<!DOCTYPEHTML>
<html>
<head>
<title>Test for bug 1359217</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body>
<iframe id="test"></iframe>
<pre id="log">
<script>
/**
* This test checks that getMatchingCSSRules returns correct style set in
* various cases. To avoid effects from UA sheets, most of the tests use
* an element with "unknowntagname".
*/
function* getStyleRules(elem) {
let rules = InspectorUtils.getMatchingCSSRules(elem);
for (let i = 0; i < rules.length; i++) {
yield rules[i];
}
}
// This will check that value of z-index property declarations in the
// rules from getMatchingCSSRules matches the given content.
function checkRules(doc, rulesContent, queryStr = "unknowntagname") {
let elem = doc.querySelector(queryStr);
let rules = [...getStyleRules(elem)];
is(rules.length, rulesContent.length, "Rule length should match");
if (rules.length != rulesContent.length) {
return;
}
for (let i = 0; i < rules.length; i++) {
let style = rules[i].style;
let expectation = rulesContent[i].toString();
is(style.length, 1, "Should contain only one declaration");
is(style.zIndex, expectation, "Should match expectation");
}
}
info("Inserting import rule");
sheet.insertRule("@import url(getMatchingCSSRules-2.css);", 0);
// There is no notification we can get when the associated style
// sheet gets loaded, so we have to query it.
while (true) {
try {
sheet.cssRules[0].styleSheet.cssRules;
break;
} catch (e) {
if (e.name == "InvalidAccessError") {
await new Promise(resolve => requestAnimationFrame(resolve));
} else {
throw e;
}
}
}
checkRules(doc, [2, 3, 5, 4]);
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 und die Messung sind noch experimentell.