2 <title>Test that the difference of the computed style of an element is always correctly propagated
</title>
4 There are CSS property changes that don't have an effect in computed style.
6 It's relatively easy to return `nsChangeHint(0)` for the case where the
7 property changes but it should have no rendering difference.
9 That's however incorrect, since if it's an inherited property, or a
10 descendant explicitly inherits it, we should still propagate the change
13 This test tests that computed style diffing is correct.
15 <script src=
"/resources/testharness.js"></script>
16 <script src=
"/resources/testharnessreport.js"></script>
17 <script src=
"property_database.js"></script>
19 <div id=
"inner"></div>
22 // We need to skip checking for properties for which the value returned by
23 // getComputedStyle depends on the parent.
25 // TODO(emilio): We could test a subset of these, see below.
27 // Could test display values that don't force blockification of children.
30 // Could avoid testing only the ones that have percentages.
40 "padding-inline-start",
42 "padding-block-start",
49 "margin-inline-start",
64 const outer
= document
.getElementById("outer");
65 const inner
= document
.getElementById("inner");
67 function testValue(prop
, value
) {
68 outer
.style
.setProperty(prop
, value
);
69 const computed
= getComputedStyle(outer
).getPropertyValue(prop
);
71 getComputedStyle(inner
).getPropertyValue(prop
), computed
,
72 "Didn't handle the inherited change correctly?"
76 // Note that we intentionally ignore the "prerequisites" here, since that's
77 // the most likely place where the diffing could potentially go wrong.
78 function testProperty(prop
, info
) {
79 // We only care about longhands, changing shorthands is not that interesting,
80 // since we're interested of changing as little as possible, and changing
81 // them would be equivalent to changing all the longhands at the same time.
82 if (info
.type
!== CSS_TYPE_LONGHAND
)
84 if (kWhitelist
.includes(prop
))
87 inner
.style
.setProperty(prop
, "inherit");
88 for (const v
of info
.initial_values
)
90 for (const v
of info
.other_values
)
92 // Test again the first value so that we test changing to it, not just from
95 // TODO(emilio): We could test every value against every-value if we wanted,
97 testValue(prop
, info
.initial_values
[0]);
99 inner
.style
.removeProperty(prop
);
102 for (let prop
in gCSSProperties
)
103 test(() => testProperty(prop
, gCSSProperties
[prop
]), "Diffing for " + prop
);