diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations index d753e66e7622..071f95ffbda7 100644 --- a/LayoutTests/TestExpectations +++ b/LayoutTests/TestExpectations @@ -6858,6 +6858,7 @@ imported/w3c/web-platform-tests/navigation-api/commit-behavior/after-transition- imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-destination-getState-back-forward.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-back-noop.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-navigation-back-same-document-in-iframe.html [ Pass ] +imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigation-navigate-same-doc.html [ Skip ] imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-to-javascript.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigate-event/navigatesuccess-cross-document.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigate-event/replaceState-in-unload-then-remove-iframe.html [ Pass ] @@ -6869,6 +6870,8 @@ imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open- imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-crossdocument-crossorigin.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/entries-across-origins.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/entries-after-blank-navigation-from-cross-origin.html [ Pass ] +imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-canceled-event.html [ Pass ] +imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-after-dispatch.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/entries-array-equality.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/entries-in-new-srcdoc-iframe.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/key-id-location-reload-intercept.html [ Pass ] @@ -6877,7 +6880,6 @@ imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/opaque-o imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/sameDocument-after-navigate.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/key-id-location-replace-cross-origin.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-from-initial-about-blank-gc.html [ Pass ] -imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-intercept-history-state.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-relative-url.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/back-forward-out-of-bounds.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-push-initial-about-blank.html [ Pass ] @@ -6888,13 +6890,9 @@ imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/b imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/back-forward-initial-about-blank.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-invalid-url.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-methods/reload-base-url.html [ Pass ] -imported/w3c/web-platform-tests/navigation-api/navigation-methods/sandboxing-navigate-parent.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/navigation-methods/sandboxing-navigate-sibling.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/ordering-and-transition/transition-cross-document.html [ Skip ] -imported/w3c/web-platform-tests/navigation-api/scroll-behavior/manual-basic.html [ Pass ] -imported/w3c/web-platform-tests/navigation-api/scroll-behavior/manual-immediate-scroll.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/scroll-behavior/scroll-on-synthetic-event.html [ Pass ] -imported/w3c/web-platform-tests/navigation-api/scroll-behavior/scroll-without-intercept.html [ Pass ] imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/same-document-away-and-back-location-api.html [ Skip ] imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/cross-document-away-and-back.html [ Skip ] imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/cross-document-location-api.html [ Skip ] diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/commit-behavior/multiple-intercept-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/commit-behavior/multiple-intercept-expected.txt index 5d3c017f9ede..d67e93540b59 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/commit-behavior/multiple-intercept-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/commit-behavior/multiple-intercept-expected.txt @@ -1,10 +1,10 @@ -FAIL after-transition + after-transition assert_equals: expected "#1" but got "" -FAIL after-transition + (not provided) assert_equals: expected "#2" but got "" -FAIL after-transition + immediate assert_equals: expected true but got false -FAIL immediate + after-transition assert_equals: expected "#4" but got "" -FAIL immediate + (not provided) assert_equals: expected true but got false -FAIL immediate + immediate assert_equals: expected true but got false -FAIL (not provided) + after-transition assert_equals: expected "#7" but got "" -FAIL (not provided) + immediate assert_equals: expected true but got false +FAIL after-transition + after-transition assert_equals: expected false but got true +FAIL after-transition + (not provided) assert_equals: expected false but got true +PASS after-transition + immediate +FAIL immediate + after-transition assert_equals: expected false but got true +PASS immediate + (not provided) +PASS immediate + immediate +FAIL (not provided) + after-transition assert_equals: expected false but got true +PASS (not provided) + immediate diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-expected.txt index ecfc8c1a20e1..687b2e5668f9 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT clicking on an element that navigates same-document targeting a cross-origin window Test timed out +FAIL clicking on an element that navigates same-document targeting a cross-origin window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-sameorigindomain.sub-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-sameorigindomain.sub-expected.txt index 10d0865a6c7d..e54c69a73e8e 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-sameorigindomain.sub-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-crossorigin-sameorigindomain.sub-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT clicking on an element that navigates same-document targeting a same-origin-domain (but cross-origin) window Test timed out +FAIL clicking on an element that navigates same-document targeting a same-origin-domain (but cross-origin) window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-sameorigin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-sameorigin-expected.txt index ef8718ceff8a..dd89bf0f204d 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-sameorigin-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/click-samedocument-sameorigin-expected.txt @@ -1,6 +1,4 @@ Click me -Harness Error (TIMEOUT), message = null - -TIMEOUT clicking on an element that navigates same-document targeting a same-origin window Test timed out +FAIL clicking on an element that navigates same-document targeting a same-origin window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-expected.txt index 9583311a7095..4fa74d898cb2 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT using location.href to navigate same-document targeting a cross-origin window Test timed out +FAIL using location.href to navigate same-document targeting a cross-origin window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub-expected.txt index bad530b78d4a..1186588281aa 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-crossorigin-sameorigindomain.sub-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT using location.href to navigate same-document targeting a same-origin-domain (but cross-origin) window Test timed out +FAIL using location.href to navigate same-document targeting a same-origin-domain (but cross-origin) window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin-expected.txt index 2dff556f374e..e85d464a97c4 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/location-samedocument-sameorigin-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT using location.href to navigate same-document targeting a same-origin window Test timed out +FAIL using location.href to navigate same-document targeting a same-origin window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-expected.txt index 60b2c506f1ae..5982b5ef2139 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT using window.open() to navigate same-document targeting a cross-origin window Test timed out +FAIL using window.open() to navigate same-document targeting a cross-origin window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub-expected.txt index b5e83755fb5c..dbe2b01d6f6f 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-crossorigin-sameorigindomain.sub-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT using window.open() to navigate same-document targeting a same-origin-domain (but cross-origin) window Test timed out +FAIL using window.open() to navigate same-document targeting a same-origin-domain (but cross-origin) window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin-expected.txt index 553fc4eab82a..cb8db3ca8d06 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/open-samedocument-sameorigin-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT using window.open() to navigate same-document targeting a same-origin window Test timed out +FAIL using window.open() to navigate same-document targeting a same-origin window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-expected.txt index 0b29506f4842..fafb8c1af4a0 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT submitting a
element that navigates same-document targeting a cross-origin window Test timed out +FAIL submitting a element that navigates same-document targeting a cross-origin window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-sameorigindomain.sub-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-sameorigindomain.sub-expected.txt index 11a57633190e..6d03f75022ab 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-sameorigindomain.sub-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-crossorigin-sameorigindomain.sub-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT submitting a element that navigates cross-document targeting a same-origin-domain (but cross-origin) window Test timed out +FAIL submitting a element that navigates cross-document targeting a same-origin-domain (but cross-origin) window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-sameorigin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-sameorigin-expected.txt index 28829b5180cb..b8f924f36ccf 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-sameorigin-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/cross-window/submit-samedocument-sameorigin-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT submitting a element that navigates same-document targeting a same-origin window Test timed out +FAIL submitting a element that navigates same-document targeting a same-origin window assert_true: destination.sameDocument expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-after-dispatch-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-after-dispatch-expected.txt index 2aa59a57e6bf..322e6550ea78 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-after-dispatch-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-after-dispatch-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT event.intercept() throws if used after the dispatch phase Test timed out +PASS event.intercept() throws if used after the dispatch phase diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-canceled-event-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-canceled-event-expected.txt index 67f81aefa60f..aa61d533faac 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-canceled-event-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-canceled-event-expected.txt @@ -1,4 +1,4 @@ -FAIL event.intercept() throws if used on a canceled event assert_true: expected true got false +PASS event.intercept() throws if used on a canceled event diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-handler-null-or-undefined-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-handler-null-or-undefined-expected.txt index c1db1a712644..1cff81f8aaf9 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-handler-null-or-undefined-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/intercept-handler-null-or-undefined-expected.txt @@ -1,6 +1,6 @@ Harness Error (TIMEOUT), message = null -TIMEOUT event.intercept() should throw if the handler is null Test timed out +PASS event.intercept() should throw if the handler is null TIMEOUT event.intercept() should not throw if the handler is explicit undefined Test timed out diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-fragment-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-fragment-expected.txt index 694bbbc9640b..5f692a7bd664 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-fragment-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-fragment-expected.txt @@ -1,5 +1,3 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT Fragment click fires navigate event Test timed out +FAIL Fragment click fires navigate event assert_true: expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-userInitiated-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-userInitiated-expected.txt index 54cf3bbe1fb9..e4ccb68b4760 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-userInitiated-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-userInitiated-expected.txt @@ -1,6 +1,4 @@ Click me -Harness Error (TIMEOUT), message = null - -TIMEOUT Fragment click fires navigate event Test timed out +FAIL Fragment click fires navigate event assert_true: expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-destination-getState-back-forward-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-destination-getState-back-forward-expected.txt index 9e87de561340..2452059c6ec7 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-destination-getState-back-forward-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-destination-getState-back-forward-expected.txt @@ -1,3 +1,3 @@ -PASS navigate event destination.getState() on back/forward navigation +FAIL navigate event destination.getState() on back/forward navigation assert_equals: expected "traverse" but got "push" diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-expected.txt index a689ae11210c..d24f12ca5081 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-expected.txt @@ -1,3 +1,3 @@ -FAIL: Timed out waiting for notifyDone to be called -{"error": {"code": 404, "message": ""}} +FAIL submission fires navigate event assert_equals: expected "replace" but got "push" + diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-get-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-get-expected.txt index 7cfaf2207f7e..76e563733ae2 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-get-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-get-expected.txt @@ -1,3 +1,3 @@ -FAIL: Timed out waiting for notifyDone to be called +FAIL submission with GET method fires navigate event but with formData null assert_equals: expected "replace" but got "push" diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-userInitiated-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-userInitiated-expected.txt index a689ae11210c..fa16b12c900f 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-userInitiated-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-form-userInitiated-expected.txt @@ -1,3 +1,4 @@ -FAIL: Timed out waiting for notifyDone to be called -{"error": {"code": 404, "message": ""}} + +FAIL submission fires navigate event assert_true: expected true got false + diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-back-after-fragment-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-back-after-fragment-expected.txt index 1460f4f896e6..c4eea7abdf23 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-back-after-fragment-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-back-after-fragment-expected.txt @@ -1,3 +1,3 @@ -FAIL history.back() fires the navigate event and sets hashChange when reversing a fragment navigation null is not an object (evaluating 'navigation.currentEntry.index') +FAIL history.back() fires the navigate event and sets hashChange when reversing a fragment navigation assert_equals: expected "traverse" but got "push" diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-go-0-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-go-0-expected.txt index 00139ebfd006..8ad60535fe96 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-go-0-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-history-go-0-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT history.go(0) fires the navigate event Test timed out +FAIL history.go(0) fires the navigate event assert_equals: expected "reload" but got "push" diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-iframe-location-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-iframe-location-expected.txt index 32f788951ef5..256e0b20eb6c 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-iframe-location-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-iframe-location-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT location API on another window fires navigate event in the target window only Test timed out +FAIL location API on another window fires navigate event in the target window only assert_true: expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-location-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-location-expected.txt index 35d5c3272a41..6bf396275912 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-location-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-location-expected.txt @@ -1,5 +1,3 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT location API fires navigate event Test timed out +FAIL location API fires navigate event assert_equals: expected "replace" but got "push" diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-meta-refresh-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-meta-refresh-expected.txt index 3da80d3d7d79..558fa844a611 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-meta-refresh-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-meta-refresh-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT refresh fires navigate event Test timed out +FAIL refresh fires navigate event assert_false: expected false got true diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-navigation-navigate-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-navigation-navigate-expected.txt index 09f64dc46e43..db1124fa593b 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-navigation-navigate-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-navigation-navigate-expected.txt @@ -1,5 +1,3 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT navigate event for navigation.navigate() Test timed out +FAIL navigate event for navigation.navigate() assert_equals: expected "replace" but got "push" diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-svg-anchor-fragment-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-svg-anchor-fragment-expected.txt index 09343677a8d4..e5fa8ebfad74 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-svg-anchor-fragment-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-svg-anchor-fragment-expected.txt @@ -1,5 +1,3 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT click fires navigate event Test timed out +FAIL click fires navigate event assert_true: expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-window-open-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-window-open-expected.txt index 507dd0ff07d8..1efc7b135450 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-window-open-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-window-open-expected.txt @@ -1,6 +1,4 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT window.open() fires navigate event in target window but not source Test timed out +FAIL window.open() fires navigate event in target window but not source assert_true: expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-window-open-self-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-window-open-self-expected.txt index 947c7bb52f24..3fcf666c8c1d 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-window-open-self-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-window-open-self-expected.txt @@ -1,5 +1,3 @@ -Harness Error (TIMEOUT), message = null - -TIMEOUT window.open() fires navigate event when targeting self Test timed out +FAIL window.open() fires navigate event when targeting self assert_true: expected true got false diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-history-push-not-loaded-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-history-push-not-loaded-expected.txt index 113d667c42bf..1243f4de4050 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-history-push-not-loaded-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-history-push-not-loaded-expected.txt @@ -1,3 +1,3 @@ -FAIL navigate() with history: 'push' in a document that has not yet had its load event promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'navigation.currentEntry.index')" +PASS navigate() with history: 'push' in a document that has not yet had its load event diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-same-document-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-same-document-expected.txt index 016ed3629334..40faa15f192f 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-same-document-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-same-document-expected.txt @@ -1,4 +1,4 @@ -FAIL navigate() navigates same-document and fires onnavigate (async) assert_equals: expected "#d" but got "" -FAIL navigate() navigates same-document and fires onnavigate (sync) assert_equals: expected "#d" but got "" +FAIL navigate() navigates same-document and fires onnavigate (async) assert_true: expected true got false +PASS navigate() navigates same-document and fires onnavigate (sync) diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-expected.txt index 8b73bd8c2a91..f9e393a7f7f7 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/return-value/navigate-expected.txt @@ -1,3 +1,3 @@ -FAIL navigate() promises assert_array_equals: lengths differ, expected array ["committed", "finished"] length 2, got ["todo"] length 1 +FAIL navigate() promises assert_equals: expected object "[object NavigationHistoryEntry]" but got object "[object NavigationHistoryEntry]" diff --git a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/scroll-behavior/manual-scroll-after-resolve-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/scroll-behavior/manual-scroll-after-resolve-expected.txt index 2e5521bd31b3..51c9db7b1f5c 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/navigation-api/scroll-behavior/manual-scroll-after-resolve-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/navigation-api/scroll-behavior/manual-scroll-after-resolve-expected.txt @@ -1,3 +1,3 @@ -FAIL scroll: scroll() should throw after a navigation finished promise fulfills assert_not_equals: got disallowed value 0 +FAIL scroll: scroll() should throw after a navigation finished promise fulfills assert_throws_dom: function "() => navigate_event.scroll()" threw object "TypeError: undefined is not an object (evaluating 'navigate_event.scroll')" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11 diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp index 504ef796ccbc..f25ee52b2d96 100644 --- a/Source/WebCore/loader/FrameLoader.cpp +++ b/Source/WebCore/loader/FrameLoader.cpp @@ -94,6 +94,7 @@ #include "MemoryRelease.h" #include "Navigation.h" #include "NavigationDisabler.h" +#include "NavigationNavigationType.h" #include "NavigationScheduler.h" #include "Node.h" #include "OriginAccessPatterns.h" @@ -1232,6 +1233,31 @@ void FrameLoader::setFirstPartyForCookies(const URL& url) } } +static NavigationNavigationType determineNavigationType(FrameLoadType frameLoadType, bool isNewNavigation) +{ + if (isNewNavigation) + return NavigationNavigationType::Push; + + switch (frameLoadType) { + case FrameLoadType::Standard: + return NavigationNavigationType::Push; + case FrameLoadType::Back: + case FrameLoadType::Forward: + case FrameLoadType::IndexedBackForward: + return NavigationNavigationType::Traverse; + case FrameLoadType::Reload: + case FrameLoadType::ReloadFromOrigin: + case FrameLoadType::ReloadExpiredOnly: + case FrameLoadType::Same: + return NavigationNavigationType::Reload; + case FrameLoadType::RedirectWithLockedBackForwardList: + case FrameLoadType::Replace: + return NavigationNavigationType::Replace; + }; + RELEASE_ASSERT_NOT_REACHED(); + return NavigationNavigationType::Push; +} + // This does the same kind of work that didOpenURL does, except it relies on the fact // that a higher level already checked that the URLs match and the scrolling is the right thing to do. void FrameLoader::loadInSameDocument(URL url, RefPtr stateObject, const SecurityOrigin* requesterOrigin, bool isNewNavigation) @@ -1275,8 +1301,19 @@ void FrameLoader::loadInSameDocument(URL url, RefPtr stat if (document->settings().navigationAPIEnabled() && !url.isAboutBlank()) { if (RefPtr domWindow = document->domWindow()) { - if (RefPtr currentItem = checkedHistory()->currentItem()) - domWindow->protectedNavigation()->updateForNavigation(currentItem.releaseNonNull(), policyChecker().loadType()); + auto navigationType = determineNavigationType(policyChecker().loadType(), isNewNavigation); + + // FIXME: This is likely not the ideal location for the navigate event and should happen earlier. + if (navigationType != NavigationNavigationType::Traverse) + domWindow->protectedNavigation()->dispatchPushReplaceReloadNavigateEvent(url, navigationType, equalIgnoringFragmentIdentifier(url, oldURL)); + + if (RefPtr currentItem = checkedHistory()->currentItem()) { + // FIXME: Properly handle result of navigate event. + if (navigationType == NavigationNavigationType::Traverse) + domWindow->protectedNavigation()->dispatchTraversalNavigateEvent(*currentItem); + + domWindow->protectedNavigation()->updateForNavigation(*currentItem, navigationType); + } } } diff --git a/Source/WebCore/page/NavigateEvent.cpp b/Source/WebCore/page/NavigateEvent.cpp index d60466e5a1c5..cdcc23c4ba2a 100644 --- a/Source/WebCore/page/NavigateEvent.cpp +++ b/Source/WebCore/page/NavigateEvent.cpp @@ -26,14 +26,16 @@ #include "config.h" #include "NavigateEvent.h" +#include "AbortController.h" +#include "ExceptionCode.h" #include namespace WebCore { WTF_MAKE_ISO_ALLOCATED_IMPL(NavigateEvent); -NavigateEvent::NavigateEvent(const AtomString& type, const NavigateEvent::Init& init) - : Event(EventInterfaceType::NavigateEvent, type, CanBubble::No, IsCancelable::No) +NavigateEvent::NavigateEvent(const AtomString& type, const NavigateEvent::Init& init, RefPtr abortController) + : Event(EventInterfaceType::NavigateEvent, type, init, Event::IsTrusted::Yes) , m_navigationType(init.navigationType) , m_destination(init.destination) , m_signal(init.signal) @@ -44,20 +46,91 @@ NavigateEvent::NavigateEvent(const AtomString& type, const NavigateEvent::Init& , m_userInitiated(init.userInitiated) , m_hashChange(init.hashChange) , m_hasUAVisualTransition(init.hasUAVisualTransition) + , m_abortController(abortController) { } +Ref NavigateEvent::create(const AtomString& type, const NavigateEvent::Init& init, RefPtr abortController) +{ + return adoptRef(*new NavigateEvent(type, init, abortController)); +} + Ref NavigateEvent::create(const AtomString& type, const NavigateEvent::Init& init) { - return adoptRef(*new NavigateEvent(type, init)); + // FIXME: AbortController is required but JS bindings need to create it with one. + return adoptRef(*new NavigateEvent(type, init, nullptr)); +} + +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigateevent-perform-shared-checks +ExceptionOr NavigateEvent::sharedChecks() +{ + if (!isTrusted()) + return Exception { ExceptionCode::SecurityError, "Event is not trusted"_s }; + + if (defaultPrevented()) + return Exception { ExceptionCode::InvalidStateError, "Event was already canceled"_s }; + + return { }; +} + +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigateevent-intercept +ExceptionOr NavigateEvent::intercept(NavigationInterceptOptions&& options) +{ + if (auto checkResult = sharedChecks(); checkResult.hasException()) + return checkResult; + + if (!canIntercept()) + return Exception { ExceptionCode::SecurityError, "Event is not interceptable"_s }; + + if (!isBeingDispatched()) + return Exception { ExceptionCode::InvalidStateError, "Event is not being dispatched"_s }; + + ASSERT(!m_interceptionState || m_interceptionState == InterceptionState::Intercepted); + + if (options.handler) + m_handlers.append(WTFMove(options.handler)); + + if (options.focusReset) { + // FIXME: Print warning to console if it was already set. + m_focusReset = options.focusReset; + } + + if (options.scroll) { + // FIXME: Print warning to console if it was already set. + m_scrollBehavior = options.scroll; + } + + m_interceptionState = InterceptionState::Intercepted; + + return { }; } -void NavigateEvent::intercept(NavigationInterceptOptions&&) +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigateevent-scroll +ExceptionOr NavigateEvent::scroll() { + auto checkResult = sharedChecks(); + if (checkResult.hasException()) + return checkResult; + + if (m_interceptionState != InterceptionState::Committed) + return Exception { ExceptionCode::InvalidStateError, "Interception has not been committed"_s }; + + // FIXME: Scroll document: https://html.spec.whatwg.org/multipage/nav-history-apis.html#process-scroll-behavior + + return { }; } -void NavigateEvent::scroll() +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigateevent-finish +void NavigateEvent::finish() { + ASSERT(m_interceptionState != InterceptionState::Intercepted && m_interceptionState != InterceptionState::Finished); + if (!m_interceptionState) + return; + + // FIXME: 3. Potentially reset the focus + // FIXME: 4. If didFulfill is true, then potentially process scroll behavior given event. + + m_interceptionState = InterceptionState::Finished; } } // namespace WebCore diff --git a/Source/WebCore/page/NavigateEvent.h b/Source/WebCore/page/NavigateEvent.h index 6439e0f99a14..a53fd1207b0b 100644 --- a/Source/WebCore/page/NavigateEvent.h +++ b/Source/WebCore/page/NavigateEvent.h @@ -25,6 +25,7 @@ #pragma once +#include "AbortController.h" #include "AbortSignal.h" #include "DOMFormData.h" #include "Event.h" @@ -36,6 +37,13 @@ namespace WebCore { +enum class InterceptionState : uint8_t { + Intercepted, + Committed, + Scrolled, + Finished, +}; + class NavigateEvent final : public Event { WTF_MAKE_ISO_ALLOCATED(NavigateEvent); public: @@ -64,39 +72,55 @@ class NavigateEvent final : public Event { struct NavigationInterceptOptions { RefPtr handler; - NavigationFocusReset focusReset; - NavigationScrollBehavior scroll; + std::optional focusReset; + std::optional scroll; }; static Ref create(const AtomString& type, const Init&); + static Ref create(const AtomString& type, const Init&, RefPtr); NavigationNavigationType navigationType() const { return m_navigationType; }; bool canIntercept() const { return m_canIntercept; }; bool userInitiated() const { return m_userInitiated; }; bool hashChange() const { return m_hashChange; }; bool hasUAVisualTransition() const { return m_hasUAVisualTransition; }; - RefPtr destination() { return m_destination; }; - RefPtr signal() { return m_signal; }; - RefPtr formData() { return m_formData; }; + NavigationDestination* destination() { return m_destination.get(); }; + AbortSignal* signal() { return m_signal.get(); }; + DOMFormData* formData() { return m_formData.get(); }; String downloadRequest() { return m_downloadRequest; }; JSC::JSValue info() { return m_info; }; - void intercept(NavigationInterceptOptions&&); - void scroll(); + ExceptionOr intercept(NavigationInterceptOptions&&); + ExceptionOr scroll(); + + bool wasIntercepted() const { return m_interceptionState.has_value(); }; + void setCanIntercept(bool canIntercept) { m_canIntercept = canIntercept; }; + void setInterceptionState(InterceptionState interceptionState) { m_interceptionState = interceptionState; }; + + void finish(); + + Vector> handlers() { return m_handlers; }; private: - NavigateEvent(const AtomString& type, const Init&); + NavigateEvent(const AtomString& type, const Init&, RefPtr); + + ExceptionOr sharedChecks(); NavigationNavigationType m_navigationType; RefPtr m_destination; RefPtr m_signal; RefPtr m_formData; String m_downloadRequest; + Vector> m_handlers; JSC::JSValue m_info; bool m_canIntercept { false }; bool m_userInitiated { false }; bool m_hashChange { false }; bool m_hasUAVisualTransition { false }; + std::optional m_interceptionState; + std::optional m_focusReset; + std::optional m_scrollBehavior; + RefPtr m_abortController; }; } // namespace WebCore diff --git a/Source/WebCore/page/NavigateEvent.idl b/Source/WebCore/page/NavigateEvent.idl index bcdc0eb50631..e1d812961265 100644 --- a/Source/WebCore/page/NavigateEvent.idl +++ b/Source/WebCore/page/NavigateEvent.idl @@ -13,7 +13,7 @@ readonly attribute DOMFormData? formData; readonly attribute DOMString? downloadRequest; readonly attribute any info; - readonly attribute boolean hasUAVisualTransition; + [EnabledBySetting=UAVisualTransitionDetectionEnabled] readonly attribute boolean hasUAVisualTransition; undefined intercept(optional NavigationInterceptOptions options = {}); undefined scroll(); @@ -29,7 +29,7 @@ dictionary NavigateEventInit : EventInit { DOMFormData? formData = null; DOMString? downloadRequest = null; any info; - boolean hasUAVisualTransition = false; + [EnabledBySetting=UAVisualTransitionDetectionEnabled] boolean hasUAVisualTransition = false; }; dictionary NavigationInterceptOptions { diff --git a/Source/WebCore/page/Navigation.cpp b/Source/WebCore/page/Navigation.cpp index fcbd19eb5370..0f4e2c694fb2 100644 --- a/Source/WebCore/page/Navigation.cpp +++ b/Source/WebCore/page/Navigation.cpp @@ -26,15 +26,23 @@ #include "config.h" #include "Navigation.h" +#include "AbortController.h" #include "EventNames.h" #include "Exception.h" #include "FrameLoadRequest.h" #include "FrameLoader.h" +#include "FrameLoaderTypes.h" #include "HistoryItem.h" +#include "JSDOMPromise.h" #include "JSNavigationHistoryEntry.h" #include "MessagePort.h" +#include "NavigateEvent.h" #include "NavigationCurrentEntryChangeEvent.h" +#include "NavigationDestination.h" +#include "NavigationHistoryEntry.h" +#include "NavigationNavigationType.h" #include "ScriptExecutionContext.h" +#include "SecurityOrigin.h" #include "SerializedScriptValue.h" #include #include @@ -298,7 +306,7 @@ ExceptionOr Navigation::updateCurrentEntry(UpdateCurrentEntryOptions&& opt if (!window()->frame() || !window()->frame()->document()) return Exception { ExceptionCode::InvalidStateError }; - auto current = currentEntry(); + RefPtr current = currentEntry(); if (!current) return Exception { ExceptionCode::InvalidStateError }; @@ -308,7 +316,7 @@ ExceptionOr Navigation::updateCurrentEntry(UpdateCurrentEntryOptions&& opt current->setState(WTFMove(serializedState)); - auto currentEntryChangeEvent = NavigationCurrentEntryChangeEvent::create({ "currententrychange"_s }, { + auto currentEntryChangeEvent = NavigationCurrentEntryChangeEvent::create(eventNames().currententrychangeEvent, { { false, false, false }, std::nullopt, current @@ -321,46 +329,24 @@ ExceptionOr Navigation::updateCurrentEntry(UpdateCurrentEntryOptions&& opt // https://html.spec.whatwg.org/multipage/nav-history-apis.html#has-entries-and-events-disabled bool Navigation::hasEntriesAndEventsDisabled() const { + if (!window()->document() || !window()->document()->isFullyActive()) + return true; if (window()->securityOrigin() && window()->securityOrigin()->isOpaque()) return true; return false; } -static NavigationNavigationType determineNavigationType(FrameLoadType frameLoadType) -{ - switch (frameLoadType) { - case FrameLoadType::Standard: - return NavigationNavigationType::Push; - case FrameLoadType::Back: - case FrameLoadType::Forward: - case FrameLoadType::IndexedBackForward: - return NavigationNavigationType::Traverse; - case FrameLoadType::Reload: - case FrameLoadType::ReloadFromOrigin: - case FrameLoadType::ReloadExpiredOnly: - case FrameLoadType::Same: - return NavigationNavigationType::Reload; - case FrameLoadType::RedirectWithLockedBackForwardList: - case FrameLoadType::Replace: - return NavigationNavigationType::Replace; - }; - RELEASE_ASSERT_NOT_REACHED(); - return NavigationNavigationType::Push; -} - // https://html.spec.whatwg.org/multipage/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation -void Navigation::updateForNavigation(Ref&& item, FrameLoadType frameLoadType) +void Navigation::updateForNavigation(Ref&& item, NavigationNavigationType navigationType) { if (hasEntriesAndEventsDisabled()) return; - auto oldCurrentEntry = currentEntry(); + RefPtr oldCurrentEntry = currentEntry(); ASSERT(oldCurrentEntry); Vector> disposedEntries; - auto navigationType = determineNavigationType(frameLoadType); - // FIXME: handle NavigationNavigationType::Traverse if (navigationType == NavigationNavigationType::Push) { m_currentEntryIndex = *m_currentEntryIndex + 1; @@ -375,7 +361,7 @@ void Navigation::updateForNavigation(Ref&& item, FrameLoadType fram // FIXME: implement Step 8 Handle API method tracker. - auto currentEntryChangeEvent = NavigationCurrentEntryChangeEvent::create({ "currententrychange"_s }, { + auto currentEntryChangeEvent = NavigationCurrentEntryChangeEvent::create(eventNames().currententrychangeEvent, { { false, false, false }, navigationType, oldCurrentEntry }); dispatchEvent(currentEntryChangeEvent); @@ -384,4 +370,158 @@ void Navigation::updateForNavigation(Ref&& item, FrameLoadType fram disposedEntry->dispatchEvent(Event::create(eventNames().disposeEvent, { })); } +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#can-have-its-url-rewritten +static bool documentCanHaveURLRewritten(const RefPtr& document, const URL& targetURL) +{ + const URL& documentURL = document->url(); + auto& documentOrigin = document->securityOrigin(); + auto targetOrigin = SecurityOrigin::create(targetURL); + + if (!documentOrigin.isSameSiteAs(targetOrigin)) + return false; + + if (targetURL.protocolIsInHTTPFamily()) + return true; + + if (targetURL.protocolIsFile() && !isEqualIgnoringQueryAndFragments(documentURL, targetURL)) + return false; + + return equalIgnoringFragmentIdentifier(documentURL, targetURL); +} + +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#inner-navigate-event-firing-algorithm +bool Navigation::innerDispatchNavigateEvent(NavigationNavigationType navigationType, Ref&& destination, const String& downloadRequestFilename) +{ + // FIXME: pass in formDataEntryList + + if (hasEntriesAndEventsDisabled()) { + ASSERT(!m_ongoingAPIMethodTracker); + ASSERT(!m_upcomingNonTraverseMethodTracker); + ASSERT(m_upcomingTraverseMethodTrackers.isEmpty()); + return true; + } + + // FIXME: promoteUpcomingAPIMethodTracker(destination->key()); + + RefPtr document = window()->protectedDocument(); + + auto apiMethodTracker = m_ongoingAPIMethodTracker; + bool isSameDocument = destination->sameDocument(); + bool isTraversal = navigationType == NavigationNavigationType::Traverse; + bool canIntercept = documentCanHaveURLRewritten(document, destination->url()) && (!isTraversal || isSameDocument); + bool canBeCanceled = !isTraversal || (document->isTopDocument() && isSameDocument); // FIXME: and either userInvolvement is not "browser UI", or navigation's relevant global object has transient activation. + bool hashChange = equalIgnoringFragmentIdentifier(document->url(), destination->url()) && !equalRespectingNullity(document->url().fragmentIdentifier(), destination->url().fragmentIdentifier()); + auto info = apiMethodTracker ? apiMethodTracker->info : JSC::jsUndefined(); + + RefPtr abortController = AbortController::create(*scriptExecutionContext()); + + auto init = NavigateEvent::Init { + { false, canBeCanceled, false }, + navigationType, + destination.ptr(), + abortController->protectedSignal(), + nullptr, // FIXME: formData + downloadRequestFilename, + info, + canIntercept, + false, // FIXME: userInitiated + hashChange, + false, // FIXME: hasUAVisualTransition + }; + + // Free up no longer needed info. + if (apiMethodTracker) + apiMethodTracker->info = JSC::jsUndefined(); + + Ref event = NavigateEvent::create(eventNames().navigateEvent, init, abortController); + m_ongoingNavigateEvent = event.ptr(); + m_focusChangedDuringOnoingNavigation = false; + m_suppressNormalScrollRestorationDuringOngoingNavigation = false; + + dispatchEvent(event); + + if (event->defaultPrevented()) { + // FIXME: If navigationType is "traverse", then consume history-action user activation. + // FIXME: If event's abort controller's signal is not aborted, then abort the ongoing navigation given navigation. + m_ongoingNavigateEvent = nullptr; + return false; + } + + bool endResultIsSameDocument = event->wasIntercepted() || destination->sameDocument(); + + // FIXME: Prepare to run script given navigation's relevant settings object. + + // Step 32: + if (event->wasIntercepted()) { + event->setInterceptionState(InterceptionState::Committed); + + RefPtr fromNavigationHistoryEntry = currentEntry(); + ASSERT(fromNavigationHistoryEntry); + + // FIXME: Create finished promise + m_transition = NavigationTransition::create(navigationType, *fromNavigationHistoryEntry); + + if (navigationType == NavigationNavigationType::Traverse) + m_suppressNormalScrollRestorationDuringOngoingNavigation = true; + + // FIXME: Step 7: URL and history update + } + + if (endResultIsSameDocument) { + // FIXME: Step 33: Wait on Handler promises + + if (document->isFullyActive() && !abortController->signal().aborted()) { + ASSERT(m_ongoingNavigateEvent == event.ptr()); + m_ongoingNavigateEvent = nullptr; + + event->finish(); + + // FIXME: 6. Fire an event named navigatesuccess at navigation. + // FIXME: 7. If navigation's transition is not null, then resolve navigation's transition's finished promise with undefined. + m_transition = nullptr; + + // FIXME: if (apiMethodTracker) + // resolveFinishedPromise(*apiMethodTracker); + } + + // FIXME: and the following failure steps given reason rejectionReason: + m_ongoingNavigateEvent = nullptr; + } + + // FIXME: if (apiMethodTracker) + // cleanupAPIMethodTracker(*apiMethodTracker); + + // FIXME: Step 35 Clean up after running script + + return !event->wasIntercepted(); +} + +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#fire-a-traverse-navigate-event +bool Navigation::dispatchTraversalNavigateEvent(Ref historyItem) +{ + // FIME: isCurrentDocument may not match spec + bool isSameDocument = historyItem->isCurrentDocument(*window()->protectedDocument()); + // FIXME: Set destinations state + // FIXME: Get Entry for historyItem + Ref destination = NavigationDestination::create(historyItem->url(), currentEntry(), isSameDocument); + + return innerDispatchNavigateEvent(NavigationNavigationType::Traverse, WTFMove(destination), { }); +} + +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#fire-a-push/replace/reload-navigate-event +bool Navigation::dispatchPushReplaceReloadNavigateEvent(const URL& url, NavigationNavigationType navigationType, bool isSameDocument) +{ + // FIXME: Set event's classic history API state to classicHistoryAPIState. + Ref destination = NavigationDestination::create(url, nullptr, isSameDocument); + return innerDispatchNavigateEvent(navigationType, WTFMove(destination), { }); +} + +// https://html.spec.whatwg.org/multipage/nav-history-apis.html#fire-a-download-request-navigate-event +bool Navigation::dispatchDownloadNavigateEvent(const URL&, const String& downloadFilename) +{ + // FIXME + UNUSED_PARAM(downloadFilename); + return false; +} + } // namespace WebCore diff --git a/Source/WebCore/page/Navigation.h b/Source/WebCore/page/Navigation.h index 51dc91c66a7d..d2de21defd02 100644 --- a/Source/WebCore/page/Navigation.h +++ b/Source/WebCore/page/Navigation.h @@ -30,6 +30,7 @@ #include "JSDOMPromiseDeferred.h" #include "LocalDOMWindowProperty.h" #include "NavigationHistoryEntry.h" +#include "NavigationNavigationType.h" #include "NavigationTransition.h" #include #include @@ -38,6 +39,8 @@ namespace WebCore { class HistoryItem; class SerializedScriptValue; +class NavigateEvent; +class NavigationDestination; enum class FrameLoadType : uint8_t; @@ -109,7 +112,7 @@ class Navigation final : public RefCounted, public EventTarget, publ const Vector>& entries() const; NavigationHistoryEntry* currentEntry() const; - RefPtr transition() { return m_transition; }; + NavigationTransition* transition() { return m_transition.get(); }; bool canGoBack() const; bool canGoForward() const; @@ -126,7 +129,11 @@ class Navigation final : public RefCounted, public EventTarget, publ ExceptionOr updateCurrentEntry(UpdateCurrentEntryOptions&&); - void updateForNavigation(Ref&&, FrameLoadType); + bool dispatchTraversalNavigateEvent(Ref); + bool dispatchPushReplaceReloadNavigateEvent(const URL&, NavigationNavigationType, bool isSameDocument); + bool dispatchDownloadNavigateEvent(const URL&, const String& downloadFilename); + + void updateForNavigation(Ref&&, NavigationNavigationType); private: explicit Navigation(LocalDOMWindow&); @@ -142,12 +149,17 @@ class Navigation final : public RefCounted, public EventTarget, publ std::optional> findEntryByKey(const String& key); ExceptionOr> serializeState(JSC::JSValue state); NavigationAPIMethodTracker maybeSetUpcomingNonTraversalTracker(Ref&& committed, Ref&& finished, JSC::JSValue info, RefPtr&&); + bool innerDispatchNavigateEvent(NavigationNavigationType, Ref&&, const String& downloadRequestFilename); std::optional m_currentEntryIndex; RefPtr m_transition; Vector> m_entries; + RefPtr m_ongoingNavigateEvent; + bool m_focusChangedDuringOnoingNavigation { false }; + bool m_suppressNormalScrollRestorationDuringOngoingNavigation { false }; + std::optional m_ongoingAPIMethodTracker; std::optional m_upcomingNonTraverseMethodTracker; HashMap m_upcomingTraverseMethodTrackers; }; diff --git a/Source/WebCore/page/NavigationTransition.h b/Source/WebCore/page/NavigationTransition.h index e83deba41531..0ce24cd97664 100644 --- a/Source/WebCore/page/NavigationTransition.h +++ b/Source/WebCore/page/NavigationTransition.h @@ -25,6 +25,7 @@ #pragma once +#include "JSDOMPromise.h" #include "NavigationHistoryEntry.h" #include "NavigationNavigationType.h" #include "ScriptWrappable.h"