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

BrowserWindow title set to window name by default (from window.open(url, name)) #27036

Closed
3 tasks done
pushkin- opened this issue Dec 16, 2020 · 2 comments · Fixed by #27521
Closed
3 tasks done

BrowserWindow title set to window name by default (from window.open(url, name)) #27036

pushkin- opened this issue Dec 16, 2020 · 2 comments · Fixed by #27521
Assignees
Labels
10-x-y 11-x-y bug/regression ↩️ A new version of Electron broke something has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@pushkin-
Copy link

pushkin- commented Dec 16, 2020

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: Electron 11, 10
  • Operating System: Windows 10
  • Last Known Working Electron version: 9.4.0

Expected Behavior

I expect that the window name doesn't get set into the title

Actual Behavior

When opening windows via window.open passing in a window name, the title of the window gets defaulted to the window name.

edit by @ckerr: since this ticket's caused a little confusion, to restate this: Calling something like window.open("https://example.com/", "aaa") creates a window with a default title that is replaced with the real title when example.com's html is parsed and its <title> is used. Electron 10 introduced a change where that default title is the window.open() windowName parameter (aaa in the example). According to the window.open() documentation this parameter "will NOT be used as the window's title", so Electron is in error by using it as the default title.

To Reproduce

  1. npm start -> main.js
  2. click "Open Window"
  3. Observe that the window title gets set to the window name ("aaa") before being replaced with the <title> of the web page. This didn't used to happen

main.js:

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

function createWindow() {
  const mainWindow = new BrowserWindow({
    webPreferences: {
      nodeIntegration: true,
      nativeWindowOpen: true
    }
  })

  mainWindow.loadFile('index.html')

  mainWindow.webContents.on("new-window", (e, url, f, d, op) => {
    console.log(op.title);
  })
}

app.whenReady().then(() => {
  createWindow()
})

app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') app.quit()
})

index.html:

<!DOCTYPE html>
<html>

<body>
  <button id="b">Open window</button>
  <script src="./renderer.js"></script>
</body>

</html>

renderer.js:

document.getElementById("b").onclick = () => {
    window.open("https://google.com", "aaa");
};
@pushkin-
Copy link
Author

Looks like this was caused by this commit

@ckerr ckerr added 10-x-y 11-x-y bug/regression ↩️ A new version of Electron broke something platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature labels Dec 16, 2020
@ckerr
Copy link
Member

ckerr commented Dec 16, 2020

@ckerr ckerr added the has-repro-gist Issue can be reproduced with code at https://gist.github.com/ label Dec 16, 2020
@mlaurencin mlaurencin self-assigned this Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10-x-y 11-x-y bug/regression ↩️ A new version of Electron broke something has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants