Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
navigation.navigate(url, { history: "push" }); should actually force …
…push Currently, { history: "push" } is actually push-or-fail: if the navigation would've been a push, it pushes. If it would've been a replace, the navigation fails immediately. This CL makes { history: "push" } actually override some cases where we would implicitly convert a push navigation to a replace: navigations before onload completes, and navigation to the current url. Change-Id: I0b985a4c9563c6000f7ee44153394466cc4bcb50 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4175895 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Owners-Override: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/main@{#1099590}
- Loading branch information
1 parent
d80a211
commit 3a5a9af
Showing
4 changed files
with
59 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
25 changes: 25 additions & 0 deletions
25
navigation-api/navigation-methods/navigate-history-push-same-url-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,25 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/helpers.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async t => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation due to onload not having completed. | ||
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); | ||
assert_equals(i.contentWindow.navigation.entries().length, 1); | ||
|
||
i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess should not be called"); | ||
i.contentWindow.navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called"); | ||
|
||
let navigateEventType; | ||
i.contentWindow.navigation.onnavigate = e => navigateEventType = e.navigationType; | ||
|
||
i.contentWindow.navigation.navigate(i.contentWindow.location, { history: "push" }); | ||
await new Promise(resolve => i.onload = resolve); | ||
assert_equals(navigateEventType, "push"); | ||
assert_equals(i.contentWindow.navigation.entries().length, 2); | ||
assert_equals(i.contentWindow.navigation.currentEntry.index, 1); | ||
}, "navigate() to the current URL with history: 'push' and allow it to go cross document"); | ||
</script> |
26 changes: 26 additions & 0 deletions
26
navigation-api/navigation-methods/navigate-history-push-same-url.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,26 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/helpers.js"></script> | ||
|
||
<script> | ||
promise_test(async t => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation due to onload not having completed. | ||
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0)); | ||
assert_equals(navigation.entries().length, 1); | ||
|
||
|
||
let navigateEventType; | ||
navigation.onnavigate = e => { | ||
navigateEventType = e.navigationType; | ||
e.intercept(); | ||
} | ||
navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called"); | ||
|
||
await navigation.navigate(location.href, { history: "push" }).finished; | ||
assert_equals(navigateEventType, "push"); | ||
assert_equals(navigation.entries().length, 2); | ||
assert_equals(navigation.currentEntry.index, 1); | ||
}, "navigate() to the current URL with history: 'push' and intercept so it remains same-document"); | ||
</script> |
19 changes: 0 additions & 19 deletions
19
navigation-api/navigation-methods/return-value/navigate-push-same-url.html
This file was deleted.
Oops, something went wrong.