From 89a9423a471b460f83e52f9a52ff0075ea4ec65a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 26 Aug 2020 13:44:43 +0900 Subject: [PATCH] fix: do not reset process_id in URLLoaderFactoryParams --- shell/browser/electron_browser_client.cc | 13 ++++--------- spec-main/chromium-spec.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index cef61ea300fff..7c531fc56b890 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -1516,15 +1516,10 @@ void ElectronBrowserClient::OverrideURLLoaderFactoryParams( const url::Origin& origin, bool is_for_isolated_world, network::mojom::URLLoaderFactoryParams* factory_params) { - for (const auto& iter : process_preferences_) { - if (iter.second.browser_context != browser_context) - continue; - - if (!iter.second.web_security) { - // bypass CORB - factory_params->process_id = iter.first; - factory_params->is_corb_enabled = false; - } + // Bypass CORB when web security is disabled. + auto it = process_preferences_.find(factory_params->process_id); + if (it != process_preferences_.end() && !it->second.web_security) { + factory_params->is_corb_enabled = false; } extensions::URLLoaderFactoryManager::OverrideURLLoaderFactoryParams( diff --git a/spec-main/chromium-spec.ts b/spec-main/chromium-spec.ts index 63ff3ac1b0346..aa1fb9b61e787 100644 --- a/spec-main/chromium-spec.ts +++ b/spec-main/chromium-spec.ts @@ -245,6 +245,14 @@ describe('web security', () => { `); await p; }); + + it('does not crash when multiple WebContent are created with web security disabled', () => { + const options = { webPreferences: { webSecurity: false } }; + const w1 = new BrowserWindow(options); + w1.loadURL(serverUrl); + const w2 = new BrowserWindow(options); + w2.loadURL(serverUrl); + }); }); describe('command line switches', () => {