diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/navigation-api/per-entry-events/dispose-same-document-intercept.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
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 | 71 |
1 files changed, 71 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..44aa096aaf --- /dev/null +++ b/testing/web-platform/tests/navigation-api/per-entry-events/dispose-same-document-intercept.html @@ -0,0 +1,71 @@ +<!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)); + + location.hash = "#1"; + location.hash = "#2"; + location.hash = "#3"; + + assert_equals(navigation.entries().length, 4); + const [entry0, entry1, entry2, entry3] = navigation.entries(); + 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(), + [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(), + [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, 3); + const [finalEntry0, finalEntry1, finalEntry2] = navigation.entries(); + 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> |