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

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

Closed
3 tasks done
hugomano opened this issue Apr 29, 2019 · 3 comments · Fixed by #18173
Closed
3 tasks done

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

hugomano opened this issue Apr 29, 2019 · 3 comments · Fixed by #18173

Comments

@hugomano
Copy link

hugomano commented Apr 29, 2019

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)

@hugomano hugomano 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 Apr 29, 2019
@alexstrat
Copy link
Contributor

Relates to #15821 IMO

@alexstrat
Copy link
Contributor

@ppontes
Copy link
Member

ppontes commented May 9, 2019

#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.

@sofianguy sofianguy moved this from Unsorted Issues to Fixed for Next Release in 5.0.x Jun 4, 2019
@sofianguy sofianguy moved this from Fixed for Next Release to Fixed in 5.0.4 in 5.0.x Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
5.0.x
Fixed in 5.0.4
Development

Successfully merging a pull request may close this issue.

4 participants