Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

window.open should return WindowProxy object #1194

Open

Description

@Gozala

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

Activity

  1. Gozala commented on Oct 5, 2018

    @Gozala
    Author

    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

  2. self-assigned this
    on Oct 7, 2018
  3. pfrazee commented on Oct 7, 2018

    @pfrazee
    Member

    I was able to re-enable native open in the electron3 branch but window.opener isn't getting set AFAICT.

  4. Gozala commented on Oct 8, 2018

    @Gozala
    Author

    I was able to re-enable native open in the electron3 branch but window.opener isn't getting set AFAICT.

    I can take stab at creating a reproducible test case for Electron in that case, unless you already have one.

  5. pfrazee commented on Oct 8, 2018

    @pfrazee
    Member
  6. Gozala commented on Oct 8, 2018

    @Gozala
    Author

    I seem to be able to get window.open() return WindowProxy but I don't have much luck in getting that window be displayed in <webview>.

  7. pfrazee commented on Oct 8, 2018

    @pfrazee
    Member

    don't have much luck in getting that window be displayed in <webview>

    Getting that window to be displayed? What do you mean?

  8. Gozala commented on Oct 8, 2018

    @Gozala
    Author

    @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.webContents and make my webview use it as it's webContents but I don't see a way of doing it.

  9. Gozala commented on Oct 8, 2018

    @Gozala
    Author

    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.

  10. Gozala commented on Oct 9, 2018

    @Gozala
    Author

    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

  11. Gozala commented on Oct 9, 2018

    @Gozala
    Author

    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.

  12. Gozala commented on Oct 17, 2018

    @Gozala
    Author

    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.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions