Skip to content

Commit

Permalink
fix: handle a race condition between preload scripts executing and na…
Browse files Browse the repository at this point in the history
…vigations (#17596)

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
  • Loading branch information
trop[bot] authored and MarshallOfSound committed Mar 28, 2019
1 parent 7aaaa24 commit 4574a21
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions atom/browser/api/atom_api_web_contents.cc
Expand Up @@ -1184,6 +1184,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.
Expand Down

0 comments on commit 4574a21

Please sign in to comment.