From e0d4a5d2ec8d080d857dff5ed94ffd2cb3cded9f Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 14 Feb 2019 00:06:30 -0800 Subject: [PATCH] fix(firefox): track frame detachment in navigation watchdog (#4008) --- experimental/puppeteer-firefox/lib/NavigationWatchdog.js | 5 ++++- test/navigation.spec.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/experimental/puppeteer-firefox/lib/NavigationWatchdog.js b/experimental/puppeteer-firefox/lib/NavigationWatchdog.js index 321fe6ce..8eb8b20b 100644 --- a/experimental/puppeteer-firefox/lib/NavigationWatchdog.js +++ b/experimental/puppeteer-firefox/lib/NavigationWatchdog.js @@ -69,6 +69,7 @@ class NavigationWatchdog { helper.addEventListener(session, 'Page.navigationCommitted', check), helper.addEventListener(session, 'Page.navigationAborted', this._onNavigationAborted.bind(this)), helper.addEventListener(networkManager, Events.NetworkManager.Request, this._onRequest.bind(this)), + helper.addEventListener(navigatedFrame._frameManager, Events.FrameManager.FrameDetached, check), ]; check(); } @@ -84,7 +85,9 @@ class NavigationWatchdog { } _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)) { this._resolveCallback(null); } diff --git a/test/navigation.spec.js b/test/navigation.spec.js index b016a46e..99940dda 100644 --- a/test/navigation.spec.js +++ b/test/navigation.spec.js @@ -480,7 +480,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) { expect(response.ok()).toBe(true); 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'); server.setRoute('/empty.html', () => {}); @@ -533,7 +533,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) { expect(response.frame()).toBe(frame); 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'); const frame = page.frames()[1];