fix: propagate window.open settings to child window (#31031)
This commit is contained in:
parent
ee19e5ee48
commit
4fcc0884f8
1 changed files with 11 additions and 0 deletions
|
@ -4,6 +4,7 @@ import type { BrowserWindowConstructorOptions, LoadURLOptions } from 'electron/m
|
||||||
import * as url from 'url';
|
import * as url from 'url';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { openGuestWindow, makeWebPreferences, parseContentTypeFormat } from '@electron/internal/browser/guest-window-manager';
|
import { openGuestWindow, makeWebPreferences, parseContentTypeFormat } from '@electron/internal/browser/guest-window-manager';
|
||||||
|
import { parseFeatures } from '@electron/internal/common/parse-features-string';
|
||||||
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
|
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
|
||||||
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
|
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
|
||||||
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
|
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
|
||||||
|
@ -665,6 +666,16 @@ WebContents.prototype._init = function () {
|
||||||
postBody
|
postBody
|
||||||
};
|
};
|
||||||
windowOpenOverriddenOptions = this._callWindowOpenHandler(event, details);
|
windowOpenOverriddenOptions = this._callWindowOpenHandler(event, details);
|
||||||
|
// if attempting to use this API with the deprecated window.open event,
|
||||||
|
// windowOpenOverriddenOptions will always return null. This ensures
|
||||||
|
// short-term backwards compatibility until window.open is removed.
|
||||||
|
const parsedFeatures = parseFeatures(rawFeatures);
|
||||||
|
const overriddenFeatures: BrowserWindowConstructorOptions = {
|
||||||
|
...parsedFeatures.options,
|
||||||
|
webPreferences: parsedFeatures.webPreferences
|
||||||
|
};
|
||||||
|
windowOpenOverriddenOptions = windowOpenOverriddenOptions || overriddenFeatures;
|
||||||
|
|
||||||
if (!event.defaultPrevented) {
|
if (!event.defaultPrevented) {
|
||||||
const secureOverrideWebPreferences = windowOpenOverriddenOptions ? {
|
const secureOverrideWebPreferences = windowOpenOverriddenOptions ? {
|
||||||
// Allow setting of backgroundColor as a webPreference even though
|
// Allow setting of backgroundColor as a webPreference even though
|
||||||
|
|
Loading…
Add table
Reference in a new issue