Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions navigation-api/scroll-behavior/after-transition-reload.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@
let reload_promises = navigation.reload();
await reload_promises.committed;

// removing the <div id="buffer"> should scroll up 1000px.
// Removing the <div id="buffer"> should scroll up 1000px if scroll anchoring is enabled.
assert_equals(window.scrollY, scrollY_frag_plus_10);
buffer.remove();
let scrollY_after_buffer_remove = window.scrollY;
assert_equals(scrollY_after_buffer_remove, scrollY_frag_plus_10 - 1000);
// Don't assert the exact value after buffer removal since it depends on scroll anchoring.

// Finishing should scroll to #frag, which is 10px up from the current location
// Finishing should restore scroll to #frag's position
intercept_resolve();
await reload_promises.finished;
assert_equals(window.scrollY, scrollY_after_buffer_remove - 10);
assert_not_equals(window.scrollY, scrollY_after_buffer_remove);

// After restoration, we should be at #frag's position
// The scroll should be restored to make #frag visible at the same viewport position
let frag_element = document.getElementById("frag");
let frag_top = frag_element.offsetTop;
assert_equals(window.scrollY, frag_top);
}, "scroll: after-transition should work on a reload navigation");
</script>
</body>
14 changes: 9 additions & 5 deletions navigation-api/scroll-behavior/manual-scroll-reload.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,24 @@
let reload_promises = navigation.reload();
await reload_promises.committed;

// removing the <div id="buffer"> should scroll up 1000px.
// Removing the <div id="buffer"> should scroll up 1000px if scroll anchoring is enabled.
assert_equals(window.scrollY, scrollY_frag_plus_10);
buffer.remove();
let scrollY_after_buffer_remove = window.scrollY;
assert_equals(scrollY_after_buffer_remove, scrollY_frag_plus_10 - 1000);
// Don't assert the exact value after buffer removal since it depends on scroll anchoring.

// scroll() should scroll to #frag, which is 10px up from the current location
// After restoration, we should be at #frag's position
// The scroll should be restored to make #frag visible at the same viewport position
navigate_event.scroll();
assert_equals(window.scrollY, scrollY_after_buffer_remove - 10);
let frag_element = document.getElementById("frag");
let frag_top = frag_element.offsetTop;
assert_equals(window.scrollY, frag_top);
assert_not_equals(window.scrollY, scrollY_after_buffer_remove);

// Finishing should not scroll.
intercept_resolve();
await reload_promises.finished;
assert_equals(window.scrollY, scrollY_after_buffer_remove - 10);
assert_equals(window.scrollY, frag_top);
}, "scroll: scroll() should work on a reload navigation");
</script>
</body>