[wpt-sync] Sync PR 37460 - Allow the navigate event to cancel same-document main-frame traversals
Categories
(Testing :: web-platform-tests, task, P4)
Tracking
(firefox112 fixed)
Tracking | Status | |
---|---|---|
firefox112 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 37460 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/37460
Details from upstream follow.
Nate Chapin <japhet@chromium.org> wrote:
Allow the navigate event to cancel same-document main-frame traversals
Currently, the navigate event is allowed to cancel push/replace/reload
navigations, but not traversals. There are two reasons for this:
chromium's architecture made it difficult to support cancelation
without getting out of sync with the authoratative version of the
joint session history in the browser process, and we were
concerned about the possibility of trapping the user if canceling
a traversal was too easy.The case where we might get out of sync is when multiple frames
navigate as part of a traversal. We want to avoid the case where
some frames cancel the navigation in their frame, but others allow
it to proceed (since giving every frame what it requested would
cause some frames to be out of sync with the browser process). Therefore, only the main frame is allowed to cancel the navigation
via the navigate event. In order to ensure the main frame is able to
cancel the entire traversal, we send the main frame navigation (if any)
to the renderer first and wait for its commit to complete before
proceeding with any subframe navigations.The main frame is only allowed to cancel a traversal when it is
traversing same-document. We had originally planned on allowing
cross-document traverals to be cancelled, too
(https://chromium-review.googlesource.com/c/chromium/src/+/3868615),
but this proved to have unacceptable performance characteristics,
requiring roundtrips to the renderer whenever a navigate event
handler was present, even if the navigate event handler had no
intention of ever cancelling a traversal.Therefore the sequence during a traversal is now:
- Calculate which frames to navigate
- If the main frame needs to do a same-document navigation, then:
2a. Start the navigation for the main frame only. The navigation
commit message will be sent to the renderer, and the navigate
event will fire. If it cancels the navigation, this will be
reported back to the browser as an Aborted commit.
2b. If it cancels, abort the entire traversal.- Start navigating all navigating subframes. These navigations will
all fire a navigate event just before committing, but none of
those events will be cancealable.As for preventing trapping the user, we only allow canceling the
navigation in the main frame if the navigating is programmatic, or
if there is a consumable user activation. This ensures that, e.g.,
pressing the back button once mighted be canceled by the navigate
event, but the second back button press is guaranteed to go through.
Traversals via the navigation API or the legacy history API will
always be cancelable because they are programmatic.Bug: 1371580
Change-Id: I0c8c39bec8e21f3ca86389a4343881ebe2bde43eReviewed-on: https://chromium-review.googlesource.com/4092862
WPT-Export-Revision: 49e074df7be4c13221aae2446fdba80d4231802e
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 1•2 years ago
|
||
Assignee | ||
Comment 2•2 years ago
|
||
CI Results
Ran 9 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI
Total 12 tests and 1 subtests
Status Summary
Firefox
OK
: 12
FAIL
: 12
Chrome
OK
: 12
PASS
: 4
FAIL
: 8
Safari
OK
: 12
FAIL
: 12
Links
Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base
Details
New Tests That Don't Pass
- /navigation-api/navigate-event/navigate-history-back-after-fragment.html [wpt.fyi]
- history.back() fires the navigate event and sets hashChange when reversing a fragment navigation:
FAIL
(Chrome:FAIL
, Safari:FAIL
)
- history.back() fires the navigate event and sets hashChange when reversing a fragment navigation:
- /navigation-api/navigate-event/navigate-history-back-after-pushState.html [wpt.fyi]
- history.back() fires the navigate event when reversing a pushState():
FAIL
(Chrome:FAIL
, Safari:FAIL
)
- history.back() fires the navigate event when reversing a pushState():
- /navigation-api/navigate-event/navigate-navigation-back-cross-document.html [wpt.fyi]
- navigate event for navigation.back() - cross-document:
FAIL
(Chrome:PASS
, Safari:FAIL
)
- navigate event for navigation.back() - cross-document:
- /navigation-api/navigate-event/navigate-navigation-back-same-document-in-iframe.html [wpt.fyi]
- navigate event for navigation.back() - same-document in an iframe:
FAIL
(Chrome:PASS
, Safari:FAIL
)
- navigate event for navigation.back() - same-document in an iframe:
- /navigation-api/navigate-event/navigate-navigation-back-same-document.html [wpt.fyi]
- navigate event for navigation.back() - same-document:
FAIL
(Chrome:FAIL
, Safari:FAIL
)
- navigate event for navigation.back() - same-document:
- /navigation-api/navigate-event/navigation-back-cross-document-preventDefault.html [wpt.fyi]
- navigation.back() cross-document cannot be cancelled with the navigate event:
FAIL
(Chrome:PASS
, Safari:FAIL
)
- navigation.back() cross-document cannot be cancelled with the navigate event:
- /navigation-api/navigate-event/navigation-back-same-document-preventDefault.html [wpt.fyi]
- navigation.back() same-document preventDefault:
FAIL
(Chrome:FAIL
, Safari:FAIL
)
- navigation.back() same-document preventDefault:
- /navigation-api/navigate-event/navigation-traverseTo-in-iframe-same-document-preventDefault.html [wpt.fyi]
- navigation.traverseTo() in an iframe with same-document preventDefault in its parent:
FAIL
(Chrome:FAIL
, Safari:FAIL
)
- navigation.traverseTo() in an iframe with same-document preventDefault in its parent:
- /navigation-api/navigate-event/navigation-traverseTo-navigates-top-and-same-doc-child-and-cross-doc-child.html [wpt.fyi]
- navigation.traverseTo() can navigate 3 frames of different types with correct navigate event cancelable values:
FAIL
(Chrome:FAIL
, Safari:FAIL
)
- navigation.traverseTo() can navigate 3 frames of different types with correct navigate event cancelable values:
- /navigation-api/navigate-event/navigation-traverseTo-same-document-preventDefault-multiple-windows.html [wpt.fyi]
- navigation.traverseTo() - if a top window cancels the traversal, any iframes should not fire navigate:
FAIL
(Chrome:FAIL
, Safari:FAIL
)
- navigation.traverseTo() - if a top window cancels the traversal, any iframes should not fire navigate:
- /navigation-api/navigate-event/navigation-traverseTo-top-cancels-cross-document-child.html [wpt.fyi]
- navigate.traverseTo() cancelled by top frame cancels cross-document iframe:
FAIL
(Chrome:FAIL
, Safari:FAIL
)
- navigate.traverseTo() cancelled by top frame cancels cross-document iframe:
- /navigation-api/navigation-methods/traverseTo-detach-between-navigate-and-navigatesuccess.html [wpt.fyi]
- Detach a window between when a traverseTo() fires navigate and navigatesuccess:
FAIL
(Chrome:PASS
, Safari:FAIL
)
- Detach a window between when a traverseTo() fires navigate and navigatesuccess:
Assignee | ||
Updated•2 years ago
|
Comment 5•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/36c7fc464f50
https://hg.mozilla.org/mozilla-central/rev/1f84b5606c0b
Description
•