fix: do not reset process_id in URLLoaderFactoryParams (#25139)

This commit is contained in:
Cheng Zhao 2020-08-28 10:43:08 +09:00 committed by GitHub
parent 95073decd3
commit 8f727b3569
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View file

@ -1506,15 +1506,10 @@ void ElectronBrowserClient::OverrideURLLoaderFactoryParams(
const url::Origin& origin, const url::Origin& origin,
bool is_for_isolated_world, bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) { network::mojom::URLLoaderFactoryParams* factory_params) {
for (const auto& iter : process_preferences_) { // Bypass CORB when web security is disabled.
if (iter.second.browser_context != browser_context) auto it = process_preferences_.find(factory_params->process_id);
continue; if (it != process_preferences_.end() && !it->second.web_security) {
factory_params->is_corb_enabled = false;
if (!iter.second.web_security) {
// bypass CORB
factory_params->process_id = iter.first;
factory_params->is_corb_enabled = false;
}
} }
extensions::URLLoaderFactoryManager::OverrideURLLoaderFactoryParams( extensions::URLLoaderFactoryManager::OverrideURLLoaderFactoryParams(

View file

@ -245,6 +245,14 @@ describe('web security', () => {
<script src="${serverUrl}"></script>`); <script src="${serverUrl}"></script>`);
await p; 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', () => { describe('command line switches', () => {