fix: refactoring regression in LocationProxy (#19495)

This commit is contained in:
Milan Burda 2019-07-29 20:20:19 +02:00 committed by Shelley Vohr
parent 4838bd7834
commit 8a33118e36
2 changed files with 22 additions and 2 deletions

View file

@ -64,12 +64,12 @@ class LocationProxy {
*/
private static ProxyProperty<T> (target: LocationProxy, propertyKey: LocationProperties) {
Object.defineProperty(target, propertyKey, {
get: function (): T | string {
get: function (this: LocationProxy): T | string {
const guestURL = this.getGuestURL()
const value = guestURL ? guestURL[propertyKey] : ''
return value === undefined ? '' : value
},
set: function (newVal: T) {
set: function (this: LocationProxy, newVal: T) {
const guestURL = this.getGuestURL()
if (guestURL) {
// TypeScript doesn't want us to assign to read-only variables.
@ -105,6 +105,10 @@ class LocationProxy {
return null
}
private _invokeWebContentsMethod (method: string, ...args: any[]) {
return ipcRendererUtils.invoke('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, method, ...args)
}
private _invokeWebContentsMethodSync (method: string, ...args: any[]) {
return ipcRendererUtils.invokeSync('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, method, ...args)
}

View file

@ -508,6 +508,22 @@ describe('chromium feature', () => {
b = window.open('about:blank')
})
it('defines a window.location.href setter', (done) => {
let b = null
app.once('browser-window-created', (event, { webContents }) => {
webContents.once('did-finish-load', () => {
// When it loads, redirect
b.location.href = `file://${fixtures}/pages/base-page.html`
webContents.once('did-finish-load', () => {
// After our second redirect, cleanup and callback
b.close()
done()
})
})
})
b = window.open('about:blank')
})
it('open a blank page when no URL is specified', async () => {
const browserWindowCreated = emittedOnce(app, 'browser-window-created')
const w = window.open()