fix: child window may have opener removed (#38910)
This commit is contained in:
parent
ff6d0df2d5
commit
09669f9d21
2 changed files with 18 additions and 1 deletions
|
@ -63,7 +63,7 @@ void ElectronRenderFrameObserver::DidClearWindowObject() {
|
|||
// Check DidInstallConditionalFeatures below for the background.
|
||||
auto* web_frame =
|
||||
static_cast<blink::WebLocalFrameImpl*>(render_frame_->GetWebFrame());
|
||||
if (has_delayed_node_initialization_ && web_frame->Opener() &&
|
||||
if (has_delayed_node_initialization_ &&
|
||||
!web_frame->IsOnInitialEmptyDocument()) {
|
||||
v8::Isolate* isolate = blink::MainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
|
|
@ -1150,6 +1150,23 @@ describe('chromium features', () => {
|
|||
expect(eventData).to.equal('size: 350 450');
|
||||
});
|
||||
|
||||
it('loads preload script after setting opener to null', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.webContents.setWindowOpenHandler(() => ({
|
||||
action: 'allow',
|
||||
overrideBrowserWindowOptions: {
|
||||
webPreferences: {
|
||||
preload: path.join(fixturesPath, 'module', 'preload.js')
|
||||
}
|
||||
}
|
||||
}));
|
||||
w.loadURL('about:blank');
|
||||
w.webContents.executeJavaScript('window.child = window.open(); child.opener = null');
|
||||
const [, { webContents }] = await once(app, 'browser-window-created');
|
||||
const [,, message] = await once(webContents, 'console-message');
|
||||
expect(message).to.equal('{"require":"function","module":"undefined","process":"object","Buffer":"function"}');
|
||||
});
|
||||
|
||||
it('disables the <webview> tag when it is disabled on the parent window', async () => {
|
||||
const windowUrl = url.pathToFileURL(path.join(fixturesPath, 'pages', 'window-opener-no-webview-tag.html'));
|
||||
windowUrl.searchParams.set('p', `${fixturesPath}/pages/window-opener-webview.html`);
|
||||
|
|
Loading…
Reference in a new issue