Add back BrowserWindowProxy location property

This commit is contained in:
Kevin Sawicki 2017-01-12 13:04:18 -08:00
parent de4be56b09
commit fbcbfbda6a
2 changed files with 18 additions and 12 deletions

View file

@ -31,6 +31,16 @@ const removeProxy = (guestId) => {
function BrowserWindowProxy (ipcRenderer, guestId) {
this.closed = false
defineProperty(this, 'location', {
get: function () {
return ipcRenderer.sendSync('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC', guestId, 'getURL')
},
set: function (url) {
url = resolveURL(url)
return ipcRenderer.sendSync('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC', guestId, 'loadURL', url)
}
})
ipcRenderer.once(`ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_${guestId}`, () => {
removeProxy(guestId)
this.closed = true

View file

@ -6,7 +6,7 @@ const url = require('url')
const {ipcRenderer, remote} = require('electron')
const {closeWindow} = require('./window-helpers')
const {BrowserWindow, ipcMain, protocol, session, webContents} = remote
const {app, BrowserWindow, ipcMain, protocol, session, webContents} = remote
const isCI = remote.getGlobal('isCi')
@ -197,12 +197,6 @@ describe('chromium feature', function () {
var b = window.open('about:blank', '', 'show=no')
assert.equal(b.closed, false)
assert.equal(b.constructor.name, 'BrowserWindowProxy')
// Check that guestId is not writeable
assert(b.guestId)
b.guestId = 'anotherValue'
assert.notEqual(b.guestId, 'anoterValue')
b.close()
})
@ -295,12 +289,14 @@ describe('chromium feature', function () {
} else {
targetURL = 'file://' + fixtures + '/pages/base-page.html'
}
b = window.open(targetURL)
webContents.fromId(b.guestId).once('did-finish-load', function () {
assert.equal(b.location, targetURL)
b.close()
done()
app.once('browser-window-created', (event, window) => {
window.webContents.once('did-finish-load', () => {
assert.equal(b.location, targetURL)
b.close()
done()
})
})
b = window.open(targetURL)
})
it('defines a window.location setter', function (done) {