From d025d1f959ef5193e1faae61244b87b5cd8850c3 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Tue, 16 Oct 2018 16:55:17 -0700 Subject: [PATCH] fix(csscoverage): don't prematurely disable the CSS domain (#3418) CSS stylesheets can still be parsed and added events emitted during the CSS.stopRuleUsageTracking call. It needs to be awaited before calling CSS.disable, otherwise the text content of those style sheets will be unavailable. --- lib/Coverage.js | 4 ++-- test/coverage.spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Coverage.js b/lib/Coverage.js index b6f30bc214c..fe38a83238c 100644 --- a/lib/Coverage.js +++ b/lib/Coverage.js @@ -224,8 +224,8 @@ class CSSCoverage { async stop() { assert(this._enabled, 'CSSCoverage is not enabled'); this._enabled = false; - const [ruleTrackingResponse] = await Promise.all([ - this._client.send('CSS.stopRuleUsageTracking'), + const ruleTrackingResponse = await this._client.send('CSS.stopRuleUsageTracking'); + await Promise.all([ this._client.send('CSS.disable'), this._client.send('DOM.disable'), ]); diff --git a/test/coverage.spec.js b/test/coverage.spec.js index 67fac609956..e62a3ae6d5a 100644 --- a/test/coverage.spec.js +++ b/test/coverage.spec.js @@ -189,7 +189,7 @@ module.exports.addTests = function({testRunner, expect}) { expect(coverage.length).toBe(0); }); }); - xit('should work with a recently loaded stylesheet', async function({page, server}) { + it('should work with a recently loaded stylesheet', async function({page, server}) { await page.coverage.startCSSCoverage(); await page.evaluate(async url => { document.body.textContent = 'hello, world';