-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update AppHistory navigate event behavior for traversals
Follows WICG/navigation-api#178 * Always fire navigate event for traversals (currently, we fire it for all same-document traversals and for cross-document appHistory.goTo(), but not cross-document traversals from the legacy history API, or from the UI). * The AppHistory navigate event should never be cancelable for traversals. Previously, it was cancelable for renderer-initiated traversals, but this has the potential to cause problems in the case where multiple frames are navigating and one frame (but not all) cancels. That frame would be out of sync with the authoritative history state in the browser process. Change-Id: I92a3ee0f908acc04c31dc9b8ec57569bd66b4bc7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3255177 Reviewed-by: Domenic Denicola <domenic@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/main@{#937981} NOKEYCHECK=True GitOrigin-RevId: 87021c0d80a703df61dd68a34eec72c1517b9c17
- Loading branch information
1 parent
07aa982
commit d8518a9
Showing
10 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...b_tests/external/wpt/app-history/navigate-event/navigate-history-back-cross-document.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
async_test(t => { | ||
window.onload = t.step_func(() => { | ||
let target_key = i.contentWindow.appHistory.current.key; | ||
let target_id = i.contentWindow.appHistory.current.id; | ||
i.contentWindow.appHistory.navigate("?foo"); | ||
i.onload = t.step_func(() => { | ||
i.contentWindow.appHistory.onnavigate = t.step_func_done(e => { | ||
assert_equals(e.navigationType, "traverse"); | ||
assert_false(e.cancelable); | ||
assert_false(e.canTransition); | ||
assert_false(e.userInitiated); | ||
assert_false(e.hashChange); | ||
assert_equals(new URL(e.destination.url).pathname, "/common/blank.html"); | ||
assert_false(e.destination.sameDocument); | ||
assert_equals(e.destination.key, target_key); | ||
assert_equals(e.destination.id, target_id); | ||
assert_equals(e.destination.index, 0); | ||
assert_equals(e.formData, null); | ||
assert_equals(e.info, undefined); | ||
}); | ||
assert_true(i.contentWindow.appHistory.canGoBack); | ||
i.contentWindow.history.back(); | ||
}) | ||
}); | ||
}, "navigate event for history.back() - cross-document"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...k/web_tests/http/tests/misc/appHistory-navigate-event-browser-initiated-back-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PASS if no errors are reported. |
38 changes: 38 additions & 0 deletions
38
blink/web_tests/http/tests/misc/appHistory-navigate-event-browser-initiated-back.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!doctype html> | ||
PASS if no errors are reported. | ||
<iframe id="i" src="resources/success.html"></iframe> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.queueLoadingScript("i.contentWindow.appHistory.navigate('about:blank');"); | ||
testRunner.queueBackNavigation(1); | ||
} | ||
|
||
function assert_equals(actual, expected) { | ||
if (!Object.is(actual, expected)) | ||
throw Error(message + ': expected: ' + expected + ', actual: ' + actual); | ||
} | ||
function assert_true(expected) { assert_equals(true, expected); } | ||
function assert_false(expected) { assert_equals(false, expected); } | ||
|
||
i.onload = () => { | ||
let target_key = i.contentWindow.appHistory.current.key; | ||
let target_id = i.contentWindow.appHistory.current.id; | ||
i.onload = () => { | ||
i.contentWindow.appHistory.onnavigate = e => { | ||
assert_equals(e.navigationType, "traverse"); | ||
assert_false(e.cancelable); | ||
assert_false(e.canTransition); | ||
assert_true(e.userInitiated); | ||
assert_false(e.hashChange); | ||
assert_equals(new URL(e.destination.url).pathname, "/misc/resources/success.html"); | ||
assert_false(e.destination.sameDocument); | ||
assert_equals(e.destination.key, target_key); | ||
assert_equals(e.destination.id, target_id); | ||
assert_equals(e.destination.index, 0); | ||
assert_equals(e.formData, null); | ||
assert_equals(e.info, undefined); | ||
}; | ||
}; | ||
}; | ||
</script> |