mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update web-platform-tests to revision 424249088dd679888e07bd315dd8ebc98ccf323a
This commit is contained in:
parent
4ad08fff04
commit
bca3835607
93 changed files with 1641 additions and 291 deletions
|
@ -40,3 +40,44 @@ function test_computed_value(property, specified, computed) {
|
|||
}, "Property " + property + " value '" + specified + "' computes to " +
|
||||
computedDesc);
|
||||
}
|
||||
|
||||
function test_pseudo_computed_value(pseudo, property, specified, computed) {
|
||||
if (!computed)
|
||||
computed = specified;
|
||||
|
||||
let computedDesc = "'" + computed + "'";
|
||||
if (Array.isArray(computed))
|
||||
computedDesc = '[' + computed.map(e => "'" + e + "'").join(' or ') + ']';
|
||||
|
||||
test(() => {
|
||||
assert_true(/^::\w+$/.test(pseudo), pseudo + " doesn't seem to be a pseudo-element");
|
||||
const styleElement = document.createElement("style");
|
||||
document.documentElement.appendChild(styleElement);
|
||||
try {
|
||||
const {sheet} = styleElement;
|
||||
sheet.insertRule("#target" + pseudo + "{}");
|
||||
const {style} = sheet.cssRules[0];
|
||||
const target = document.getElementById('target');
|
||||
|
||||
assert_true(property in getComputedStyle(target, pseudo), property + " doesn't seem to be supported in the computed style");
|
||||
assert_true(CSS.supports(property, specified), "'" + specified + "' is a supported value for " + property + ".");
|
||||
style[property] = specified;
|
||||
|
||||
let readValue = getComputedStyle(target, pseudo)[property];
|
||||
if (Array.isArray(computed)) {
|
||||
assert_in_array(readValue, computed);
|
||||
} else {
|
||||
assert_equals(readValue, computed);
|
||||
}
|
||||
if (readValue !== specified) {
|
||||
style[property] = '';
|
||||
style[property] = readValue;
|
||||
assert_equals(getComputedStyle(target, pseudo)[property], readValue,
|
||||
'computed value should round-trip');
|
||||
}
|
||||
} finally {
|
||||
document.documentElement.removeChild(styleElement);
|
||||
}
|
||||
}, "Property " + property + " value '" + specified + "' computes to " +
|
||||
computedDesc + " in " + pseudo);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue