summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-api/navigation-methods/traverseTo-detach-between-navigate-and-navigatesuccess.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/navigation-api/navigation-methods/traverseTo-detach-between-navigate-and-navigatesuccess.html
parentInitial commit. (diff)
downloadfirefox-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/navigation-methods/traverseTo-detach-between-navigate-and-navigatesuccess.html')
-rw-r--r--testing/web-platform/tests/navigation-api/navigation-methods/traverseTo-detach-between-navigate-and-navigatesuccess.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-api/navigation-methods/traverseTo-detach-between-navigate-and-navigatesuccess.html b/testing/web-platform/tests/navigation-api/navigation-methods/traverseTo-detach-between-navigate-and-navigatesuccess.html
new file mode 100644
index 0000000000..43bde9a103
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/traverseTo-detach-between-navigate-and-navigatesuccess.html
@@ -0,0 +1,54 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="return-value/resources/helpers.js"></script>
+
+<iframe id="i" src="/common/blank.html"></iframe>
+
+<script>
+async_test(t => {
+ window.onload = t.step_func(() => {
+ const iWindow = i.contentWindow;
+ const iDOMException = iWindow.DOMException;
+ const iNavigationHistoryEntry = iWindow.NavigationHistoryEntry;
+
+ i.contentWindow.navigation.navigate("#1").finished.then(t.step_func(() => {
+ assert_equals(i.contentWindow.navigation.entries().length, 2);
+ let key = i.contentWindow.navigation.entries()[0].key;
+
+ let onnavigateerror_called = false;
+ let result;
+
+ i.contentWindow.navigation.onnavigate = t.step_func(e => {
+ // 1. The intercept handler runs.
+ // 2. "t.step_timeout(handlerRunResolve, 0)" executes handlerRunResolve in a macro task.
+ // 3. In the next microtask, the iframe is removed.
+ // 4. "t.step_timeout(resolve, 5)" executes and the intercept handler promise resolves.
+ let handlerRunResolve;
+ new Promise(r => handlerRunResolve = r).then(() => i.remove());
+ e.intercept({ handler() {
+ t.step_timeout(handlerRunResolve, 0);
+ return new Promise(resolve => t.step_timeout(resolve, 5));
+ }});
+ });
+
+ i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("navigatesuccess must not fire");
+
+ i.contentWindow.navigation.onnavigateerror = t.step_func(e => {
+ assert_false(onnavigateerror_called);
+ onnavigateerror_called = true;
+ assert_equals(e.filename, location.href);
+ assert_greater_than(e.lineno, 0);
+ assert_greater_than(e.colno, 0);
+
+ assertCommittedFulfillsFinishedRejectsExactly(t, result, iWindow.navigation.currentEntry, e.error, iWindow, iDOMException, iNavigationHistoryEntry).then(
+ () => t.done(),
+ t.step_func(err => { throw err; })
+ );
+ });
+
+ result = i.contentWindow.navigation.traverseTo(key);
+ }));
+ });
+}, "Detach a window between when a traverseTo() fires navigate and navigatesuccess");
+</script>