Bug 1760682 [wpt PR 33287] - Navigation API: serialize state first in navigate()/reload(), a=testonly
authorDomenic Denicola <domenic@chromium.org>
Thu, 24 Mar 2022 12:19:15 +0000
changeset 687320 7bc7abeb7bc1c3f03fe7ebadc5d822e96c51d515
parent 687319 27fb34fc4164a2aca1ae7fbfd54dc121312c3dd1
child 687321 6a629b39dba637e71941d67753aee4e367acb30c
push id2831
push userffxbld-merge
push dateMon, 25 Apr 2022 15:51:01 +0000
treeherdermozilla-release@bad8853d0c21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1760682, 33287, 1183545, 3540582, 983988
milestone100.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1760682 [wpt PR 33287] - Navigation API: serialize state first in navigate()/reload(), a=testonly Automatic update from web-platform-tests Navigation API: serialize state first in navigate()/reload() Follows https://github.com/WICG/navigation-api/pull/215. Bug: 1183545 Change-Id: Ia88d09993821dce59a7cbc2768941ff28db53277 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3540582 Reviewed-by: Nate Chapin <japhet@chromium.org> Commit-Queue: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#983988} -- wpt-commits: ada05ad83ef1ff9882abcacd3b3759be0253b4dd wpt-pr: 33287
testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach-in-onnavigate.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach-in-serialization.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-beforeunload-unserializablestate.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-detached-unserializablestate.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-unload-unserializablestate.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach-in-onnavigate.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach-in-serialization.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-beforeunload-unserializablestate.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-detached-unserializablestate.html
testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-unload-unserializablestate.html
rename from testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach.html
rename to testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach-in-onnavigate.html
copy from testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach.html
copy to testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach-in-serialization.html
--- a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach.html
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-detach-in-serialization.html
@@ -6,13 +6,19 @@
 <iframe id="i" src="/common/blank.html"></iframe>
 
 <script>
 promise_test(async t => {
   await new Promise(resolve => window.onload = resolve);
 
   const iWindow = i.contentWindow;
   const iDOMException = iWindow.DOMException;
-  i.contentWindow.navigation.onnavigate = () => i.remove();
 
-  await assertBothRejectDOM(t, i.contentWindow.navigation.navigate("#1"), "AbortError", iWindow, iDOMException);
-}, "navigate() promise rejections when detaching an iframe inside onnavigate");
+  const trappedState = {
+    get prop() {
+      i.remove();
+      return "whatever";
+    }
+  };
+
+  await assertBothRejectDOM(t, i.contentWindow.navigation.navigate("#1", { state: trappedState }), "InvalidStateError", iWindow, iDOMException);
+}, "navigate() promise rejections when detaching an iframe inside state serialization");
 </script>
--- a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-beforeunload-unserializablestate.html
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-beforeunload-unserializablestate.html
@@ -14,18 +14,18 @@ promise_test(async t => {
   i.contentWindow.navigation.onnavigatesuccess = t.unreached_func('onnavigatesuccess should not be called');
   i.contentWindow.navigation.onnavigateerror = t.unreached_func('onnavigateerror should not be called');
 
   let assertionPromise;
   // The iframe does not have sticky activation, so per
   // https://html.spec.whatwg.org/#prompt-to-unload-a-document, no prompt is
   // shown and the navigation will proceed.
   i.contentWindow.onbeforeunload = t.step_func(() => {
-    assertionPromise = assertBothRejectDOM(t, i.contentWindow.navigation.navigate("/common/blank.html?1", { state: document.body }), "InvalidStateError", i.contentWindow);
+    assertionPromise = assertBothRejectDOM(t, i.contentWindow.navigation.navigate("/common/blank.html?1", { state: document.body }), "DataCloneError", i.contentWindow);
   });
   i.contentWindow.navigation.navigate("?1");
 
   assert_not_equals(assertionPromise, undefined);
   await assertionPromise;
 
   assert_equals(navigateEventCount, 1);
-}, `navigate() with an unserializable state inside onbeforeunload throws "InvalidStateError", not "DataCloneError"`);
+}, `navigate() with an unserializable state inside onbeforeunload "DataCloneError", not "InvalidStateError"`);
 </script>
--- a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-detached-unserializablestate.html
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-detached-unserializablestate.html
@@ -10,11 +10,11 @@ promise_test(async t => {
   await new Promise(resolve => window.onload = resolve);
   const iWindow = i.contentWindow;
   const iDOMException = iWindow.DOMException;
 
   i.remove();
 
   iWindow.navigation.onnavigate = t.unreached_func("onnavigate");
 
-  await assertBothRejectDOM(t, iWindow.navigation.navigate("https://example.com/", { state: document.body }), "InvalidStateError", iWindow, iDOMException);
-}, `navigate() with unserializable state in a detached iframe throws "InvalidStateError", not "DataCloneError"`);
+  await assertBothRejectDOM(t, iWindow.navigation.navigate("https://example.com/", { state: document.body }), "DataCloneError", iWindow, iDOMException);
+}, `navigate() with unserializable state in a detached iframe throws "DataCloneError", not "InvalidStateError"`);
 </script>
--- a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-unload-unserializablestate.html
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/navigate-rejection-order-unload-unserializablestate.html
@@ -13,15 +13,15 @@ promise_test(async t => {
   i.contentWindow.navigation.onnavigate = () => navigateEventCount++;
   i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess should not be called");
   i.contentWindow.navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called");
 
   i.contentWindow.navigation.navigate("?1");
 
   await new Promise(resolve => {
     i.contentWindow.onunload = t.step_func(async () => {
-      await assertBothRejectDOM(t, i.contentWindow.navigation.navigate("?2", { state: document.body }), "InvalidStateError", i.contentWindow);
+      await assertBothRejectDOM(t, i.contentWindow.navigation.navigate("?2", { state: document.body }), "DataCloneError", i.contentWindow);
       assert_equals(navigateEventCount, 1);
       resolve();
     });
   });
-}, `navigate() with an unserializable state inside onunload throws "InvalidStateError", not "DataCloneError"`);
+}, `navigate() with an unserializable state inside onunload throws "DataCloneError", not "InvalidStateError"`);
 </script>
rename from testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach.html
rename to testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach-in-onnavigate.html
copy from testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach.html
copy to testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach-in-serialization.html
--- a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach.html
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-detach-in-serialization.html
@@ -6,13 +6,19 @@
 <iframe id="i" src="/common/blank.html"></iframe>
 
 <script>
 promise_test(async t => {
   await new Promise(resolve => window.onload = resolve);
 
   const iWindow = i.contentWindow;
   const iDOMException = iWindow.DOMException;
-  i.contentWindow.navigation.onnavigate = () => i.remove();
 
-  await assertBothRejectDOM(t, i.contentWindow.navigation.reload(), "AbortError", iWindow, iDOMException);
-}, "reload() promise rejections when detaching an iframe inside onnavigate");
+  const trappedState = {
+    get prop() {
+      i.remove();
+      return "whatever";
+    }
+  };
+
+  await assertBothRejectDOM(t, i.contentWindow.navigation.reload({ state: trappedState }), "InvalidStateError", iWindow, iDOMException);
+}, "reload() promise rejections when detaching an iframe inside state serialization");
 </script>
--- a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-beforeunload-unserializablestate.html
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-beforeunload-unserializablestate.html
@@ -14,18 +14,18 @@ promise_test(async t => {
   i.contentWindow.navigation.onnavigatesuccess = t.unreached_func('onnavigatesuccess should not be called');
   i.contentWindow.navigation.onnavigateerror = t.unreached_func('onnavigateerror should not be called');
 
   let assertionPromise;
   // The iframe does not have sticky activation, so per
   // https://html.spec.whatwg.org/#prompt-to-unload-a-document, no prompt is
   // shown and the navigation will proceed.
   i.contentWindow.onbeforeunload = t.step_func(() => {
-    assertionPromise = assertBothRejectDOM(t, i.contentWindow.navigation.reload({ state: document.body }), "InvalidStateError", i.contentWindow);
+    assertionPromise = assertBothRejectDOM(t, i.contentWindow.navigation.reload({ state: document.body }), "DataCloneError", i.contentWindow);
   });
   i.contentWindow.navigation.navigate("?1");
 
   assert_not_equals(assertionPromise, undefined);
   await assertionPromise;
 
   assert_equals(navigateEventCount, 1);
-}, `reload() with an unserializable state inside onbeforeunload throws "InvalidStateError", not "DataCloneError"`);
+}, `reload() with an unserializable state inside onbeforeunload throws "DataCloneError", not "InvalidStateError"`);
 </script>
--- a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-detached-unserializablestate.html
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-detached-unserializablestate.html
@@ -10,11 +10,11 @@ promise_test(async t => {
   await new Promise(resolve => window.onload = resolve);
   const iWindow = i.contentWindow;
   const iDOMException = iWindow.DOMException;
 
   i.remove();
 
   iWindow.navigation.onnavigate = t.unreached_func("onnavigate");
 
-  await assertBothRejectDOM(t, iWindow.navigation.reload({ state: document.body }), "InvalidStateError", iWindow, iDOMException);
-}, `reload() with unserializable state in a detached iframe throws "InvalidStateError", not "DataCloneError"`);
+  await assertBothRejectDOM(t, iWindow.navigation.reload({ state: document.body }), "DataCloneError", iWindow, iDOMException);
+}, `reload() with unserializable state in a detached iframe throws "DataCloneError", not "InvalidStateError"`);
 </script>
--- a/testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-unload-unserializablestate.html
+++ b/testing/web-platform/tests/navigation-api/navigation-methods/return-value/reload-rejection-order-unload-unserializablestate.html
@@ -11,17 +11,22 @@ promise_test(async t => {
 
   let navigateEventCount = 0;
   i.contentWindow.navigation.onnavigate = () => navigateEventCount++;
   i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess should not be called");
   i.contentWindow.navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called");
 
   i.contentWindow.navigation.navigate("?1");
 
+  let assertionPromise;
   await new Promise(resolve => {
-    i.contentWindow.onunload = t.step_func(async () => {
-      await assertBothRejectDOM(t, i.contentWindow.navigation.reload({ state: document.body }), "InvalidStateError", i.contentWindow);
+    i.contentWindow.onunload = t.step_func(() => {
+      assertionPromise = assertBothRejectDOM(t, i.contentWindow.navigation.reload({ state: document.body }), "DataCloneError", i.contentWindow);
       assert_equals(navigateEventCount, 1);
       resolve();
     });
   });
-}, `reload() with an unserializable state inside onunload throws "InvalidStateError", not "DataCloneError"`);
+
+  assert_not_equals(assertionPromise, undefined);
+  await assertionPromise;
+
+}, `reload() with an unserializable state inside onunload throws "DataCloneError", not "InvalidStateError"`);
 </script>