commit 9b629fb4e490657c327f03fb9faf527d00099478
parent ceb53ef162316194ea1e4b0cd52d6aa696ee7950
Author: Andreas Farre <farre@mozilla.com>
Date: Tue, 14 Oct 2025 10:06:34 +0000
Bug 1994118 - Test replaceState inside back handler. r=zcorpan
Copy navigation-api/navigate-event/replaceState-inside-back-handler.html
test and make it consider the infinite recursion case.
Since the only observable check is an optional throw in spec, mark this
test as optonal.
Differential Revision: https://phabricator.services.mozilla.com/D268498
Diffstat:
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/replaceState-inside-back-handler-infinite.optional.html b/testing/web-platform/tests/navigation-api/navigate-event/replaceState-inside-back-handler-infinite.optional.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../navigation-methods/return-value/resources/helpers.js"></script>
+<script>
+promise_test(async t => {
+ await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
+ await navigation.navigate("#push").finished;
+ let { reject, promise } = Promise.withResolvers();
+ navigation.addEventListener("navigate", () => {
+ try {
+ history.replaceState(null, "", "#");
+ } catch (e) {
+ reject(e);
+ }
+ });
+ await Promise.all([
+ promise_rejects_dom(t, "SecurityError", promise, "Infinite recursion in replaceState"),
+ assertBothRejectDOM(t, navigation.back(), "AbortError")]);
+}, "infinite replaceState inside a navigate event for navigation.back()");
+</script>