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