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]: setWindowOpenHandler of webContents not called while new window open. #28656

Closed
patil-milind opened this issue Apr 14, 2021 · 8 comments
Closed

Comments

@patil-milind
Copy link

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 a feature request that matches the one I want to file, without success.

Electron Version

12.0.0

What operating system are you using?

Windows

Operating System Version

Windows 10

What arch are you using?

x64

Last Known Working Electron version

12.0.0

Expected Behavior

Electron version: 12.0.0
Problem: Need to disable new windows popup, for this use the event and its working but this is deprecated in Electron 12.0

win.webContents.on('new-window'', event => {
    event.preventDefault()
  })

So instead of above used the suggested alternative handler but this is not getting called during new windows open or mouse mid click.

win.webContents.setWindowOpenHandler(() => {
            return { action: 'deny' };
     });

Expected behavior: On mouse mid click new windows creation should prevented.

Actual Behavior

Actual : New window opens on mouse windows click.

Testcase Gist URL

No response

@patil-milind patil-milind changed the title [Bug]: setWindowOpenHandler of webContents dosent not gets called while new window open. [Bug]: setWindowOpenHandler of webContents not gets called while new window open. Apr 14, 2021
@patil-milind patil-milind changed the title [Bug]: setWindowOpenHandler of webContents not gets called while new window open. [Bug]: setWindowOpenHandler of webContents not called while new window open. Apr 14, 2021
@VerteDinde
Copy link
Member

Hey @patil-milind, thanks for reporting this issue! Correct me if I'm wrong, but I think you may be experiencing the same issue as this user: #27967 We have a fix for this merged into master, and will backport it into 12-x-y - the fix is already available in the newest 13 beta. I'll close this issue once it's backported into 12.

@patil-milind
Copy link
Author

@VerteDinde Yes its same issue as #27967 .

@nornagon
Copy link
Member

Duplicate of #27967

@nornagon nornagon marked this as a duplicate of #27967 Apr 20, 2021
@VerteDinde
Copy link
Member

@patil-milind This fix is available in 12.0.5 🙂 Let us know if it still doesn't work for you!

@Delagen
Copy link

Delagen commented Apr 29, 2021

@VerteDinde I catch download window with this, and calling {action:'deny'} freeze main frame

@nvdai2401
Copy link

catch download window with this, and calling {action:'deny'} freeze main frame

I'm dealing with the same problem as you

@andresavic
Copy link

I get the error message
this.win.webContents.setWindowOpenHandler(({ url }) => { return { action: 'deny' } })

The window open handler response must be an object, but was instead of type 'undefined'.

and the main window freezes as well.

@nornagon
Copy link
Member

@andresavic @nvdai2401 @Delagen that sounds like #29509, which is recently fixed by #29851.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants