зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1567164 - Ensure StyleRuleActor.getRuleText() returns text content of minified CSS. r=gl
The patch for Bug 724505 changed the return of `prettifyCSS()` from a string to an object and the reference in the StyleRuleActor.getRuleText() was not updated. This patch fixes this and introduces a test. Differential Revision: https://phabricator.services.mozilla.com/D38673 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b768462da1
Коммит
6bd3a34df5
|
@ -1595,8 +1595,8 @@ var StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
text = `${selectorText} {${ruleBodyText}}`;
|
||||
}
|
||||
|
||||
const prettyCSS = prettifyCSS(text);
|
||||
return Promise.resolve(prettyCSS);
|
||||
const { result } = prettifyCSS(text);
|
||||
return Promise.resolve(result);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -138,6 +138,7 @@ fail-if = fission
|
|||
fail-if = fission
|
||||
[browser_storage_updates.js]
|
||||
fail-if = fission
|
||||
[browser_styles_getRuleText.js]
|
||||
[browser_stylesheets_getTextEmpty.js]
|
||||
[browser_stylesheets_nested-iframes.js]
|
||||
[browser_register_actor.js]
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test that StyleRuleActor.getRuleText returns the contents of the CSS rule.
|
||||
|
||||
const CSS_RULE = `#test {
|
||||
background-color: #f06;
|
||||
}`;
|
||||
|
||||
const CONTENT = `
|
||||
<style type='text/css'>
|
||||
${CSS_RULE}
|
||||
</style>
|
||||
<div id="test"></div>
|
||||
`;
|
||||
|
||||
const TEST_URI = `data:text/html;charset=utf-8,${encodeURIComponent(CONTENT)}`;
|
||||
|
||||
add_task(async function() {
|
||||
const { inspector, target, walker } = await initInspectorFront(TEST_URI);
|
||||
|
||||
const pageStyle = await inspector.getPageStyle();
|
||||
const element = await walker.querySelector(walker.rootNode, "#test");
|
||||
const entries = await pageStyle.getApplied(element, { inherited: false });
|
||||
|
||||
const rule = entries[1].rule;
|
||||
const text = await rule.getRuleText();
|
||||
|
||||
is(text, CSS_RULE, "CSS rule text content matches");
|
||||
|
||||
await target.destroy();
|
||||
});
|
Загрузка…
Ссылка в новой задаче