Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: emit will-navigate for links in chrome: pages #40390

Merged
merged 3 commits into from Nov 14, 2023

Conversation

samuelmaddock
Copy link
Member

Description of Change

Navigating to links within chrome: pages—such as chrome://gpu—don't emit the "will-navigate" event. This is caused by navigations in pages with Web UI (e.g. chrome: pages) to always be set as browser-initiated requests.

To fix this, we're overriding the browser-initiated flag for certain page transitions with navigations on Web UI pages. Pressing links is a link page transition while calling loadURL uses a different page transition type.

Checklist

Release Notes

Notes: Fixed "will-navigate" not being emitted when pressing links in chrome: pages.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Oct 31, 2023
@samuelmaddock samuelmaddock added semver/patch backwards-compatible bug fixes target/27-x-y PR should also be added to the "27-x-y" branch. target/28-x-y PR should also be added to the "28-x-y" branch. labels Oct 31, 2023
shell/browser/electron_navigation_throttle.cc Outdated Show resolved Hide resolved
// ignore that.
// https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/navigator.cc;l=883-892;drc=0c8ffbe78dc0ef2047849e45cefb3f621043e956
if (!is_renderer_initiated &&
ui::PageTransitionIsWebTriggerable(handle->GetPageTransition())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This was new to me, so tldr for other reviewers: true if it's a link, auto subframe, manual subframe, or form submission")

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Nov 1, 2023
@VerteDinde VerteDinde merged commit 088affd into electron:main Nov 14, 2023
16 checks passed
Copy link

release-clerk bot commented Nov 14, 2023

Release Notes Persisted

Fixed "will-navigate" not being emitted when pressing links in chrome: pages.

@trop
Copy link
Contributor

trop bot commented Nov 14, 2023

I have automatically backported this PR to "27-x-y", please check out #40524

@trop trop bot added in-flight/27-x-y and removed target/27-x-y PR should also be added to the "27-x-y" branch. labels Nov 14, 2023
@trop
Copy link
Contributor

trop bot commented Nov 14, 2023

I have automatically backported this PR to "28-x-y", please check out #40525

@trop trop bot added in-flight/28-x-y merged/28-x-y PR was merged to the "28-x-y" branch. merged/27-x-y PR was merged to the "27-x-y" branch. and removed target/28-x-y PR should also be added to the "28-x-y" branch. in-flight/28-x-y in-flight/27-x-y labels Nov 14, 2023
@samuelmaddock samuelmaddock deleted the fix/webui-navigation branch November 15, 2023 17:16
MrHuangJser pushed a commit to MrHuangJser/electron that referenced this pull request Dec 11, 2023
* fix: emit will-navigate for links in chrome: pages

* test: will-navigate emitted from chrome: pages

* Update shell/browser/electron_navigation_throttle.cc

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/27-x-y PR was merged to the "27-x-y" branch. merged/28-x-y PR was merged to the "28-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants