fix: handle a race condition between preload scripts executing and (#17577)

navigations

There is a race condition between DidCreateScriptContext and another
navigation occuring in the main process. If the navigation occurs while
the preload script is running, the same process is re-used.  This
ensures that any pending navigations are completely removed / ignored
when we trigger a new navigation.

Fixes #17576
This commit is contained in:
Samuel Attard 2019-03-28 11:13:05 -07:00 committed by GitHub
parent 7eaa57b116
commit 3475cd168e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1200,6 +1200,9 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
params.transition_type = ui::PAGE_TRANSITION_TYPED;
params.should_clear_history_list = true;
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
// Discord non-committed entries to ensure that we don't re-use a pending
// entry
web_contents()->GetController().DiscardNonCommittedEntries();
web_contents()->GetController().LoadURLWithParams(params);
// Set the background color of RenderWidgetHostView.