// 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: () => {} });
ok(!applied[0].inherited, "Entry 0 should be uninherited");
is(applied[0].rule.type, 100, "Entry 0 should be an element style");
ok(!!applied[0].rule.href, "Element styles should have a URL");
is(applied[0].rule.cssText, "", "Entry 0 should be an empty style");
is(applied[1].inherited.id, "uninheritable-rule-inheritable-style", "Entry 1 should be inherited from the parent");
is(applied[1].rule.type, 100, "Entry 1 should be an element style");
is(applied[1].rule.cssText, "color: red;", "Entry 1 should have the expected cssText");
is(applied[2].inherited.id, "inheritable-rule-inheritable-style", "Entry 2 should be inherited from the parent's parent");
is(applied[2].rule.type, 100, "Entry 2 should be an element style");
is(applied[2].rule.cssText, "color: blue;", "Entry 2 should have the expected cssText");
is(applied[3].inherited.id, "inheritable-rule-inheritable-style", "Entry 3 should be inherited from the parent's parent");
is(applied[3].rule.type, 1, "Entry 3 should be a rule style");
is(applied[3].rule.cssText, "font-size: 15px;", "Entry 3 should have the expected cssText");
ok(!applied[3].matchedSelectorIndexes, "Shouldn't get matchedSelectorIndexes with this request.");
is(applied[4].inherited.id, "inheritable-rule-uninheritable-style", "Entry 4 should be inherited from the parent's parent");
is(applied[4].rule.type, 1, "Entry 4 should be an rule style");
is(applied[4].rule.cssText, "font-size: 15px;", "Entry 4 should have the expected cssText");
ok(!applied[4].matchedSelectorIndexes, "Shouldn't get matchedSelectorIndexes with this request.");
is(applied.length, 5, "Should have 5 rules.");
runNextTest();
});
addTest(async function inheritedSystemStyles() {
const node = await gWalker.querySelector(gWalker.rootNode, "#test-node");
const applied = await gStyles.getApplied(node, { inherited: true, filter: "ua" });
// If our system stylesheets are prone to churn, this might be a fragile
// test. If you're here because of that I apologize, file a bug
// and we can find a different way to test.
ok(!applied[1].inherited, "Entry 1 should not be inherited");
ok(applied[1].rule.parentStyleSheet.system, "Entry 1 should be a system style");
is(applied[1].rule.type, 1, "Entry 1 should be a rule style");
is(applied.length, 8, "Should have the expected number of rules.");
runNextTest();
});
addTest(async function noInheritedStyles() {
const node = await gWalker.querySelector(gWalker.rootNode, "#test-node")
const applied = await gStyles.getApplied(node, { inherited: false, filter: "user" });
ok(!applied[0].inherited, "Entry 0 should be uninherited");
is(applied[0].rule.type, 100, "Entry 0 should be an element style");
is(applied[0].rule.cssText, "", "Entry 0 should be an empty style");
is(applied.length, 1, "Should have 1 rule.");
runNextTest();
});
addTest(async function matchedSelectors() {
const node = await gWalker.querySelector(gWalker.rootNode, "#test-node");
const applied = await gStyles.getApplied(node, {
inherited: true, filter: "user", matchedSelectors: true,
});
Assert.deepEqual(applied[3].matchedSelectorIndexes, [0], "Entry 3 should have a matched selector");
Assert.deepEqual(applied[4].matchedSelectorIndexes, [0], "Entry 4 should have a matched selector");
runNextTest();
});
const ruleWithMedia = applied[1].rule;
is(ruleWithMedia.type, 1, "Entry 1 is a rule style");
is(ruleWithMedia.ancestorData[0].type, "media", "Entry 1's rule ancestor data holds the media rule data...");
is(ruleWithMedia.ancestorData[0].value, "screen", "...with the expected value");
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.