8000 fix: refactoring regression in LocationProxy by miniak · Pull Request #19494 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: refactoring regression in LocationProxy #19494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/renderer/window-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ 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.
// It's right, that's bad, but we're doing it anway.
(guestURL as any)[propertyKey] = newVal

return this.ipcRenderer.sendSync(
return ipcRendererInternal.sendSync(
'ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC',
this.guestId, 'loadURL', guestURL.toString())
}
Expand Down
16 changes: 16 additions & 0 deletions spec/chromium-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,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()
Expand Down
0