mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Determine failed navigation based on Frame.unreachedURL (#365)
This patch starts using frame.unreachedURL property from frameNavigated event to determine if the page navigation was successful.
This commit is contained in:
parent
ae14c1eee4
commit
d71feb63d0
@ -130,6 +130,14 @@ class FrameManager extends EventEmitter {
|
|||||||
this._frames.delete(frame._id);
|
this._frames.delete(frame._id);
|
||||||
this.emit(FrameManager.Events.FrameDetached, frame);
|
this.emit(FrameManager.Events.FrameDetached, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {!Frame} frame
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
isMainFrameLoadingFailed() {
|
||||||
|
return !!this._mainFrame._loadingFailed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
@ -337,6 +345,7 @@ class Frame {
|
|||||||
_navigated(framePayload) {
|
_navigated(framePayload) {
|
||||||
this._name = framePayload.name;
|
this._name = framePayload.name;
|
||||||
this._url = framePayload.url;
|
this._url = framePayload.url;
|
||||||
|
this._loadingFailed = !!framePayload.unreachableUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
_detach() {
|
_detach() {
|
||||||
|
@ -293,12 +293,9 @@ class Page extends EventEmitter {
|
|||||||
}
|
}
|
||||||
await result;
|
await result;
|
||||||
helper.removeEventListeners([listener]);
|
helper.removeEventListeners([listener]);
|
||||||
if (url === 'about:blank')
|
if (this._frameManager.isMainFrameLoadingFailed())
|
||||||
return null;
|
|
||||||
let response = responses.get(this.mainFrame().url());
|
|
||||||
if (!response)
|
|
||||||
throw new Error('Failed to navigate: ' + url);
|
throw new Error('Failed to navigate: ' + url);
|
||||||
return response;
|
return responses.get(this.mainFrame().url()) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user