New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: don't reject loadURL()
promise from did-fail-load
- use did-finish-load
instead
#40661
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems broadly reasonable, but the WebContentsObserver docs make it seem like did-finish-load won't always be called:
// This method is invoked when the load is done, i.e. the spinner of the tab
// will stop spinning, and the onload event was dispatched.
//
// If the WebContents is displaying replacement content, e.g. network error
// pages, DidFinishLoad is invoked for frames that were not sending
// navigational events before. It is safe to ignore these events.
virtual void DidFinishLoad(RenderFrameHost* render_frame_host,
const GURL& validated_url) {}
// This method is like DidFinishLoad, but when the load failed or was
// cancelled, e.g. window.stop() is invoked.
virtual void DidFailLoad(RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) {}
How sure are we that did-finish-load is always called after did-fail-load is dispatched?
Also, a relevant test is failing :)
As far as I can tell, the call hierarchy is linear (i.e. no other path leads to
And
|
Actually, it was |
d27ad6e
to
834a472
Compare
Release Notes Persisted
|
Can we backport this to 27? |
Description of Change
Fixes this issue: #40640
The promise from
WebContents.loadURL()
rejects as soon as it receivesdid-fail-load
. However,did-fail-load
will be followed by adid-finish-load
, which means that if the client code immediately issues anotherloadURL()
when the promise rejects, thisloadURL()
will be resolved by the previous call'sdid-finish-load
.This PR changes the
did-fail-load
handler to only note the failure, and leave it todid-finish-load
to actually resolve/reject the promise.Checklist
npm test
passesRelease Notes
Notes: Fixed
WebContents.loadURL()
incorrectly failing if called immediately after a previous call toloadURL()
failed.