From 24630e5dabd2a6e9d699d498de7f0e957d80de87 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 13 Oct 2023 16:45:25 +0000 Subject: [PATCH] Bug 1856740 [wpt PR 42233] - Make navigation-api/navigate-event/ resilient to starting with extra NavigationHistoryEntries, a=testonly Automatic update from web-platform-tests Make navigation-api/navigate-event/ resilient to starting with extra NavigationHistoryEntries When WPT are run in-browser or via wptrunner, there may be additional session history entries when the test starts, so the tests shouldn't assume that they start with navigation.entries().length == 1 or navigation.currentEntry.index == 0. This is a workaround for https://github.com/web-platform-tests/wpt/issues/33590. Change-Id: I978d492d5d31d110716d6a1d84732aff792aca14 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4904223 Reviewed-by: Domenic Denicola Auto-Submit: Nate Chapin Commit-Queue: Nate Chapin Cr-Commit-Position: refs/heads/main{#1204863} -- wpt-commits: 4cd570dc80fec7b17cad121e7ac866badf62df38 wpt-pr: 42233 UltraBlame original commit: 0ffb634e43b9353a7b4d17a11b06b1ca4cb3f779 --- .../intercept-and-navigate.html | 32 ++++++++++++-- .../intercept-navigation-back.html | 26 ++++++++++- .../intercept-same-document-history-back.html | 38 ++++++++++++++-- .../navigate-destination-dynamic-index.html | 13 +++++- .../navigate-history-back-after-fragment.html | 11 ++++- ...navigate-history-back-after-pushState.html | 15 +++++-- .../navigate-history-back-noop.html | 43 ++++++++++++++++--- ...avigate-navigation-back-same-document.html | 11 ++++- ...ion-back-same-document-preventDefault.html | 28 +++++++++++- ...n-iframe-same-document-preventDefault.html | 28 +++++++++++- ...nd-same-doc-child-and-cross-doc-child.html | 30 +++++++++++-- ...ument-preventDefault-multiple-windows.html | 30 ++++++++++++- ...seTo-top-cancels-cross-document-child.html | 28 +++++++++++- .../same-url-replace-cross-document.html | 26 +++++++++-- .../same-url-replace-same-document.html | 34 +++++++++++++-- 15 files changed, 357 insertions(+), 36 deletions(-) diff --git a/testing/web-platform/tests/navigation-api/navigate-event/intercept-and-navigate.html b/testing/web-platform/tests/navigation-api/navigate-event/intercept-and-navigate.html index 9eb6d604c06a2..92b9d7af5dc29 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/intercept-and-navigate.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/intercept-and-navigate.html @@ -47,6 +47,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -157,7 +177,7 @@ currentEntry . index -0 +start_index ) ; assert_equals @@ -169,7 +189,9 @@ ) . length -2 +start_length ++ +1 ) ; navigation @@ -229,6 +251,8 @@ currentEntry . index +start_index ++ 1 ) ; @@ -241,7 +265,9 @@ ) . length -2 +start_length ++ +1 ) ; } diff --git a/testing/web-platform/tests/navigation-api/navigate-event/intercept-navigation-back.html b/testing/web-platform/tests/navigation-api/navigate-event/intercept-navigation-back.html index 94fd3b07966c1..3eff13a17ee14 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/intercept-navigation-back.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/intercept-navigation-back.html @@ -46,6 +46,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -159,7 +179,9 @@ ) . length -2 +start_length ++ +1 ) ; assert_equals @@ -173,7 +195,7 @@ ( ) [ -0 +start_index ] ) ; diff --git a/testing/web-platform/tests/navigation-api/navigate-event/intercept-same-document-history-back.html b/testing/web-platform/tests/navigation-api/navigate-event/intercept-same-document-history-back.html index 95c228b2f32b0..46a3eaf9175e2 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/intercept-same-document-history-back.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/intercept-same-document-history-back.html @@ -46,6 +46,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -149,7 +169,9 @@ ) . length -3 +start_length ++ +2 ) ; assert_equals @@ -159,6 +181,8 @@ currentEntry . index +start_index ++ 1 ) ; @@ -193,7 +217,9 @@ ) . length -3 +start_length ++ +2 ) ; assert_equals @@ -203,7 +229,7 @@ currentEntry . index -0 +start_index ) ; assert_equals @@ -278,7 +304,9 @@ ) . length -3 +start_length ++ +2 ) ; assert_equals @@ -288,6 +316,8 @@ currentEntry . index +start_index ++ 2 ) ; diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigate-destination-dynamic-index.html b/testing/web-platform/tests/navigation-api/navigate-event/navigate-destination-dynamic-index.html index 52e159103da1f..6fdc8ea696068 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigate-destination-dynamic-index.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigate-destination-dynamic-index.html @@ -74,6 +74,15 @@ = > { +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -164,7 +173,7 @@ back_destination . index -0 +start_index ) ; } @@ -262,6 +271,8 @@ destination . index +start_index ++ 1 ) ; diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-after-fragment.html b/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-after-fragment.html index 5e3d74f99b0f4..6158976dd4f9c 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-after-fragment.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-after-fragment.html @@ -71,6 +71,15 @@ length ; let +start_index += +navigation +. +currentEntry +. +index +; +let target_key = navigation @@ -218,7 +227,7 @@ destination . index -0 +start_index ) ; assert_equals diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-after-pushState.html b/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-after-pushState.html index 14327830bb6ef..ef85451e869b8 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-after-pushState.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-after-pushState.html @@ -64,13 +64,22 @@ > { let -start_length +start_history_length = history . length ; let +start_index += +navigation +. +currentEntry +. +index +; +let target_key = navigation @@ -107,7 +116,7 @@ history . length -start_length +start_history_length + 1 ) @@ -223,7 +232,7 @@ destination . index -0 +start_index ) ; assert_equals diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-noop.html b/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-noop.html index b82048311535c..ba168a4742ba1 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-noop.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigate-history-back-noop.html @@ -69,6 +69,33 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; +let +start_history_length += +history +. +length +; / / Wait @@ -172,7 +199,7 @@ ) . length -1 +start_length ) ; assert_equals @@ -182,7 +209,7 @@ currentEntry . index -0 +start_index ) ; assert_equals @@ -190,7 +217,9 @@ history . length -2 +start_history_length ++ +1 ) ; i @@ -208,7 +237,7 @@ ) . length -1 +start_length ) ; assert_equals @@ -218,7 +247,7 @@ currentEntry . index -0 +start_index ) ; assert_equals @@ -226,7 +255,9 @@ history . length -2 +start_history_length ++ +1 ) ; / diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigate-navigation-back-same-document.html b/testing/web-platform/tests/navigation-api/navigate-event/navigate-navigation-back-same-document.html index 9b422b6f6129f..327934f39a094 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigate-navigation-back-same-document.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigate-navigation-back-same-document.html @@ -105,6 +105,15 @@ . id ; +let +target_index += +navigation +. +currentEntry +. +index +; navigation . navigate @@ -239,7 +248,7 @@ destination . index -0 +target_index ) ; assert_equals diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigation-back-same-document-preventDefault.html b/testing/web-platform/tests/navigation-api/navigate-event/navigation-back-same-document-preventDefault.html index dfa859a55cb81..2e58aa91664aa 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigation-back-same-document-preventDefault.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigation-back-same-document-preventDefault.html @@ -74,6 +74,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -143,7 +163,9 @@ ) . length -2 +start_length ++ +1 ) ; assert_equals @@ -153,6 +175,8 @@ currentEntry . index +start_index ++ 1 ) ; @@ -227,6 +251,8 @@ currentEntry . index +start_index ++ 1 ) ; diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-in-iframe-same-document-preventDefault.html b/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-in-iframe-same-document-preventDefault.html index 0f4a7f298d902..bd5b0ca869bdb 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-in-iframe-same-document-preventDefault.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-in-iframe-same-document-preventDefault.html @@ -96,6 +96,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -210,7 +230,9 @@ ) . length -2 +start_length ++ +1 ) ; assert_equals @@ -236,6 +258,8 @@ currentEntry . index +start_index ++ 1 ) ; @@ -479,6 +503,8 @@ currentEntry . index +start_index ++ 1 ) ; diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-navigates-top-and-same-doc-child-and-cross-doc-child.html b/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-navigates-top-and-same-doc-child-and-cross-doc-child.html index 22d35b3d22fe7..660666df58ca0 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-navigates-top-and-same-doc-child-and-cross-doc-child.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-navigates-top-and-same-doc-child-and-cross-doc-child.html @@ -91,6 +91,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -213,7 +233,9 @@ ) . length -2 +start_length ++ +1 ) ; assert_equals @@ -255,6 +277,8 @@ currentEntry . index +start_index ++ 1 ) ; @@ -408,7 +432,7 @@ ( ) [ -0 +start_index ] . key @@ -487,7 +511,7 @@ currentEntry . index -0 +start_index ) ; assert_equals diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-same-document-preventDefault-multiple-windows.html b/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-same-document-preventDefault-multiple-windows.html index bc840411274b7..cbeeb00777292 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-same-document-preventDefault-multiple-windows.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-same-document-preventDefault-multiple-windows.html @@ -69,6 +69,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -154,7 +174,9 @@ ) . length -2 +start_length ++ +1 ) ; assert_equals @@ -180,6 +202,8 @@ currentEntry . index +start_index ++ 1 ) ; @@ -260,7 +284,7 @@ ( ) [ -0 +start_index ] . key @@ -276,6 +300,8 @@ currentEntry . index +start_index ++ 1 ) ; diff --git a/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-top-cancels-cross-document-child.html b/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-top-cancels-cross-document-child.html index 5a835ee111f1d..b5f773a701141 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-top-cancels-cross-document-child.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/navigation-traverseTo-top-cancels-cross-document-child.html @@ -96,6 +96,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -202,7 +222,9 @@ ) . length -2 +start_length ++ +1 ) ; assert_equals @@ -228,6 +250,8 @@ currentEntry . index +start_index ++ 1 ) ; @@ -302,7 +326,7 @@ ( ) [ -0 +start_index ] . key diff --git a/testing/web-platform/tests/navigation-api/navigate-event/same-url-replace-cross-document.html b/testing/web-platform/tests/navigation-api/navigate-event/same-url-replace-cross-document.html index fec80a3f1381b..88eeb5e781d29 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/same-url-replace-cross-document.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/same-url-replace-cross-document.html @@ -63,6 +63,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -122,7 +142,7 @@ ) . length -1 +start_length ) ; navigation @@ -194,7 +214,7 @@ ) . length -1 +start_length ) ; assert_equals @@ -204,7 +224,7 @@ currentEntry . index -0 +start_index ) ; } diff --git a/testing/web-platform/tests/navigation-api/navigate-event/same-url-replace-same-document.html b/testing/web-platform/tests/navigation-api/navigate-event/same-url-replace-same-document.html index 6d91a67b2e2f2..27d97b783d1d8 100644 --- a/testing/web-platform/tests/navigation-api/navigate-event/same-url-replace-same-document.html +++ b/testing/web-platform/tests/navigation-api/navigate-event/same-url-replace-same-document.html @@ -63,6 +63,26 @@ = > { +let +start_length += +navigation +. +entries +( +) +. +length +; +let +start_index += +navigation +. +currentEntry +. +index +; / / Wait @@ -122,7 +142,7 @@ ) . length -1 +start_length ) ; await @@ -146,7 +166,9 @@ ) . length -2 +start_length ++ +1 ) ; assert_equals @@ -156,6 +178,8 @@ currentEntry . index +start_index ++ 1 ) ; @@ -205,7 +229,9 @@ ) . length -2 +start_length ++ +1 ) ; assert_equals @@ -215,6 +241,8 @@ currentEntry . index +start_index ++ 1 ) ;