From 56a48559c20ad7f1ab95c12a811e5969f983c057 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 20 Dec 2019 15:30:12 -0800 Subject: [PATCH] fix(setContent): call window.stop() before setting new content (#323) This ensures that previous loading activity is suppressed and all network requests are canceled. --- src/frames.ts | 1 + test/navigation.spec.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/frames.ts b/src/frames.ts index 29eef40abd..40853ab7fb 100644 --- a/src/frames.ts +++ b/src/frames.ts @@ -431,6 +431,7 @@ export class Frame { if (this._page._delegate.needsLifecycleResetOnSetContent()) this._page._frameManager.frameLifecycleEvent(this._id, 'clear'); await context.evaluate(html => { + window.stop(); document.open(); document.write(html); document.close(); diff --git a/test/navigation.spec.js b/test/navigation.spec.js index aa0d45eb9f..af1c622f41 100644 --- a/test/navigation.spec.js +++ b/test/navigation.spec.js @@ -489,9 +489,9 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROME return page.setContent(``, { waitUntil: 'networkidle2' }); }, true); }); - xit('should wait for networkidle0 in setContent with request from previous navigation', async({page, server}) => { - // TODO: there are two issues here which combined fail the test: - // - setContent implementation does not cancel all outstanding requests; + it.skip(FFOX)('should wait for networkidle0 in setContent with request from previous navigation', async({page, server}) => { + // TODO: there are two issues here which combined fail the test in firefox: + // - calling window.stop() does not cancel all outstanding requests in firefox; // - we do not reset inflight request counter on lifecycle clear, so we wait for // the first request indefinitely. // Note that we cannot just reset inflight request counter, because the current navigation @@ -503,7 +503,7 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROME return page.setContent(``, { waitUntil: 'networkidle0' }); }, true); }); - xit('should wait for networkidle2 in setContent with request from previous navigation', async({page, server}) => { + it.skip(FFOX)('should wait for networkidle2 in setContent with request from previous navigation', async({page, server}) => { await page.goto(server.EMPTY_PAGE); server.setRoute('/foo.js', () => {}); await page.setContent(``);