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]: WebContents.opener is undefined for windows opened via links with target=_blank #36025
Comments
cc @samuelmaddock given this refs #35140 |
This is expected behavior when using https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target
I only learned about this when writing the tests for this API: electron/spec/api-web-contents-spec.ts Lines 1302 to 1329 in 23d4a25
|
@samuelmaddock huh, so even Electron isn't able to access/know the window that opened the child window? I'm not totally following how they're connected. If I window.open a window but disable window.opener, won't webContents.opener still give me the correct result? So how is that different from a link that opens a window with window.opener disabled. |
If electron/spec/api-web-contents-spec.ts Lines 1286 to 1301 in 23d4a25
|
Preflight Checklist
Electron Version
21.1.1
What operating system are you using?
Windows
Operating System Version
Windows 10 version 21H2
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
If a new window is opened via a programmatic call to
window.open()
, that window'swebContents.opener
provides a reference to the frame that opened that window. I would expect the same behavior for new windows opened via links with target="_blank".Actual Behavior
For new windows opened via links with target="_blank", the window's
webContents.opener
is undefined. The opener is provided as expected if the target is a specified frame name (which doesn't already exist).Testcase Gist URL
https://gist.github.com/8dc8da58f36238db0ef950a0a1d639d9
Additional Information
No response
The text was updated successfully, but these errors were encountered: