4 https://bugzilla.mozilla.org/show_bug.cgi?id=634373
7 <title>Test for Bug
634373</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=634373">Mozilla Bug
634373</a>
14 <div id=
"content" style=
"display: none">
18 <script type=
"application/javascript">
20 /** Test for Bug
634373 **/
22 function make_rule_and_remove_sheet(text, getter) {
23 var style = document.createElement(
"style");
24 style.setAttribute(
"type",
"text/css");
25 style.appendChild(document.createTextNode(text));
26 document.head.appendChild(style);
27 var result = style.sheet.cssRules[
0];
29 result = getter(result);
31 document.head.removeChild(style);
33 SpecialPowers.DOMWindowUtils.garbageCollect();
37 var gDisplayCS = getComputedStyle(document.getElementById(
"display"),
"");
39 function keep_rule_alive_by_matching(rule) {
40 // It's the caller's job to guarantee that the rule matches a p.
41 // This just causes a style flush, which in turn keeps the rule alive
42 // until the next style flush.
43 var color = gDisplayCS.color;
47 function get_rule_and_child(rule) {
48 return [rule, rule.cssRules[
0]];
51 function get_only_child(rule) {
52 return rule.cssRules[
0];
57 // In this case, the rule goes away immediately, so we're testing
58 // the DOM wrapper's handling of a null rule, rather than the rule's
59 // handling of a null sheet.
60 rule = make_rule_and_remove_sheet(
"p { color: blue }");
61 rule.style.color =
"";
63 rule.style.color =
"fuchsia";
66 rule = make_rule_and_remove_sheet(
"p { color: blue }",
67 keep_rule_alive_by_matching);
69 rule.style.color =
"";
72 rule.style.color =
"fuchsia";
75 rule = make_rule_and_remove_sheet(
"@media screen { p { color: blue } }",
77 rule[
1].style.color =
"";
79 rule[
1].style.color =
"fuchsia";
82 // In this case, the rule goes away immediately, so we're testing
83 // the DOM wrapper's handling of a null rule, rather than the rule's
84 // handling of a null sheet.
85 rule = make_rule_and_remove_sheet(
"@media screen { p { color: blue } }",
87 rule.style.color =
"";
89 rule.style.color =
"fuchsia";
92 rule = make_rule_and_remove_sheet(
"@media screen { p { color: blue } }",
94 return keep_rule_alive_by_matching(
95 get_only_child(ruleInner));
98 rule.style.color =
"";
101 rule.style.color =
"fuchsia";
104 rule = make_rule_and_remove_sheet(
"@keyframes a { from { color: blue } }");
105 rule.appendRule(
"from { color: fuchsia}");
106 rule.deleteRule(
"from");
108 rule.cssRules[
0].keyText =
"50%";
110 ok(true,
"didn't crash");