From 32c76c820b7d2387eac649c32b445573dc10cdce Mon Sep 17 00:00:00 2001 From: Blink WPT Bot Date: Mon, 20 Nov 2023 10:20:36 +0000 Subject: [PATCH] Bug 1862325 [wpt PR 42873] - NavigationActivation prototype, a=testonly Automatic update from web-platform-tests NavigationActivation prototype (#42873) NavigationActivation is a new object (exposed as `navigation.activation`). It is updated when a new Document is "activated": initial Document creation, restore from bfcache, or (in a future CL) prerender activation. It has three pieces of state: * `activation.entry`: The current NavigationHistoryEntry at the time of activation. * `activation.from`: The current NavigationHistoryEntry immediately before activation (i.e., the entry we came from). This will be null if the navigation was cross-origin, or if the previous entry was not in the same-origin contiguous region of the back/forward list that is available in `navigation.entries()`. * `activation.navigationType`: The navigationType ('push', 'replace', 'reload', or 'traverse') of the navigation that activated the current Document. Note that `entry` or `from` may be a NavigationHistoryEntry that is no longer present in `navigation.entries()` (e.g., when doing a replace navigation, `activation.from` will be the replaced entry). In that case, the entry will remain visible, but because it is a "disposed" entry, its index will be -1 and attempting to `navigation.traverseTo()` its key will be rejected. Initial discussion: https://github.com/whatwg/html/issues/9760 Draft spec PR: https://github.com/whatwg/html/pull/9856 I2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/EfqxeH3Iwh4 Bug: 1492932 Change-Id: I2e090a8366906e4cb6778893ad9ffdca18d6ec37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4990011 Reviewed-by: Domenic Denicola Commit-Queue: Nate Chapin Cr-Commit-Position: refs/heads/main@{#1220983} Co-authored-by: Nate Chapin -- wpt-commits: c2ca6ebdc7f92fbaf7308c91dda05bcaf24ef455 wpt-pr: 42873 --- ...activation-after-bfcache-cross-origin.html | 28 +++++++++++ .../activation-after-bfcache.html | 34 ++++++++++++++ .../activation-history-pushState.html | 18 +++++++ .../activation-history-replaceState.html | 17 +++++++ .../activation-initial-about-blank.html | 23 +++++++++ .../activation-push-cross-origin.html | 25 ++++++++++ .../activation-push.html | 30 ++++++++++++ .../activation-reload.html | 21 +++++++++ .../activation-replace-cross-origin.html | 25 ++++++++++ .../activation-replace.html | 44 +++++++++++++++++ ...ion-same-document-then-cross-document.html | 24 ++++++++++ .../activation-traverse-not-in-entries.html | 32 +++++++++++++ .../activation-traverse-then-clobber.html | 47 +++++++++++++++++++ .../activation-traverse.html | 38 +++++++++++++++ .../no-referrer-dynamic-url-censored.html | 3 ++ .../no-referrer-from-meta-url-censored.html | 3 ++ .../no-referrer-url-censored.html | 3 ++ 17 files changed, 415 insertions(+) create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-after-bfcache-cross-origin.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-after-bfcache.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-history-pushState.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-history-replaceState.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-initial-about-blank.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-push-cross-origin.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-push.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-reload.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-replace-cross-origin.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-replace.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-same-document-then-cross-document.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse-not-in-entries.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse-then-clobber.html create mode 100644 testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse.html diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-after-bfcache-cross-origin.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-after-bfcache-cross-origin.html new file mode 100644 index 0000000000000..3a0b8804b4091 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-after-bfcache-cross-origin.html @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-after-bfcache.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-after-bfcache.html new file mode 100644 index 0000000000000..4c246e9d624a0 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-after-bfcache.html @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-history-pushState.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-history-pushState.html new file mode 100644 index 0000000000000..bcc56136f7e2e --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-history-pushState.html @@ -0,0 +1,18 @@ + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-history-replaceState.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-history-replaceState.html new file mode 100644 index 0000000000000..70dc7b8eedee5 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-history-replaceState.html @@ -0,0 +1,17 @@ + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-initial-about-blank.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-initial-about-blank.html new file mode 100644 index 0000000000000..402093809ca65 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-initial-about-blank.html @@ -0,0 +1,23 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-push-cross-origin.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-push-cross-origin.html new file mode 100644 index 0000000000000..15651bf78aac9 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-push-cross-origin.html @@ -0,0 +1,25 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-push.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-push.html new file mode 100644 index 0000000000000..99548314c4606 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-push.html @@ -0,0 +1,30 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-reload.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-reload.html new file mode 100644 index 0000000000000..f65afc74bc145 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-reload.html @@ -0,0 +1,21 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-replace-cross-origin.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-replace-cross-origin.html new file mode 100644 index 0000000000000..a835b7f4c52a2 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-replace-cross-origin.html @@ -0,0 +1,25 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-replace.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-replace.html new file mode 100644 index 0000000000000..71624fd7cece6 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-replace.html @@ -0,0 +1,44 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-same-document-then-cross-document.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-same-document-then-cross-document.html new file mode 100644 index 0000000000000..3daa4de66ee3a --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-same-document-then-cross-document.html @@ -0,0 +1,24 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse-not-in-entries.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse-not-in-entries.html new file mode 100644 index 0000000000000..c8386615a24f6 --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse-not-in-entries.html @@ -0,0 +1,32 @@ + + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse-then-clobber.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse-then-clobber.html new file mode 100644 index 0000000000000..c02837624098d --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse-then-clobber.html @@ -0,0 +1,47 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse.html b/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse.html new file mode 100644 index 0000000000000..218fe8626910a --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigation-activation/activation-traverse.html @@ -0,0 +1,38 @@ + + + + + diff --git a/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-dynamic-url-censored.html b/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-dynamic-url-censored.html index 7a5544c4196be..f16f828220592 100644 --- a/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-dynamic-url-censored.html +++ b/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-dynamic-url-censored.html @@ -12,6 +12,7 @@ i.contentWindow.navigation.navigate("/common/blank.html?2"); await new Promise(r => i.onload = () => t.step_timeout(r, 0)); assert_not_equals(i.contentWindow.navigation.entries()[0].url, null); + assert_not_equals(i.contentWindow.navigation.activation.from.url, null); // Apply no-referrer, the url should now be censored when no longer on that document. i.contentWindow.navigation.back(); @@ -21,6 +22,7 @@ i.contentWindow.navigation.forward(); await new Promise(r => i.onload = () => t.step_timeout(r, 0)); assert_equals(i.contentWindow.navigation.entries()[0].url, null); + assert_equals(i.contentWindow.navigation.activation.from.url, null); // Overwrite the referrer policy, the url should be visible again. i.contentWindow.navigation.back(); @@ -29,5 +31,6 @@ i.contentWindow.navigation.forward(); await new Promise(r => i.onload = () => t.step_timeout(r, 0)); assert_not_equals(i.contentWindow.navigation.entries()[0].url, null); + assert_not_equals(i.contentWindow.navigation.activation.from.url, null); }, "The url of a document is censored by a no-referrer policy dynamically"); diff --git a/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-from-meta-url-censored.html b/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-from-meta-url-censored.html index fc563f509e79c..6e759d595d240 100644 --- a/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-from-meta-url-censored.html +++ b/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-from-meta-url-censored.html @@ -18,6 +18,7 @@ assert_equals(i.contentWindow.navigation.currentEntry.index, 2); assert_equals(i.contentWindow.navigation.entries()[0].url, null); assert_equals(i.contentWindow.navigation.entries()[1].url, null); + assert_equals(i.contentWindow.navigation.activation.from.url, null); // Navigating back to no-referrer.html should uncensor the urls. i.contentWindow.navigation.back(); @@ -28,5 +29,7 @@ "/navigation-api/navigation-history-entry/resources/no-referrer-meta.html"); assert_equals(new URL(i.contentWindow.navigation.entries()[1].url).pathname, "/navigation-api/navigation-history-entry/resources/no-referrer-meta.html"); + assert_equals(new URL(i.contentWindow.navigation.activation.entry.url).pathname, + "/navigation-api/navigation-history-entry/resources/no-referrer-meta.html"); }, "The url of a document with no-referrer referrer meta tag is censored in NavigationHistoryEntry"); diff --git a/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-url-censored.html b/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-url-censored.html index e7eb1afc7d1d2..e88d4453db3ed 100644 --- a/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-url-censored.html +++ b/testing/web-platform/tests/navigation-api/navigation-history-entry/no-referrer-url-censored.html @@ -18,6 +18,7 @@ assert_equals(i.contentWindow.navigation.currentEntry.index, 2); assert_equals(i.contentWindow.navigation.entries()[0].url, null); assert_equals(i.contentWindow.navigation.entries()[1].url, null); + assert_equals(i.contentWindow.navigation.activation.from.url, null); // Navigating back to no-referrer.html should uncensor the urls. i.contentWindow.navigation.back(); @@ -28,5 +29,7 @@ "/navigation-api/navigation-history-entry/resources/no-referrer.html"); assert_equals(new URL(i.contentWindow.navigation.entries()[1].url).pathname, "/navigation-api/navigation-history-entry/resources/no-referrer.html"); + assert_equals(new URL(i.contentWindow.navigation.activation.entry.url).pathname, + "/navigation-api/navigation-history-entry/resources/no-referrer.html"); }, "The url of a document with no-referrer referrer policy is censored in NavigationHistoryEntry");