Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent WindowClient.navigate() from cancelling a browser-initiated n…
…avigation. Otherwise, a service worker can prevent you from navigating where you want to go via the omnibox. Note: this is similar to WebContentsImpl::OnGoToEntryAtOffset() for renderer-initiated history navigations. Bug: 930154 Change-Id: I3a687ccc8ba4420d2369adb24f63c2702bdeeff1 Reviewed-on: https://chromium-review.googlesource.com/c/1477454 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org> Auto-Submit: Matt Falkenhagen <falken@chromium.org> Cr-Commit-Position: refs/heads/master@{#633231}
- Loading branch information
Showing
4 changed files
with
67 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Request navigate</title> | ||
<script> | ||
// Asks the service worker to call WindowClient.navigate() on us. It will | ||
// message back the result if it failed, or else we navigate away. | ||
async function requestToNavigate() { | ||
const sawMessage = new Promise((resolve) => { | ||
navigator.serviceWorker.onmessage = (event) => { | ||
resolve(event.data); | ||
}; | ||
}); | ||
const registration = await navigator.serviceWorker.ready; | ||
registration.active.postMessage({command: 'navigate', url: 'empty.html'}); | ||
return await sawMessage; | ||
} | ||
</script> |