Add back BrowserWindowProxy location property
This commit is contained in:
parent
de4be56b09
commit
fbcbfbda6a
2 changed files with 18 additions and 12 deletions
|
@ -31,6 +31,16 @@ const removeProxy = (guestId) => {
|
||||||
function BrowserWindowProxy (ipcRenderer, guestId) {
|
function BrowserWindowProxy (ipcRenderer, guestId) {
|
||||||
this.closed = false
|
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}`, () => {
|
ipcRenderer.once(`ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_${guestId}`, () => {
|
||||||
removeProxy(guestId)
|
removeProxy(guestId)
|
||||||
this.closed = true
|
this.closed = true
|
||||||
|
|
|
@ -6,7 +6,7 @@ const url = require('url')
|
||||||
const {ipcRenderer, remote} = require('electron')
|
const {ipcRenderer, remote} = require('electron')
|
||||||
const {closeWindow} = require('./window-helpers')
|
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')
|
const isCI = remote.getGlobal('isCi')
|
||||||
|
|
||||||
|
@ -197,12 +197,6 @@ describe('chromium feature', function () {
|
||||||
var b = window.open('about:blank', '', 'show=no')
|
var b = window.open('about:blank', '', 'show=no')
|
||||||
assert.equal(b.closed, false)
|
assert.equal(b.closed, false)
|
||||||
assert.equal(b.constructor.name, 'BrowserWindowProxy')
|
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()
|
b.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -295,13 +289,15 @@ describe('chromium feature', function () {
|
||||||
} else {
|
} else {
|
||||||
targetURL = 'file://' + fixtures + '/pages/base-page.html'
|
targetURL = 'file://' + fixtures + '/pages/base-page.html'
|
||||||
}
|
}
|
||||||
b = window.open(targetURL)
|
app.once('browser-window-created', (event, window) => {
|
||||||
webContents.fromId(b.guestId).once('did-finish-load', function () {
|
window.webContents.once('did-finish-load', () => {
|
||||||
assert.equal(b.location, targetURL)
|
assert.equal(b.location, targetURL)
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
b = window.open(targetURL)
|
||||||
|
})
|
||||||
|
|
||||||
it('defines a window.location setter', function (done) {
|
it('defines a window.location setter', function (done) {
|
||||||
// Load a page that definitely won't redirect
|
// Load a page that definitely won't redirect
|
||||||
|
|
Loading…
Add table
Reference in a new issue