Skip to content

window.opener opened from webview is null after cross site navigation #18032

Closed

Description

@hugomano

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

Issue Details

  • Electron Version:
    5.0.0
  • Operating System:
    macOS 10.14.4
  • Last Known Working Electron version::
    4.0.4

Expected Behavior

Open a Window with domain A via window.open et navigate to domain B in the opened window should keep the window.opener reference.

At the business logic level, sign-in with Google Auth from a web frame doesn't work. The callback on final application domain can't post a message to the window opener.

Actual Behavior

The window.opener is null after cross-site navigation.

To Reproduce

// main.js

const { app, BrowserWindow } = require('electron')

function createWindow() {
  const mainWindow = new BrowserWindow({
        webPreferences: {
          nodeIntegration: true,
          webviewTag: true,
          contextIsolation: false,
        }
  });

  mainWindow.loadFile('index.html')
}

app.on('ready', createWindow)
app.on('window-all-closed', app.quit);
  <webview src="https://mail.google.com" allowpopups></webview>
  • Call window.open('https://google.com') from the web view dev tools
  • The window.opener is not null
  • Go to Github with window.location = 'https://github.com'; the window.opener is null

Screenshots

Additional Information

Similar issues have been reported: #17869,
#15821, #8100

Also preloads doesn't load in the same origin context for the opened window.
Seems linked to #17989:

  • Web view (myapp.com) open auth.google.com, window.opener is null and preloads are loaded
  • Web view (myapp.com) open auth.myapp.com, window.opener is set but preloads are not loaded

More details here
History: #11471 (comment)

Activity

  1. changed the title [-]`window.opener` opened from webview is null after cross site navigation[/-] [+]window.opener opened from webview is null after cross site navigation[/+] on Apr 29, 2019
  2. alexstrat commented on Apr 30, 2019

    @alexstrat
    Contributor

    Relates to #15821 IMO

  3. ppontes commented on May 9, 2019

    @ppontes
    Member

    #15821 fixed this bug for sandboxed renderers. For non-sandboxed renderers, Node is enabled and the approach Electron uses to force it to be properly restarted upon navigation causes this problem.
    While this is worked on, you can consider either sandboxing your renderer if at all possible or not using native window open to open the popup.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions