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]: Opening Popup Window (window.open) issue #38746

Closed
3 tasks done
rmtech11 opened this issue Jun 12, 2023 · 5 comments
Closed
3 tasks done

[Bug]: Opening Popup Window (window.open) issue #38746

rmtech11 opened this issue Jun 12, 2023 · 5 comments

Comments

@rmtech11
Copy link

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,

  1. 'weContents.destroyed' event to be fired for the first BrowserWindow
  2. Electron.browserWindow closed for the firs BrowserWindow
  3. Electron to invoke the setWindowOpenHandler
  4. did-create-window event should be fired.

Actual Behavior

On calling window.close first and then window.open in the renderer,

  1. 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)

  2. Received 'weContents.destroyed' event (of the first window, based on webContents.id)

  3. 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

@github-actions
Copy link
Contributor

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 blocked/need-repro label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.

@t57ser
Copy link
Contributor

t57ser commented Jun 15, 2023

Sounds like: #28625

@github-actions github-actions bot removed the blocked/need-repro Needs a test case to reproduce the bug label Jun 15, 2023
@rmtech11
Copy link
Author

@t57ser thanks for pointing out, its the same issue

@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!

@codebytere
Copy link
Member

Closing as duplicate of #28625

@codebytere codebytere closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Unsorted Items
Development

No branches or pull requests

4 participants