function make_rule_and_remove_sheet(text, getter) { varstyle = document.createElement("style"); style.setAttribute("type", "text/css"); style.appendChild(document.createTextNode(text));
document.head.appendChild(style); var result = style.sheet.cssRules[0];
if (getter) {
result = getter(result);
}
document.head.removeChild(style); style = null;
SpecialPowers.DOMWindowUtils.garbageCollect();
return result;
}
var gDisplayCS = getComputedStyle(document.getElementById("display"), "");
function keep_rule_alive_by_matching(rule) {
// It's the caller's job to guarantee that the rule matches a p.
// This just causes a style flush, which in turn keeps the rule alive
// until the next style flush. var color = gDisplayCS.color;
return rule;
}
function get_rule_and_child(rule) {
return [rule, rule.cssRules[0]];
}
function get_only_child(rule) {
return rule.cssRules[0];
}
var rule;
// In this case, the rule goes away immediately, so we're testing
// the DOM wrapper's handling of a null rule, rather than the rule's
// handling of a null sheet.
rule = make_rule_and_remove_sheet("p { color: blue }");
rule.style.color = "";
try {
rule.style.color = "fuchsia";
} catch(ex) {}
// In this case, the rule goes away immediately, so we're testing
// the DOM wrapper's handling of a null rule, rather than the rule's
// handling of a null sheet.
rule = make_rule_and_remove_sheet("@media screen { p { color: blue } }",
get_only_child);
rule.style.color = "";
try {
rule.style.color = "fuchsia";
} catch(ex) {}