Skip to content

Commit

Permalink
fix(firefox): track frame detachment in navigation watchdog (#4008)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Feb 14, 2019
1 parent 247733b commit e0d4a5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion experimental/puppeteer-firefox/lib/NavigationWatchdog.js
Expand Up @@ -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();
}
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions test/navigation.spec.js
Expand Up @@ -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', () => {});
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit e0d4a5d

Please sign in to comment.