diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/navigation-api/navigation-methods/back-forward-multiple-frames.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/navigation-api/navigation-methods/back-forward-multiple-frames.html')
-rw-r--r-- | testing/web-platform/tests/navigation-api/navigation-methods/back-forward-multiple-frames.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-api/navigation-methods/back-forward-multiple-frames.html b/testing/web-platform/tests/navigation-api/navigation-methods/back-forward-multiple-frames.html new file mode 100644 index 0000000000..738bfd37dc --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-methods/back-forward-multiple-frames.html @@ -0,0 +1,74 @@ +<!doctype html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe id="i" src="/common/blank.html"></iframe> +<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(resolve => window.onload = () => t.step_timeout(resolve, 0)); + // Step 1 + assert_equals(navigation.entries().length, 1, "step 1 outer entries() length"); + assert_equals(i.contentWindow.navigation.entries().length, 1, "step 1 iframe entries() length"); + await navigation.navigate("#top").committed; + // Step 2: iframe at initial entry, top on second entry + assert_equals(navigation.entries().length, 2, "step 2 outer entries() length"); + assert_equals(i.contentWindow.navigation.entries().length, 1, "step 2 iframe entries() length"); + await i.contentWindow.navigation.navigate("#iframe").committed; + + // Step 3: Both windows on second entry. + assert_equals(navigation.entries().length, 2, "step 3 outer entries() length"); + assert_equals(i.contentWindow.navigation.entries().length, 2, "step 3 iframe entries() length"); + assert_equals(navigation.currentEntry.index, 1, "step 3 outer index"); + assert_equals(i.contentWindow.navigation.currentEntry.index, 1, "step 1 iframe index"); + + // NOTE: the order of navigation in the two windows is not guaranteed; we need to wait for both. + + // Going back in the iframe should go 3->2 (navigating iframe only) + await Promise.all([ + i.contentWindow.navigation.back().committed, + new Promise(resolve => i.contentWindow.onpopstate = resolve) + ]); + assert_equals(navigation.currentEntry.index, 1, "after iframe back() outer index"); + assert_equals(i.contentWindow.navigation.currentEntry.index, 0, "after iframe back() iframe index"); + + // Going forward in iframe should go 2->3 + await Promise.all([ + i.contentWindow.navigation.forward().commited, + new Promise(resolve => i.contentWindow.onpopstate = resolve) + ]); + assert_equals(navigation.currentEntry.index, 1, "after iframe forward() outer index"); + assert_equals(i.contentWindow.navigation.currentEntry.index, 1, "after iframe forward() iframe index"); + + // Going back in top should go 3->1 (navigating both windows). + await Promise.all([ + navigation.back().commited, + new Promise(resolve => i.contentWindow.onpopstate = resolve) + ]); + assert_equals(navigation.currentEntry.index, 0, "after outer back() outer index"); + assert_equals(i.contentWindow.navigation.currentEntry.index, 0, "after outer back() iframe index"); + + // Next two should not navigate the iframe + i.contentWindow.onpopstate = t.unreached_func("popstate must not be called"); + + // Going forward in top should go 1->2 (navigating top only) + await navigation.forward().committed; + await new Promise(resolve => t.step_timeout(resolve, 0)); + assert_equals(navigation.currentEntry.index, 1, "after outer forward() outer index"); + assert_equals(i.contentWindow.navigation.currentEntry.index, 0, "after outer forward() iframe index"); + + // Going back in top should go 2->1 + await navigation.back().committed; + await new Promise(resolve => t.step_timeout(resolve, 0)); + assert_equals(navigation.currentEntry.index, 0, "after outer second back() outer index"); + assert_equals(i.contentWindow.navigation.currentEntry.index, 0, "after outer second back() iframe index"); + + // Going forward in iframe should go 1->3 (navigating both windows) + await Promise.all([ + i.contentWindow.navigation.forward().commited, + new Promise(resolve => i.contentWindow.onpopstate = resolve) + ]); + assert_equals(navigation.currentEntry.index, 1, "after iframe second forward() outer index"); + assert_equals(i.contentWindow.navigation.currentEntry.index, 1, "after iframe second forward() iframe index"); +}, "navigation.back() and navigation.forward() can navigate multiple frames"); +</script> |