// We need an active resource command before initializing the inspector front.
const resourceCommand = commands.resourceCommand;
// We listen to any random resource, we only need to trigger the resource command
// onTargetAvailable callback so the `resourceCommand` attribute is set on the target front.
await resourceCommand.watchResources([resourceCommand.TYPES.DOCUMENT_EVENT], { onAvailable: () => {} });
addTest(function testMatchedStyles() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#matched-test-node").then(node => {
return gStyles.getMatchedSelectors(node, "font-size", {});
}).then(matched => {
is(matched[0].sourceText, "this.style", "First match comes from the element style");
is(matched[0].selector, "@element.style", "Element style has a special selector");
is(matched[0].value, "10px", "First match has the expected value");
is(matched[0].status, CssLogic.STATUS.BEST, "First match is the best match");
is(matched[0].rule.type, 100, "First match is an element style");
is(matched[0].rule.href, gInspectee.defaultView.location.href, "Node style comes from this document");
is(matched[1].sourceText, ".column-rule", "Second match comes from a rule");
is(matched[1].selector, ".column-rule", "Second match comes from highest line number");
is(matched[1].value, "25px", "Second match comes from highest column");
is(matched[1].status, CssLogic.STATUS.PARENT_MATCH, "Second match is from the parent");
is(matched[1].rule.parentStyleSheet.href, null, "Inline stylesheet shouldn't have an href");
is(matched[1].rule.parentStyleSheet.nodeHref, gInspectee.defaultView.location.href, "Inline stylesheet's nodeHref should match the current document");
ok(!matched[1].rule.parentStyleSheet.system, "Inline stylesheet shouldn't be a system stylesheet.");
// matched[2] is only there to test matched[1]; do not need to test
is(matched[3].value, "15px", "Third match has the expected value");
}).then(runNextTest));
});
addTest(function testSystemStyles() {
let testNode = null;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#matched-test-node").then(node => {
testNode = node;
return gStyles.getMatchedSelectors(testNode, "display", { filter: "user" });
}).then(matched => {
is(matched.length, 0, "No user selectors apply to this rule.");
return gStyles.getMatchedSelectors(testNode, "display", { filter: "ua" });
}).then(matched => {
is(matched[0].selector, "div", "Should match system div selector");
is(matched[0].value, "block");
}).then(runNextTest));
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.