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

[Bug]: will-navigate doesn't fire when navigating to about: URLs #21136

Open
3 tasks done
pushkin- opened this issue Nov 14, 2019 · 18 comments
Open
3 tasks done

[Bug]: will-navigate doesn't fire when navigating to about: URLs #21136

pushkin- opened this issue Nov 14, 2019 · 18 comments
Labels
5-0-x 7-1-x 10-x-y 20-x-y 22-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows

Comments

@pushkin-
Copy link

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version: 5.0.7
  • Operating System: Windows 10

Expected Behavior

Based on the documentation, I expect that navigating to "about:blank" will trigger the webcontent's will-navigate event.

Actual Behavior

will-navigate does not get triggered.

The docs make no mention of "about:blank" being an exception, and so I expect that will-navigate should get emitted when navigating to it.

Either this is a documentation error, or it's a bug with will-navigate.

To Reproduce

const { app, BrowserWindow, BrowserView } = require('electron')

async function onReady() {
	const mainWindow = new BrowserWindow();
	const view = new BrowserView();
	view.webContents.addListener("will-navigate", (e, url) => {
		console.log("navigating to: " + url);
	});
	mainWindow.setBrowserView(view);
	await view.webContents.loadURL("https://google.com");
	view.webContents.openDevTools();
}

app.on('ready', onReady)

After npm starting, in the devtools, run location = "https://google.com". Notice that we log it.

Then run location = "about:blank". Notice, that there's no log.

@pushkin-
Copy link
Author

this is also an issue with Electron 7.1.2

@sofianguy sofianguy added this to Unsorted Issues in 7.2.x Feb 15, 2020
@pushkin-
Copy link
Author

Still a problem in Electron 10.1.2

@pimterry
Copy link

Still a problem in Electron v11.3.0, and a fairly annoying one: I include links from external content in my app, and intercept them using will-navigate and new-window to allow HTTP links only and to redirect them to the system browser. It seems that about:blank ignores all that, and somehow some about:blank links are occasionally sneaking into some of the content I render.

If anybody clicks such a link, instead of either being blocked or opening in the system browser (both pretty reasonable) it blanks the entire app. As far as I can tell there's no other event or workaround for this available at present, so there's nothing I can do to protect against this at the Electron level.

@pushkin-
Copy link
Author

@pimterry Can you use onBeforeRequest to cancel the request to about:blank?

@pimterry
Copy link

pimterry commented Mar 25, 2021

@pushkin- no, that doesn't work either, it doesn't fire (presumably because there's no actual HTTP request involved).

That's with this code:

    session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
        console.log("before request to", details.url);
        callback({});
    });

It logs every other request the app makes, but no request to about:blank

@mckravchyk
Copy link
Contributor

Note that it's not just about:blank, but also about:, about:anything

@pushkin- pushkin- changed the title will-navigate doesn't fire when navigating to about:blank will-navigate doesn't fire when navigating to about: URLs Nov 11, 2021
@rzhao271
Copy link
Contributor

rzhao271 commented Jan 6, 2022

The issue still occurs in 16.0.4.
gist: https://gist.github.com/rzhao271/db5a33e5b332bc5f292f049be6c404a1

@CodeSmith32
Copy link

Bump:
This is still an issue as of Electron v20.0.0.

@ckerr ckerr added has-repro-gist Issue can be reproduced with code at https://gist.github.com/ 20-x-y labels Sep 12, 2022
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jan 10, 2023
@CodeSmith32
Copy link

Bump:
This is still an issue as of Electron v22.0.0.

@github-actions github-actions bot removed the stale label Jan 11, 2023
@dsanders11 dsanders11 changed the title will-navigate doesn't fire when navigating to about: URLs [Bug]: will-navigate doesn't fire when navigating to about: URLs Feb 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2023

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label May 8, 2023
@pushkin-
Copy link
Author

pushkin- commented May 9, 2023

bump

@github-actions github-actions bot removed the stale label May 10, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2023

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Aug 9, 2023
@pushkin-
Copy link
Author

pushkin- commented Aug 9, 2023

repros with v25.4.0

@github-actions github-actions bot removed the stale label Aug 10, 2023
@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@pushkin-
Copy link
Author

pushkin- commented Nov 9, 2023

repros in v27

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@pushkin-
Copy link
Author

pushkin- commented Feb 9, 2024

repros in v28 and v29-beta8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5-0-x 7-1-x 10-x-y 20-x-y 22-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows
Projects
No open projects
5.0.x
Unsorted Issues
7.2.x
Unsorted Issues
Development

No branches or pull requests

9 participants