[bfcache] Use pagehide instead of unload in navigation-api webtests
These tests are testing navigation API's behavior upon navigating away.
We can use pagehide instead of unload, as it happens with the same timing as unload
Bug: 1488371
Change-Id: I77df62a752242adfbb0efdfe93dce827673622d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5048291
Reviewed-by: Fergal Daly <fergal@chromium.org>
Auto-Submit: Yuzu Saijo <yuzus@chromium.org>
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Commit-Queue: Yuzu Saijo <yuzus@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1229756}
diff --git a/navigation-api/navigation-methods/return-value/navigate-unload.html b/navigation-api/navigation-methods/return-value/navigate-pagehide.html
similarity index 90%
rename from navigation-api/navigation-methods/return-value/navigate-unload.html
rename to navigation-api/navigation-methods/return-value/navigate-pagehide.html
index fbc1fde..c303e65 100644
--- a/navigation-api/navigation-methods/return-value/navigate-unload.html
+++ b/navigation-api/navigation-methods/return-value/navigate-pagehide.html
@@ -17,11 +17,11 @@
i.contentWindow.navigation.navigate("?1");
await new Promise(resolve => {
- i.contentWindow.onunload = t.step_func(async () => {
+ i.contentWindow.onpagehide = t.step_func(async () => {
await assertBothRejectDOM(t, i.contentWindow.navigation.navigate("?2"), "InvalidStateError", i.contentWindow);
assert_equals(navigateEventCount, 1);
resolve();
});
});
-}, `navigate() inside onunload`);
+}, `navigate() inside onpagehide`);
</script>
diff --git a/navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-unload.html b/navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-pagehide.html
similarity index 85%
rename from navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-unload.html
rename to navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-pagehide.html
index d778dd6..79f1607 100644
--- a/navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-unload.html
+++ b/navigation-api/navigation-methods/return-value/navigate-rejection-order-invalidurl-pagehide.html
@@ -17,11 +17,11 @@
i.contentWindow.navigation.navigate("?1");
await new Promise(resolve => {
- i.contentWindow.onunload = t.step_func(async () => {
+ i.contentWindow.onpagehide = t.step_func(async () => {
await assertBothRejectDOM(t, i.contentWindow.navigation.navigate("https://example.com\u0000mozilla.org"), "SyntaxError", i.contentWindow);
assert_equals(navigateEventCount, 1);
resolve();
});
});
-}, `navigate() with an invalid URL inside onunload throws "SyntaxError", not "InvalidStateError"`);
+}, `navigate() with an invalid URL inside onpagehide throws "SyntaxError", not "InvalidStateError"`);
</script>
diff --git a/navigation-api/navigation-methods/return-value/navigate-rejection-order-unload-unserializablestate.html b/navigation-api/navigation-methods/return-value/navigate-rejection-order-pagehide-unserializablestate.html
similarity index 84%
rename from navigation-api/navigation-methods/return-value/navigate-rejection-order-unload-unserializablestate.html
rename to navigation-api/navigation-methods/return-value/navigate-rejection-order-pagehide-unserializablestate.html
index 417dd27..5a3c069 100644
--- a/navigation-api/navigation-methods/return-value/navigate-rejection-order-unload-unserializablestate.html
+++ b/navigation-api/navigation-methods/return-value/navigate-rejection-order-pagehide-unserializablestate.html
@@ -17,11 +17,11 @@
i.contentWindow.navigation.navigate("?1");
await new Promise(resolve => {
- i.contentWindow.onunload = t.step_func(async () => {
+ i.contentWindow.onpagehide = t.step_func(async () => {
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 "DataCloneError", not "InvalidStateError"`);
+}, `navigate() with an unserializable state inside onpagehide throws "DataCloneError", not "InvalidStateError"`);
</script>
diff --git a/navigation-api/navigation-methods/return-value/reload-unload.html b/navigation-api/navigation-methods/return-value/reload-pagehide.html
similarity index 90%
rename from navigation-api/navigation-methods/return-value/reload-unload.html
rename to navigation-api/navigation-methods/return-value/reload-pagehide.html
index 1906659..1c3ce0d 100644
--- a/navigation-api/navigation-methods/return-value/reload-unload.html
+++ b/navigation-api/navigation-methods/return-value/reload-pagehide.html
@@ -17,11 +17,11 @@
i.contentWindow.navigation.navigate("?1");
await new Promise(resolve => {
- i.contentWindow.onunload = t.step_func(async () => {
+ i.contentWindow.onpagehide = t.step_func(async () => {
await assertBothRejectDOM(t, i.contentWindow.navigation.reload(), "InvalidStateError", i.contentWindow);
assert_equals(navigateEventCount, 1);
resolve();
});
});
-}, `reload() inside onunload`);
+}, `reload() inside onpagehide`);
</script>
diff --git a/navigation-api/navigation-methods/return-value/reload-rejection-order-unload-unserializablestate.html b/navigation-api/navigation-methods/return-value/reload-rejection-order-pagehide-unserializablestate.html
similarity index 86%
rename from navigation-api/navigation-methods/return-value/reload-rejection-order-unload-unserializablestate.html
rename to navigation-api/navigation-methods/return-value/reload-rejection-order-pagehide-unserializablestate.html
index 9e7edcb..e976575 100644
--- a/navigation-api/navigation-methods/return-value/reload-rejection-order-unload-unserializablestate.html
+++ b/navigation-api/navigation-methods/return-value/reload-rejection-order-pagehide-unserializablestate.html
@@ -18,7 +18,7 @@
let assertionPromise;
await new Promise(resolve => {
- i.contentWindow.onunload = t.step_func(() => {
+ i.contentWindow.onpagehide = t.step_func(() => {
assertionPromise = assertBothRejectDOM(t, i.contentWindow.navigation.reload({ state: document.body }), "DataCloneError", i.contentWindow);
assert_equals(navigateEventCount, 1);
resolve();
@@ -28,5 +28,5 @@
assert_not_equals(assertionPromise, undefined);
await assertionPromise;
-}, `reload() with an unserializable state inside onunload throws "DataCloneError", not "InvalidStateError"`);
+}, `reload() with an unserializable state inside onpagehide throws "DataCloneError", not "InvalidStateError"`);
</script>