| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <head> | 2 <head> |
| 3 <style id="thestyle"></style> | 3 <style id="thestyle"></style> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <div><!-- Extra divs so it's clear when we're doing a full document recalc --> | 6 <div><!-- Extra divs so it's clear when we're doing a full document recalc --> |
| 7 <div></div> | 7 <div></div> |
| 8 <div></div> | 8 <div></div> |
| 9 <div></div> | 9 <div></div> |
| 10 <div></div> | 10 <div></div> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 function forceRecalc() | 30 function forceRecalc() |
| 31 { | 31 { |
| 32 document.documentElement.offsetTop; | 32 document.documentElement.offsetTop; |
| 33 } | 33 } |
| 34 | 34 |
| 35 if (window.internals) { | 35 if (window.internals) { |
| 36 // Add non-existant classname. | 36 // Add non-existant classname. |
| 37 forceRecalc(); | 37 forceRecalc(); |
| 38 sheet.textContent = ".nonexistant { color: red; }"; | 38 sheet.textContent = ".nonexistant { color: red; }"; |
| 39 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1"); | 39 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "0"); |
| 40 | 40 |
| 41 // Add two existing classnames. | 41 // Add two existing classnames. |
| 42 forceRecalc(); | 42 forceRecalc(); |
| 43 sheet.textContent = ".bar { color: red; }\n.baz { color: red; }"; | 43 sheet.textContent = ".bar { color: red; }\n.baz { color: red; }"; |
| 44 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "7"); | 44 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "6"); |
| 45 | 45 |
| 46 // Remove the classnames from the previous step. | 46 // Remove the classnames from the previous step. |
| 47 forceRecalc(); | 47 forceRecalc(); |
| 48 sheet.textContent = ""; | 48 sheet.textContent = ""; |
| 49 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "7"); | 49 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "6"); |
| 50 | 50 |
| 51 // Test innerHTML. | 51 // Test innerHTML. |
| 52 forceRecalc(); | 52 forceRecalc(); |
| 53 sheet.innerHTML = ".bar { color: red; }\n.baz { color: red; }"; | 53 sheet.innerHTML = ".bar { color: red; }\n.baz { color: red; }"; |
| 54 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "7"); | 54 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "6"); |
| 55 | 55 |
| 56 // Test deleteRule | 56 // Test deleteRule |
| 57 forceRecalc(); | 57 forceRecalc(); |
| 58 sheet.sheet.deleteRule(0); // Deletes .bar rule. | 58 sheet.sheet.deleteRule(0); // Deletes .bar rule. |
| 59 // FIXME: Ideally we'd do StyleInvalidationAnalysis here and only recalc 3 b
ar's, 3 baz's + documentElement | 59 // FIXME: Ideally we'd do StyleInvalidationAnalysis here and only recalc 3 b
ar's, 3 baz's + documentElement |
| 60 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "44"); | 60 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "43"); |
| 61 | 61 |
| 62 shouldBe("getComputedStyle(document.querySelector('.foo')).color", '"rgb(0,
0, 0)"'); | 62 shouldBe("getComputedStyle(document.querySelector('.foo')).color", '"rgb(0,
0, 0)"'); |
| 63 shouldBe("getComputedStyle(document.querySelector('.baz')).color", '"rgb(255
, 0, 0)"'); | 63 shouldBe("getComputedStyle(document.querySelector('.baz')).color", '"rgb(255
, 0, 0)"'); |
| 64 shouldBe("getComputedStyle(document.querySelector('.bar')).color", '"rgb(0,
0, 0)"'); | 64 shouldBe("getComputedStyle(document.querySelector('.bar')).color", '"rgb(0,
0, 0)"'); |
| 65 | 65 |
| 66 // Test insertRule | 66 // Test insertRule |
| 67 forceRecalc(); | 67 forceRecalc(); |
| 68 sheet.sheet.insertRule(".foo { color: red; }", 0); | 68 sheet.sheet.insertRule(".foo { color: red; }", 0); |
| 69 // FIXME: Ideally we'd do StyleInvalidationAnalysis here and only recalc 3 f
oo's, 3 baz's + documentElement | 69 // FIXME: Ideally we'd do StyleInvalidationAnalysis here and only recalc 3 f
oo's, 3 baz's + documentElement |
| 70 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "60"); | 70 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "59"); |
| 71 | 71 |
| 72 shouldBe("getComputedStyle(document.querySelector('.foo')).color", '"rgb(255
, 0, 0)"'); | 72 shouldBe("getComputedStyle(document.querySelector('.foo')).color", '"rgb(255
, 0, 0)"'); |
| 73 shouldBe("getComputedStyle(document.querySelector('.baz')).color", '"rgb(255
, 0, 0)"'); | 73 shouldBe("getComputedStyle(document.querySelector('.baz')).color", '"rgb(255
, 0, 0)"'); |
| 74 shouldBe("getComputedStyle(document.querySelector('.bar')).color", '"rgb(0,
0, 0)"'); | 74 shouldBe("getComputedStyle(document.querySelector('.bar')).color", '"rgb(0,
0, 0)"'); |
| 75 | 75 |
| 76 } | 76 } |
| 77 </script> | 77 </script> |
| OLD | NEW |