fix: remove windowName set as title for native window.open() (#27481)
This commit is contained in:
parent
d5bcf742be
commit
c175d41ae8
4 changed files with 11 additions and 21 deletions
|
@ -14,6 +14,12 @@ This document uses the following convention to categorize breaking changes:
|
||||||
|
|
||||||
## Planned Breaking API Changes (14.0)
|
## Planned Breaking API Changes (14.0)
|
||||||
|
|
||||||
|
### API Changed: `window.(open)`
|
||||||
|
|
||||||
|
The optional parameter `frameName` will no longer set the title of the window. This now follows the specification described by the [native documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#parameters) under the corresponding parameter `windowName`.
|
||||||
|
|
||||||
|
If you were using this parameter to set the title of a window, you can instead use [win.setTitle(title)](https://www.electronjs.org/docs/api/browser-window#winsettitletitle).
|
||||||
|
|
||||||
### Removed: `worldSafeExecuteJavaScript`
|
### Removed: `worldSafeExecuteJavaScript`
|
||||||
|
|
||||||
In Electron 14, `worldSafeExecuteJavaScript` will be removed. There is no alternative, please
|
In Electron 14, `worldSafeExecuteJavaScript` will be removed. There is no alternative, please
|
||||||
|
|
|
@ -46,8 +46,6 @@ export function openGuestWindow ({ event, embedder, guest, referrer, disposition
|
||||||
const { options: browserWindowOptions, additionalFeatures } = makeBrowserWindowOptions({
|
const { options: browserWindowOptions, additionalFeatures } = makeBrowserWindowOptions({
|
||||||
embedder,
|
embedder,
|
||||||
features,
|
features,
|
||||||
frameName,
|
|
||||||
isNativeWindowOpen,
|
|
||||||
overrideOptions: overrideBrowserWindowOptions
|
overrideOptions: overrideBrowserWindowOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -200,11 +198,9 @@ const securityWebPreferences: { [key: string]: boolean } = {
|
||||||
enableWebSQL: false
|
enableWebSQL: false
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeBrowserWindowOptions ({ embedder, features, frameName, isNativeWindowOpen, overrideOptions, useDeprecatedBehaviorForBareValues = true, useDeprecatedBehaviorForOptionInheritance = true }: {
|
function makeBrowserWindowOptions ({ embedder, features, overrideOptions, useDeprecatedBehaviorForBareValues = true, useDeprecatedBehaviorForOptionInheritance = true }: {
|
||||||
embedder: WebContents,
|
embedder: WebContents,
|
||||||
features: string,
|
features: string,
|
||||||
frameName: string,
|
|
||||||
isNativeWindowOpen: boolean,
|
|
||||||
overrideOptions?: BrowserWindowConstructorOptions,
|
overrideOptions?: BrowserWindowConstructorOptions,
|
||||||
useDeprecatedBehaviorForBareValues?: boolean
|
useDeprecatedBehaviorForBareValues?: boolean
|
||||||
useDeprecatedBehaviorForOptionInheritance?: boolean
|
useDeprecatedBehaviorForOptionInheritance?: boolean
|
||||||
|
@ -220,7 +216,6 @@ function makeBrowserWindowOptions ({ embedder, features, frameName, isNativeWind
|
||||||
show: true,
|
show: true,
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
...(!isNativeWindowOpen && { title: frameName }),
|
|
||||||
...parsedOptions,
|
...parsedOptions,
|
||||||
...overrideOptions,
|
...overrideOptions,
|
||||||
webPreferences: makeWebPreferences({ embedder, insecureParsedWebPreferences: parsedWebPreferences, secureOverrideWebPreferences: overrideOptions && overrideOptions.webPreferences, useDeprecatedBehaviorForOptionInheritance: true })
|
webPreferences: makeWebPreferences({ embedder, insecureParsedWebPreferences: parsedWebPreferences, secureOverrideWebPreferences: overrideOptions && overrideOptions.webPreferences, useDeprecatedBehaviorForOptionInheritance: true })
|
||||||
|
|
|
@ -744,20 +744,13 @@ describe('chromium features', () => {
|
||||||
expect(await w.webContents.executeJavaScript('b.location.href')).to.equal('about:blank');
|
expect(await w.webContents.executeJavaScript('b.location.href')).to.equal('about:blank');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets the window title to the specified frameName', async () => {
|
|
||||||
const w = new BrowserWindow({ show: false });
|
|
||||||
w.loadURL('about:blank');
|
|
||||||
w.webContents.executeJavaScript('{ b = window.open(\'\', \'hello\'); null }');
|
|
||||||
const [, window] = await emittedOnce(app, 'browser-window-created');
|
|
||||||
expect(window.getTitle()).to.equal('hello');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not throw an exception when the frameName is a built-in object property', async () => {
|
it('does not throw an exception when the frameName is a built-in object property', async () => {
|
||||||
const w = new BrowserWindow({ show: false });
|
const w = new BrowserWindow({ show: false });
|
||||||
w.loadURL('about:blank');
|
w.loadURL('about:blank');
|
||||||
w.webContents.executeJavaScript('{ b = window.open(\'\', \'__proto__\'); null }');
|
w.webContents.executeJavaScript('{ b = window.open(\'\', \'__proto__\'); null }');
|
||||||
const [, window] = await emittedOnce(app, 'browser-window-created');
|
const [, , frameName] = await emittedOnce(w.webContents, 'new-window');
|
||||||
expect(window.getTitle()).to.equal('__proto__');
|
|
||||||
|
expect(frameName).to.equal('__proto__');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('denies custom open when nativeWindowOpen: true', async () => {
|
it('denies custom open when nativeWindowOpen: true', async () => {
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"width": 800,
|
"width": 800,
|
||||||
"height": 600,
|
"height": 600,
|
||||||
"title": "frame-name",
|
|
||||||
"top": 5,
|
"top": 5,
|
||||||
"left": 10,
|
"left": 10,
|
||||||
"resizable": false,
|
"resizable": false,
|
||||||
|
@ -48,7 +47,6 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"width": 800,
|
"width": 800,
|
||||||
"height": 600,
|
"height": 600,
|
||||||
"title": "frame-name",
|
|
||||||
"resizable": false,
|
"resizable": false,
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 10,
|
"y": 10,
|
||||||
|
@ -82,7 +80,6 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"width": 800,
|
"width": 800,
|
||||||
"height": 600,
|
"height": 600,
|
||||||
"title": "frame-name",
|
|
||||||
"backgroundColor": "gray",
|
"backgroundColor": "gray",
|
||||||
"webPreferences": {
|
"webPreferences": {
|
||||||
"nodeIntegration": false,
|
"nodeIntegration": false,
|
||||||
|
@ -116,9 +113,9 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"width": 800,
|
"width": 800,
|
||||||
"height": 600,
|
"height": 600,
|
||||||
"title": "sup",
|
|
||||||
"x": 50,
|
"x": 50,
|
||||||
"y": 20,
|
"y": 20,
|
||||||
|
"title": "sup",
|
||||||
"webPreferences": {
|
"webPreferences": {
|
||||||
"nodeIntegration": false,
|
"nodeIntegration": false,
|
||||||
"webviewTag": false,
|
"webviewTag": false,
|
||||||
|
@ -148,7 +145,6 @@
|
||||||
"show": false,
|
"show": false,
|
||||||
"width": 800,
|
"width": 800,
|
||||||
"height": 600,
|
"height": 600,
|
||||||
"title": "frame-name",
|
|
||||||
"top": 1,
|
"top": 1,
|
||||||
"left": 1,
|
"left": 1,
|
||||||
"x": 1,
|
"x": 1,
|
||||||
|
|
Loading…
Add table
Reference in a new issue