electron: [Bug]: Window title not being updated when navigating to certain sites after removing a page-title-updated handler that cancels the event

Preflight Checklist

Electron Version

13.1.1

What operating system are you using?

Windows

Operating System Version

Windows 10

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

I expect that when my window doesn’t have a page-title-updated event that cancels title updates, the window title will be updated when navigating to a site like “https://www.google.com

Actual Behavior

The window title isn’t updated and stays set to what was configured in the BrowserWindowConstructorOptions

Testcase Gist URL

No response

Additional Information

  1. start app
  2. observe that the window title is configured to "TITLE"
  3. After 2 seconds, a navigation will happen to https://www.google.com
  4. The title will stay set to “TITLE” instead of “Google”
  5. (note that the behavior works correctly when navigating to https://google.com instead

main.js:

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

(async () => {
  await app.whenReady();
  const win = new BrowserWindow({ title: "TITLE" });
  win.on("page-title-updated", (e) => {
    e.preventDefault();
  });
  await win.loadURL("https://google.com");
  // title will be set to TITLE

  setTimeout(async () => {
    win.removeAllListeners("page-title-updated");
    await win.loadURL("https://www.google.com");
    // window title won't be updated, but will be if site is
    // https://google.com
  }, 2000);

  app.on('window-all-closed', function () {
    app.quit()
  });
})();

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Possibly related: https://bugs.chromium.org/p/chromium/issues/detail?id=1178663

I think this is an upstream bug, we do very little other than forward the events given to us from Chromium here.