fix: refactoring regression in LocationProxy (#19495)
This commit is contained in:
parent
4838bd7834
commit
8a33118e36
2 changed files with 22 additions and 2 deletions
|
@ -64,12 +64,12 @@ class LocationProxy {
|
||||||
*/
|
*/
|
||||||
private static ProxyProperty<T> (target: LocationProxy, propertyKey: LocationProperties) {
|
private static ProxyProperty<T> (target: LocationProxy, propertyKey: LocationProperties) {
|
||||||
Object.defineProperty(target, propertyKey, {
|
Object.defineProperty(target, propertyKey, {
|
||||||
get: function (): T | string {
|
get: function (this: LocationProxy): T | string {
|
||||||
const guestURL = this.getGuestURL()
|
const guestURL = this.getGuestURL()
|
||||||
const value = guestURL ? guestURL[propertyKey] : ''
|
const value = guestURL ? guestURL[propertyKey] : ''
|
||||||
return value === undefined ? '' : value
|
return value === undefined ? '' : value
|
||||||
},
|
},
|
||||||
set: function (newVal: T) {
|
set: function (this: LocationProxy, newVal: T) {
|
||||||
const guestURL = this.getGuestURL()
|
const guestURL = this.getGuestURL()
|
||||||
if (guestURL) {
|
if (guestURL) {
|
||||||
// TypeScript doesn't want us to assign to read-only variables.
|
// TypeScript doesn't want us to assign to read-only variables.
|
||||||
|
@ -105,6 +105,10 @@ class LocationProxy {
|
||||||
return null
|
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[]) {
|
private _invokeWebContentsMethodSync (method: string, ...args: any[]) {
|
||||||
return ipcRendererUtils.invokeSync('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, method, ...args)
|
return ipcRendererUtils.invokeSync('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, method, ...args)
|
||||||
}
|
}
|
||||||
|
|
|
@ -508,6 +508,22 @@ describe('chromium feature', () => {
|
||||||
b = window.open('about:blank')
|
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 () => {
|
it('open a blank page when no URL is specified', async () => {
|
||||||
const browserWindowCreated = emittedOnce(app, 'browser-window-created')
|
const browserWindowCreated = emittedOnce(app, 'browser-window-created')
|
||||||
const w = window.open()
|
const w = window.open()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue