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]: Opening Popup Window (window.open) issue #38746
Comments
Hello @rmtech11. Thanks for reporting this and helping to make Electron better! Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use. Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests. Now adding the |
Sounds like: #28625 |
@t57ser thanks for pointing out, its the same issue |
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! |
Closing as duplicate of #28625 |
Preflight Checklist
Electron Version
25.0.1
What operating system are you using?
Windows
Operating System Version
Windows 10 21H2 19044, macOS Ventura 13.4
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
On clicking a link in a webpage, i call window.open for the first time. Electron invokes a 'setWindowOpenHandler' followed by 'did-create-window' event. A new electron "BrowserWindow" is created and loaded the webpage. No issues so far.
(I took the window obj in did-create-window and registered for weContents.destroyed and browserWindow.closed event)
Now I keep track of the opened window in the renderer ( this.popupWindow['frameName'] = window.open(o.url + "?" + o.queryParam, s, d);) and subsequently when i click the same link again (with the same frameName), i call window.close - this.popupWindow['frameName'].close() (so that the first opened webContent would be destroyed) and then call 'window.open' to create a new window again. In this case, i'm expecting the following sequence,
Actual Behavior
On calling window.close first and then window.open in the renderer,
Electron invoked setWindowOpenHandler
did-create-window event is NOT fired (seems electron under the hood maintains a collection based on the frameName and reuse the window if a BrowserWindow exists for the frameName)
Received 'weContents.destroyed' event (of the first window, based on webContents.id)
Received electron.browserWindow closed event
It appears that calling window.close() in the renderer did not close the window immediately or at least until setWindowOpenHandler is invoked. Electron decided to pick the window available for the frameName (https://github.com/electron/electron/blob/f5869b6fb936ba125071f6560ae8c871e4488777/lib/browser/guest-window-manager.ts#LL51C52-L51C61) but got closed as soon as it received the (guest.once('closed')) closed event.
Testcase Gist URL
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: