mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update web-platform-tests to revision ac3d096a5972dea5ecca1c43e324086895db7c6f
This commit is contained in:
parent
1c74a80e28
commit
db54f176d0
47 changed files with 860 additions and 246 deletions
|
@ -6,22 +6,36 @@
|
|||
*
|
||||
* @param {string} property The name of the CSS property being tested.
|
||||
* @param {string} specified A specified value for the property.
|
||||
* @param {string} computed The expected computed value. If omitted,
|
||||
defaults to specified.
|
||||
* @param {string|array} computed The expected computed value,
|
||||
* or an array of permitted computed value.
|
||||
* If omitted, defaults to specified.
|
||||
*/
|
||||
function test_computed_value(property, specified, computed) {
|
||||
if (!computed)
|
||||
computed = specified;
|
||||
|
||||
let computedDesc = "'" + computed + "'";
|
||||
if (Array.isArray(computed))
|
||||
computedDesc = '[' + computed.map(e => "'" + e + "'").join(' or ') + ']';
|
||||
|
||||
test(() => {
|
||||
const target = document.getElementById('target');
|
||||
assert_true(property in getComputedStyle(target), property + " doesn't seem to be supported in the computed style");
|
||||
target.style[property] = '';
|
||||
target.style[property] = specified;
|
||||
assert_equals(getComputedStyle(target)[property], computed);
|
||||
if (computed !== specified) {
|
||||
target.style[property] = '';
|
||||
target.style[property] = computed;
|
||||
assert_equals(getComputedStyle(target)[property], computed, 'computed value should round-trip');
|
||||
|
||||
let readValue = getComputedStyle(target)[property];
|
||||
if (Array.isArray(computed)) {
|
||||
assert_in_array(readValue, computed);
|
||||
} else {
|
||||
assert_equals(readValue, computed);
|
||||
}
|
||||
}, "Property " + property + " value '" + specified + "' computes to '" + computed + "'");
|
||||
if (readValue !== specified) {
|
||||
target.style[property] = '';
|
||||
target.style[property] = readValue;
|
||||
assert_equals(getComputedStyle(target)[property], readValue,
|
||||
'computed value should round-trip');
|
||||
}
|
||||
}, "Property " + property + " value '" + specified + "' computes to " +
|
||||
computedDesc);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue