fix: replace default frameName title with null check (#27521)

* refactor: replace default frameName title with null check

* add isNativeWindowOpen check in makeBrowserWindowOptions

* modify snapshot test files

* replace title with frame-name again for proxy - not native open

* modify proxy snapshot title key-value to come after height key-value
This commit is contained in:
Michaela Laurencin 2021-01-29 05:24:30 -08:00 committed by GitHub
parent 40aeb0d994
commit 357becd113
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 22 deletions

View file

@ -47,6 +47,7 @@ export function openGuestWindow ({ event, embedder, guest, referrer, disposition
embedder, embedder,
features, features,
frameName, frameName,
isNativeWindowOpen,
overrideOptions: overrideBrowserWindowOptions overrideOptions: overrideBrowserWindowOptions
}); });
@ -199,10 +200,11 @@ const securityWebPreferences: { [key: string]: boolean } = {
enableWebSQL: false enableWebSQL: false
}; };
function makeBrowserWindowOptions ({ embedder, features, frameName, overrideOptions, useDeprecatedBehaviorForBareValues = true, useDeprecatedBehaviorForOptionInheritance = true }: { function makeBrowserWindowOptions ({ embedder, features, frameName, isNativeWindowOpen, overrideOptions, useDeprecatedBehaviorForBareValues = true, useDeprecatedBehaviorForOptionInheritance = true }: {
embedder: WebContents, embedder: WebContents,
features: string, features: string,
frameName: string, frameName: string,
isNativeWindowOpen: boolean,
overrideOptions?: BrowserWindowConstructorOptions, overrideOptions?: BrowserWindowConstructorOptions,
useDeprecatedBehaviorForBareValues?: boolean useDeprecatedBehaviorForBareValues?: boolean
useDeprecatedBehaviorForOptionInheritance?: boolean useDeprecatedBehaviorForOptionInheritance?: boolean
@ -216,9 +218,9 @@ function makeBrowserWindowOptions ({ embedder, features, frameName, overrideOpti
options: { options: {
...(useDeprecatedBehaviorForOptionInheritance && deprecatedInheritedOptions), ...(useDeprecatedBehaviorForOptionInheritance && deprecatedInheritedOptions),
show: true, show: true,
title: frameName,
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 })

View file

@ -5,11 +5,11 @@
"sender": "[WebContents]" "sender": "[WebContents]"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"width": 800, "width": 800,
"title": "frame name", "title": "cool",
"backgroundColor": "blue", "backgroundColor": "blue",
"focusable": false, "focusable": false,
"webPreferences": { "webPreferences": {
@ -43,11 +43,11 @@
"sender": "[WebContents]" "sender": "[WebContents]"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"width": 800, "width": 800,
"title": "frame name", "title": "cool",
"backgroundColor": "blue", "backgroundColor": "blue",
"focusable": false, "focusable": false,
"webPreferences": { "webPreferences": {
@ -80,11 +80,11 @@
"sender": "[WebContents]" "sender": "[WebContents]"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"width": 800, "width": 800,
"title": "frame name", "title": "cool",
"backgroundColor": "gray", "backgroundColor": "gray",
"focusable": false, "focusable": false,
"webPreferences": { "webPreferences": {
@ -115,7 +115,7 @@
"sender": "[WebContents]" "sender": "[WebContents]"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"width": 800, "width": 800,
@ -150,11 +150,11 @@
"sender": "[WebContents]" "sender": "[WebContents]"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"width": 800, "width": 800,
"title": "frame name", "title": "cool",
"backgroundColor": "blue", "backgroundColor": "blue",
"focusable": false, "focusable": false,
"webPreferences": { "webPreferences": {

View file

@ -7,13 +7,13 @@
"processId": "placeholder-process-id" "processId": "placeholder-process-id"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"show": true, "show": true,
"title": "frame name",
"width": 800, "width": 800,
"height": 600, "height": 600,
"title": "frame-name",
"top": 5, "top": 5,
"left": 10, "left": 10,
"resizable": false, "resizable": false,
@ -42,13 +42,13 @@
"processId": "placeholder-process-id" "processId": "placeholder-process-id"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"show": true, "show": true,
"title": "frame name",
"width": 800, "width": 800,
"height": 600, "height": 600,
"title": "frame-name",
"resizable": false, "resizable": false,
"x": 0, "x": 0,
"y": 10, "y": 10,
@ -76,13 +76,13 @@
"processId": "placeholder-process-id" "processId": "placeholder-process-id"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"show": true, "show": true,
"title": "frame name",
"width": 800, "width": 800,
"height": 600, "height": 600,
"title": "frame-name",
"backgroundColor": "gray", "backgroundColor": "gray",
"webPreferences": { "webPreferences": {
"nodeIntegration": false, "nodeIntegration": false,
@ -110,13 +110,13 @@
"processId": "placeholder-process-id" "processId": "placeholder-process-id"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"show": true, "show": true,
"title": "sup",
"width": 800, "width": 800,
"height": 600, "height": 600,
"title": "sup",
"x": 50, "x": 50,
"y": 20, "y": 20,
"webPreferences": { "webPreferences": {
@ -142,13 +142,13 @@
"processId": "placeholder-process-id" "processId": "placeholder-process-id"
}, },
"about:blank", "about:blank",
"frame name", "frame-name",
"new-window", "new-window",
{ {
"show": false, "show": false,
"title": "frame name",
"width": 800, "width": 800,
"height": 600, "height": 600,
"title": "frame-name",
"top": 1, "top": 1,
"left": 1, "left": 1,
"x": 1, "x": 1,

View file

@ -10,7 +10,7 @@ function genSnapshot (browserWindow: BrowserWindow, features: string) {
browserWindow.webContents.on('new-window', (...args: any[]) => { browserWindow.webContents.on('new-window', (...args: any[]) => {
resolve([features, ...args]); resolve([features, ...args]);
}); });
browserWindow.webContents.executeJavaScript(`window.open('about:blank', 'frame name', '${features}') && true`); browserWindow.webContents.executeJavaScript(`window.open('about:blank', 'frame-name', '${features}') && true`);
}); });
} }