summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-api/navigation-methods/return-value/resources/back-forward-opaque-origin-page.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/navigation-api/navigation-methods/return-value/resources/back-forward-opaque-origin-page.html')
-rw-r--r--testing/web-platform/tests/navigation-api/navigation-methods/return-value/resources/back-forward-opaque-origin-page.html28
1 files changed, 28 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/resources/back-forward-opaque-origin-page.html b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/resources/back-forward-opaque-origin-page.html
new file mode 100644
index 0000000000..ec63363952
--- /dev/null
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/resources/back-forward-opaque-origin-page.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="helpers.js"></script>
+<!-- Put this page in a sandbox to give it an opaque origin -->
+
+<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));
+
+ navigation.onnavigate = t.unreached_func("onnavigate should not be called");
+ navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess should not be called");
+ navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called");
+
+ location.hash = "#1";
+ await new Promise(resolve => window.onhashchange = resolve);
+ location.hash = "#2";
+ await new Promise(resolve => window.onhashchange = resolve);
+ history.back();
+ await new Promise(resolve => window.onhashchange = resolve);
+
+ assert_equals(location.hash, "#1");
+
+ await assertBothRejectDOM(t, navigation.back(), "InvalidStateError");
+ await assertBothRejectDOM(t, navigation.forward(), "InvalidStateError");
+}, "navigation.back()/forward() in an opaque origin iframe");
+</script>