You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 27, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 27, 2022. It is now read-only.
window.open should return WindowProxy object #1194
According to the spec window.open() returns corresponding WindowProxy object unless it could not be opened - which in practice is when call isn't triggered from the DOM event handler as a popup prevention mechanism.
This feature commonly used to allow cross site communication via postMessage between window that was opened and it's window.opener usually used for logins or payments or any situation where page requesting action from another page doesn't wishes to discard it's current state.
At the moment this is totally broken in beaker meaning window.open() always returns null even though tab get's open and window.opener is also always null.
that is misleading for the opener, for instance typically if window.open returns null that tells site it needs to fallback to loading that URL instead passing destination a callback URL, which in beaker would result in two tabs with a same URL active one would not know how to communicate back to opener
I remember from a project that I worked couple years ago that this was an Electron limitation, but it seems that it may have being resolved since electron/electron#9523
What I observe is if I open a window from with-in the webview document, I get WindowProxy object but it's not the window that is being displayed in the new web-view that I've created.
It appears to me that I need some way to take event.options.webContents and make my webview use it as it's webContents but I don't see a way of doing it.
BTW if you set webpreferences="nativeWindowOpen=yes" allowpopups on webview it does open separate window and provides proxy window to it. Updated example now does it and is able to interact with opened window. Still not sure how do I make it be a webview instead.
I have given up on trying to make this work, as it does not look like Electron provides a mechanism to load opened documents into <webview>. I did submit feature request to do support this electron/electron#15040
I found out that BrowserWindowProxy instances returned on "nativeWindowOpen=yes" are implemented (in something that looks like "preload" script) by overriding native window.open to return the instance that is just wired to corresponding guestId.
I am starting to think same mechanism could be (re)used to return BrowserWindowProxy wired to guestId of the <webview> document instead.
I have made a workaround that can be use to overcome bugs (or deliberate choices) in Electron that cause window.open to return null. I have described it in this comment with links to implementation.
I think it would make a lot more sense to land changes into Electron as described in my comment, but unfortunately maintainers 😞 are really fast at closing issues I open in that regard and so fast with feedback loop.
@pfrazee I'll leave it up to you to decide what to do here, as I can no longer justify spending additional time on getting cross-dat-app communication possible.
Activity
Gozala commentedon Oct 5, 2018
I remember from a project that I worked couple years ago that this was an Electron limitation, but it seems that it may have being resolved since electron/electron#9523
There is also dedicated doc for that https://electronjs.org/docs/api/window-open
pfrazee commentedon Oct 7, 2018
I was able to re-enable native open in the
electron3branch but window.opener isn't getting set AFAICT.Gozala commentedon Oct 8, 2018
I can take stab at creating a reproducible test case for Electron in that case, unless you already have one.
pfrazee commentedon Oct 8, 2018
Gozala commentedon Oct 8, 2018
I seem to be able to get
window.open()returnWindowProxybut I don't have much luck in getting that window be displayed in<webview>.pfrazee commentedon Oct 8, 2018
Getting that window to be displayed? What do you mean?
Gozala commentedon Oct 8, 2018
@pfrazee this is more or less the code I have:
https://github.com/Gozala/electron-quick-start/blob/window.open/renderer.js#L12-L19
What I observe is if I open a window from with-in the webview document, I get WindowProxy object but it's not the window that is being displayed in the new web-view that I've created.
It appears to me that I need some way to take
event.options.webContentsand make mywebviewuse it as it'swebContentsbut I don't see a way of doing it.Gozala commentedon Oct 8, 2018
BTW if you set
webpreferences="nativeWindowOpen=yes" allowpopupsonwebviewit does open separate window and provides proxy window to it. Updated example now does it and is able to interact with opened window. Still not sure how do I make it be a webview instead.Gozala commentedon Oct 9, 2018
I have given up on trying to make this work, as it does not look like Electron provides a mechanism to load opened documents into
<webview>. I did submit feature request to do support this electron/electron#15040Gozala commentedon Oct 9, 2018
I found out that
BrowserWindowProxyinstances returned on "nativeWindowOpen=yes" are implemented (in something that looks like "preload" script) by overriding nativewindow.opento return the instance that is just wired to correspondingguestId.I am starting to think same mechanism could be (re)used to return
BrowserWindowProxywired toguestIdof the<webview>document instead.Gozala commentedon Oct 17, 2018
I have made a workaround that can be use to overcome bugs (or deliberate choices) in Electron that cause
window.opento returnnull. I have described it in this comment with links to implementation.I think it would make a lot more sense to land changes into Electron as described in my comment, but unfortunately maintainers 😞 are really fast at closing issues I open in that regard and so fast with feedback loop.
@pfrazee I'll leave it up to you to decide what to do here, as I can no longer justify spending additional time on getting cross-dat-app communication possible.