refactor: improve feature string parsing (#23130)
* test: add pre-change snapshot of new-window event * move to .ts file for easier diff * refactor: improve feature string parsing logic * test: update snapshots * update type names per review * update comma-separated parse test * use for loop instead of reduce per review * tighten up types * avoid variable guest contents id returnValue in test snapshot
This commit is contained in:
parent
b3909f5600
commit
aca2e4f968
10 changed files with 589 additions and 108 deletions
|
@ -11,7 +11,7 @@ const { internalWindowOpen } = require('@electron/internal/browser/guest-window-
|
|||
const NavigationController = require('@electron/internal/browser/navigation-controller');
|
||||
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal');
|
||||
const ipcMainUtils = require('@electron/internal/browser/ipc-main-internal-utils');
|
||||
const { convertFeaturesString } = require('@electron/internal/common/parse-features-string');
|
||||
const { parseFeatures } = require('@electron/internal/common/parse-features-string');
|
||||
const { MessagePortMain } = require('@electron/internal/browser/message-port-main');
|
||||
|
||||
// session is not used here, the purpose is to make sure session is initalized
|
||||
|
@ -511,11 +511,13 @@ WebContents.prototype._init = function () {
|
|||
// Make new windows requested by links behave like "window.open".
|
||||
this.on('-new-window', (event, url, frameName, disposition,
|
||||
rawFeatures, referrer, postData) => {
|
||||
const { options, additionalFeatures } = convertFeaturesString(rawFeatures, frameName);
|
||||
const { options, webPreferences, additionalFeatures } = parseFeatures(rawFeatures);
|
||||
const mergedOptions = {
|
||||
show: true,
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: frameName,
|
||||
webPreferences,
|
||||
...options
|
||||
};
|
||||
|
||||
|
@ -533,12 +535,14 @@ WebContents.prototype._init = function () {
|
|||
return;
|
||||
}
|
||||
|
||||
const { options, additionalFeatures } = convertFeaturesString(rawFeatures, frameName);
|
||||
const { options, webPreferences, additionalFeatures } = parseFeatures(rawFeatures);
|
||||
const mergedOptions = {
|
||||
show: true,
|
||||
width: 800,
|
||||
height: 600,
|
||||
webContents,
|
||||
title: frameName,
|
||||
webPreferences,
|
||||
...options
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue