OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <div id="testContainer"> |
| 5 <div id="outer"> |
| 6 <div id="inner"> |
| 7 <div id="innermost"></div> |
| 8 </div> |
| 9 </div> |
| 10 </div> |
| 11 <script> |
| 12 |
| 13 var independent_properties = [ |
| 14 // Property name, Value 1, Value 2 |
| 15 ["pointerEvents", "auto", "all"], |
| 16 ["visibility", "visible", "hidden"], |
| 17 ]; |
| 18 |
| 19 independent_properties.forEach(function(test_data) |
| 20 { |
| 21 var propertyName = test_data[0]; |
| 22 var value1 = test_data[1]; |
| 23 var value2 = test_data[2]; |
| 24 |
| 25 test(function(t) |
| 26 { |
| 27 if (!window.internals) |
| 28 assert_unreached('This test requires window.internals.'); |
| 29 |
| 30 // Create a nested div structure for the test. |
| 31 var outer = document.createElement("div"); |
| 32 var inner = document.createElement("div"); |
| 33 var innermost = document.createElement("div"); |
| 34 testContainer.appendChild(outer); |
| 35 outer.appendChild(inner); |
| 36 inner.appendChild(innermost); |
| 37 |
| 38 outer.offsetTop; // Force recalc. |
| 39 assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 0); |
| 40 |
| 41 // Set the whole container to the first value. |
| 42 testContainer.style[propertyName] = value1; |
| 43 |
| 44 // All elements start as the first value. |
| 45 assert_equals(getComputedStyle(outer)[propertyName], value1); |
| 46 assert_equals(getComputedStyle(inner)[propertyName], value1); |
| 47 assert_equals(getComputedStyle(innermost)[propertyName], value1); |
| 48 outer.offsetTop; // Force recalc. |
| 49 |
| 50 // Changing outer also changes inner and innermost. |
| 51 outer.style[propertyName] = value2; |
| 52 assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 1, "
Only outer should be recalced (3 without fast path)"); |
| 53 |
| 54 assert_equals(getComputedStyle(outer)[propertyName], value2); |
| 55 assert_equals(getComputedStyle(inner)[propertyName], value2); |
| 56 assert_equals(getComputedStyle(innermost)[propertyName], value2); |
| 57 outer.offsetTop; // Force recalc. |
| 58 |
| 59 // Changing inner to value1 changes all its children to that value. |
| 60 inner.style[propertyName] = value1; |
| 61 assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 1, "
Only inner should be recalced (2 without fast path)"); |
| 62 |
| 63 assert_equals(getComputedStyle(outer)[propertyName], value2); |
| 64 assert_equals(getComputedStyle(inner)[propertyName], value1); |
| 65 assert_equals(getComputedStyle(innermost)[propertyName], value1); |
| 66 outer.offsetTop; // Force recalc. |
| 67 |
| 68 // Clear for next test. |
| 69 outer.remove(); |
| 70 }, "Changing " + propertyName + ", an independent inherited property, propag
ates correctly with a single style recalc."); |
| 71 }) |
| 72 </script> |
OLD | NEW |