diff --git a/lib/renderer/window-setup.ts b/lib/renderer/window-setup.ts index fc9373c3d6e5..49b6a8ba5999 100644 --- a/lib/renderer/window-setup.ts +++ b/lib/renderer/window-setup.ts @@ -64,12 +64,12 @@ class LocationProxy { */ private static ProxyProperty (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) } diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index cc3ac3ba90aa..71b9987c057b 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -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()