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.
This commit is contained in:
Joel Einbinder 2018-10-16 16:55:17 -07:00 committed by Andrey Lushnikov
parent a4cebd8e6a
commit d025d1f959
2 changed files with 3 additions and 3 deletions

View File

@ -224,8 +224,8 @@ class CSSCoverage {
async stop() { async stop() {
assert(this._enabled, 'CSSCoverage is not enabled'); assert(this._enabled, 'CSSCoverage is not enabled');
this._enabled = false; this._enabled = false;
const [ruleTrackingResponse] = await Promise.all([ const ruleTrackingResponse = await this._client.send('CSS.stopRuleUsageTracking');
this._client.send('CSS.stopRuleUsageTracking'), await Promise.all([
this._client.send('CSS.disable'), this._client.send('CSS.disable'),
this._client.send('DOM.disable'), this._client.send('DOM.disable'),
]); ]);

View File

@ -189,7 +189,7 @@ module.exports.addTests = function({testRunner, expect}) {
expect(coverage.length).toBe(0); 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.coverage.startCSSCoverage();
await page.evaluate(async url => { await page.evaluate(async url => {
document.body.textContent = 'hello, world'; document.body.textContent = 'hello, world';