electron / electron/electron

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

Open
#21,136 37 comments 3 reactions 0 assignees View on GitHub
10-x-y 20-x-y 22-x-y 5-0-x 7-1-x bug :beetle: has-repro-gist platform/windows
Dominant language
C++
Stars
123k
Forks
17.5k
Avg merge
14h 22m
Merged PRs (30d)
873

Description

### Preflight Checklist

* [x] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
* [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
* [x] 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](https://electronjs.org/docs/api/web-contents#event-will-navigate) 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 start`ing, in the devtools, run `location = "https://google.com"`. Notice that we log it.

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.