fix(firefox): track frame detachment in navigation watchdog (#4008)

This commit is contained in:
Andrey Lushnikov 2019-02-14 00:06:30 -08:00 committed by GitHub
parent 247733b879
commit e0d4a5d2ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -69,6 +69,7 @@ class NavigationWatchdog {
helper.addEventListener(session, 'Page.navigationCommitted', check), helper.addEventListener(session, 'Page.navigationCommitted', check),
helper.addEventListener(session, 'Page.navigationAborted', this._onNavigationAborted.bind(this)), helper.addEventListener(session, 'Page.navigationAborted', this._onNavigationAborted.bind(this)),
helper.addEventListener(networkManager, Events.NetworkManager.Request, this._onRequest.bind(this)), helper.addEventListener(networkManager, Events.NetworkManager.Request, this._onRequest.bind(this)),
helper.addEventListener(navigatedFrame._frameManager, Events.FrameManager.FrameDetached, check),
]; ];
check(); check();
} }
@ -84,7 +85,9 @@ class NavigationWatchdog {
} }
_checkNavigationComplete() { _checkNavigationComplete() {
if (this._navigatedFrame._lastCommittedNavigationId === this._targetNavigationId if (this._navigatedFrame.isDetached()) {
this._resolveCallback(new Error('Navigating frame was detached'));
} else if (this._navigatedFrame._lastCommittedNavigationId === this._targetNavigationId
&& checkFiredEvents(this._navigatedFrame, this._firedEvents)) { && checkFiredEvents(this._navigatedFrame, this._firedEvents)) {
this._resolveCallback(null); this._resolveCallback(null);
} }

View File

@ -480,7 +480,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
expect(response.ok()).toBe(true); expect(response.ok()).toBe(true);
expect(response.frame()).toBe(page.frames()[1]); expect(response.frame()).toBe(page.frames()[1]);
}); });
it_fails_ffox('should reject when frame detaches', async({page, server}) => { it('should reject when frame detaches', async({page, server}) => {
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');
server.setRoute('/empty.html', () => {}); server.setRoute('/empty.html', () => {});
@ -533,7 +533,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
expect(response.frame()).toBe(frame); expect(response.frame()).toBe(frame);
expect(page.url()).toContain('/frames/one-frame.html'); expect(page.url()).toContain('/frames/one-frame.html');
}); });
it_fails_ffox('should reject when frame detaches', async({page, server}) => { it_fails_ffox('should resolve when frame detaches', async({page, server}) => {
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');
const frame = page.frames()[1]; const frame = page.frames()[1];