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]: {action: "deny"} from contents.setWindowOpenHandler(handler) is unusable #42210

Closed
3 tasks done
safris opened this issue May 16, 2024 · 2 comments
Closed
3 tasks done
Labels
blocked/need-info ❌ Cannot proceed without more information bug 🪲

Comments

@safris
Copy link

safris commented May 16, 2024

Preflight Checklist

Electron Version

30.0.4

What operating system are you using?

macOS

Operating System Version

Sonoma 14.4.1

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Expected Behavior

The documentation here describes the behavior of the contents.setWindowOpenHandler(handler).

If {action: "allow"} is returned, a BrowserWindow will be instantiated.

If {action: "deny"} is returned, a BrowserWindow will be not be instantiated. But also, the WebContents from whose renderer the window.open() function was called will show a dialog saying "Grrr! A popup blocker may be preventing the application from opening the page. If you have a popup blocker, try disabling it to open the window."

I would expect there to be a mechanism by which the "Grrr!..." dialog can be quashed (i.e. not shown).

Actual Behavior

I have not been able to find any mention of how to quash the "Grrr!..." dialog. If the dialog cannot be quashed, then {action: "deny"} cannot ever be returned from contents.setWindowOpenHandler(handler) for a window.open() call from a renderer without displaying the "Grrr!..." dialog, thus making {action: "deny"} unusable.

Testcase Gist URL

No response

Additional Information

No response

@codebytere
Copy link
Member

codebytere commented May 17, 2024

"Grrr! A popup blocker may be preventing the application from opening the page. If you have a popup blocker, try disabling it to open the window."

I've never seen this and it's not part of Chromium's own codebase - is this part of the app you're working on? It's not reproducible for me either. The window simply doesn't open, as I'd expect. I added

mainWindow.webContents.setWindowOpenHandler((details) => {
    return {
      action: 'deny'
    }
  })

to the main process and window.open() to the renderer process on macOS.

@codebytere codebytere added the blocked/need-info ❌ Cannot proceed without more information label May 17, 2024
@safris
Copy link
Author

safris commented May 19, 2024

@codebytere, you're absolutely right. This bug was indeed outside of Electron. I apologize for raising this here, and thank you for looking into it 🙏

@safris safris closed this as completed May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/need-info ❌ Cannot proceed without more information bug 🪲
Projects
None yet
Development

No branches or pull requests

2 participants