Skip to content

Commit

Permalink
fix(firefox): track frame detachment in navigation watchdog (puppetee…
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov authored and kiku-jw committed Apr 6, 2019
1 parent 0f43128 commit 5644350
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 5644350

Please sign in to comment.