diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/navigation-api/per-entry-events/dispose-same-document-intercept.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/navigation-api/per-entry-events/dispose-same-document-intercept.html')
-rw-r--r-- | testing/web-platform/tests/navigation-api/per-entry-events/dispose-same-document-intercept.html | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-api/per-entry-events/dispose-same-document-intercept.html b/testing/web-platform/tests/navigation-api/per-entry-events/dispose-same-document-intercept.html new file mode 100644 index 0000000000..862e01127b --- /dev/null +++ b/testing/web-platform/tests/navigation-api/per-entry-events/dispose-same-document-intercept.html @@ -0,0 +1,73 @@ +<!doctype html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +promise_test(async (t) => { + // Wait for after the load event so that the navigation doesn't get converted + // into a replace navigation. + await new Promise(r => window.onload = () => t.step_timeout(r, 0)); + let start_length = navigation.entries().length; + let start_index = navigation.currentEntry.index; + + location.hash = "#1"; + location.hash = "#2"; + location.hash = "#3"; + + assert_equals(navigation.entries().length, start_length + 3); + const [entry0, entry1, entry2, entry3] = navigation.entries().slice(start_index); + assert_equals((new URL(entry2.url)).hash, "#2"); + assert_equals((new URL(entry3.url)).hash, "#3"); + + let dispose2Called = false; + entry2.ondispose = t.step_func(e => { + dispose2Called = true; + + assert_equals(e.constructor, Event); + assert_equals(e.bubbles, false); + assert_equals(e.cancelable, false); + assert_equals(e.composed, false); + + assert_array_equals( + navigation.entries().slice(start_index), + [entry0, entry1, navigation.currentEntry], + "entries() is updated during dispose for entry 2"); + assert_not_equals(navigation.currentEntry, entry1, "current entry must be updated during dispose for entry 3"); + assert_true(navigation.canGoBack, "canGoBack is still true during dispose for entry 2"); + assert_false(navigation.canGoForward, "canGoForward is still false during beforedispose for entry 2"); + assert_equals(navigation.transition.navigationType, "push", "transition navigationType during dispose for entry 2"); + assert_equals(navigation.transition.from, entry1, "transition from during dispose for entry 2"); + assert_equals(location.hash, "#fork", "location.hash is updated during dispose for entry 2"); + }); + + entry3.addEventListener("dispose", t.step_func_done(e => { + assert_true(dispose2Called, "dispose for entry 2 must have happened before entry 3"); + + assert_array_equals( + navigation.entries().slice(start_index), + [entry0, entry1, navigation.currentEntry], + "entries() is updated during dispose for entry 3"); + assert_not_equals(navigation.currentEntry, entry1, "current entry must be updated during dispose for entry 3"); + assert_true(navigation.canGoBack, "canGoBack is still true during dispose for entry 3"); + assert_false(navigation.canGoForward, "canGoForward is still false during beforedispose for entry 3"); + assert_equals(navigation.transition.navigationType, "push", "transition navigationType during dispose for entry 3"); + assert_equals(navigation.transition.from, entry1, "transition from during dispose for entry 3"); + assert_equals(location.hash, "#fork", "location.hash is updated during dispose for entry 3"); + })); + + await navigation.traverseTo(entry1.key).committed; + + navigation.addEventListener("navigate", e => { + e.intercept(); + }); + + navigation.navigate("#fork"); + + assert_equals(navigation.entries().length, start_length + 2); + const [finalEntry0, finalEntry1, finalEntry2] = navigation.entries().slice(start_index); + assert_equals(finalEntry0, entry0); + assert_equals(finalEntry1, entry1); + assert_not_equals(finalEntry2, entry2); + assert_equals(navigation.currentEntry, finalEntry2); + assert_equals((new URL(finalEntry2.url)).hash, "#fork"); +}, "dispose events when forward-pruning same-document entries"); +</script> |