Get webContents from guestId

This commit is contained in:
Kevin Sawicki 2016-06-09 13:37:50 -07:00
parent c8180ab301
commit 39180e6539

View file

@ -5,8 +5,7 @@ const ws = require('ws')
const url = require('url')
const remote = require('electron').remote
const BrowserWindow = remote.require('electron').BrowserWindow
const session = remote.require('electron').session
const {BrowserWindow, session, webContents} = remote
const isCI = remote.getGlobal('isCi')
@ -235,7 +234,7 @@ describe('chromium feature', function () {
else
targetURL = 'file://' + fixtures + '/pages/base-page.html'
b = window.open(targetURL)
BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function () {
webContents.fromId(b.guestId).once('did-finish-load', function () {
assert.equal(b.location, targetURL)
b.close()
done()
@ -246,10 +245,10 @@ describe('chromium feature', function () {
// Load a page that definitely won't redirect
var b
b = window.open('about:blank')
BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function () {
webContents.fromId(b.guestId).once('did-finish-load', function () {
// When it loads, redirect
b.location = 'file://' + fixtures + '/pages/base-page.html'
BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function () {
webContents.fromId(b.guestId).once('did-finish-load', function () {
// After our second redirect, cleanup and callback
b.close()
done()
@ -308,7 +307,7 @@ describe('chromium feature', function () {
}
window.addEventListener('message', listener)
b = window.open('file://' + fixtures + '/pages/window-open-postMessage.html', '', 'show=no')
BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function () {
webContents.fromId(b.guestId).once('did-finish-load', function () {
b.postMessage('testing', '*')
})
})