mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
Update web-platform-tests to revision c792ea26624bde49b72afce348de07ab72fb9ad7
This commit is contained in:
parent
e051c5880e
commit
ca45711d07
178 changed files with 2163 additions and 1807 deletions
|
@ -13,16 +13,22 @@
|
|||
// Properties are generated on demand, as `--prop-${g_counter}`.
|
||||
let g_counter = 1;
|
||||
|
||||
// Generate a new property name.
|
||||
function gen_name() {
|
||||
let name = `--prop-${g_counter}`;
|
||||
g_counter++;
|
||||
return name;
|
||||
}
|
||||
|
||||
// Generate a property and return its name.
|
||||
function gen_prop(syntax, initialValue) {
|
||||
let name = `--prop-${g_counter}`;
|
||||
let name = gen_name();
|
||||
CSS.registerProperty({
|
||||
name: name,
|
||||
syntax: syntax,
|
||||
initialValue: initialValue,
|
||||
inherits: false
|
||||
});
|
||||
g_counter++;
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -50,6 +56,28 @@ function assert_computed_type(name, value, expected) {
|
|||
}
|
||||
}
|
||||
|
||||
function assert_attribute_get_type(syntax, value, expected) {
|
||||
let name = gen_name();
|
||||
target.style = `${name}: ${value}`;
|
||||
|
||||
assert_true(target.attributeStyleMap.get(name) instanceof CSSUnparsedValue);
|
||||
|
||||
CSS.registerProperty({
|
||||
name: name,
|
||||
syntax: syntax,
|
||||
initialValue: value,
|
||||
inherits: false
|
||||
});
|
||||
|
||||
if (expected == CSSStyleValue) {
|
||||
assert_false(target.attributeStyleMap.get(name) instanceof CSSUnparsedValue);
|
||||
}
|
||||
|
||||
assert_true(target.attributeStyleMap.get(name) instanceof expected);
|
||||
}
|
||||
|
||||
// computedStyleMap
|
||||
|
||||
test(function(){
|
||||
let name = gen_prop('*', 'if(){}');
|
||||
assert_true(target.computedStyleMap().get(name) instanceof CSSUnparsedValue);
|
||||
|
@ -164,4 +192,110 @@ test(function(){
|
|||
assert_true(target.computedStyleMap().getAll(name).every(x => x instanceof CSSUnitValue));
|
||||
}, 'All computed values correctly reified in comma-separated list');
|
||||
|
||||
// attributeStyleMap.get
|
||||
|
||||
test(function(){
|
||||
let name1 = gen_prop('<length>', '100px');
|
||||
let name2 = gen_prop('<length>', '0px');
|
||||
target.style = `${name2}: var(${name1})`;
|
||||
assert_true(target.attributeStyleMap.get(name2) instanceof CSSUnparsedValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnparsedValue for value with var references');
|
||||
|
||||
test(function(){
|
||||
let name1 = gen_prop('<length>', '100px');
|
||||
let name2 = gen_prop('<length>#', '0px');
|
||||
target.style = `${name2}: 1px, var(${name1}), 3px`;
|
||||
assert_true(target.attributeStyleMap.get(name2) instanceof CSSUnparsedValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnparsedValue for value with var reference in list');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('*', 'if(){}', CSSUnparsedValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnparsedValue for *');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<angle>', '42deg', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <angle>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<color>', '#fefefe', CSSStyleValue);
|
||||
}, 'attributeStyleMap.get returns CSSStyleValue for <color>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<custom-ident>', 'none', CSSKeywordValue);
|
||||
}, 'attributeStyleMap.get returns CSSKeywordValue for <custom-ident>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<image>', 'url(thing.png)', CSSImageValue);
|
||||
}, 'attributeStyleMap.get returns CSSImageValue for <image>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<integer>', '100', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <integer>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<length-percentage>', '10%', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <length-percentage> [10%]');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<length-percentage>', '10px', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <length-percentage> [10px]');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<length-percentage>', 'calc(10px + 10%)', CSSMathSum);
|
||||
}, 'attributeStyleMap.get returns CSSMathSum for <length-percentage> [calc(10px + 10%)]');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<length>', '10px', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <length>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<number>', '42', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <number>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<percentage>', '10%', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <percentage>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<resolution>', '300dpi', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <resolution>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<time>', '42s', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <time>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<url>', 'url(a)', CSSStyleValue);
|
||||
}, 'attributeStyleMap.get returns CSSStyleValue for <url>');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('thing1 | THING2', 'thing1', CSSKeywordValue);
|
||||
}, 'attributeStyleMap.get returns CSSKeywordValue for thing1 | THING2');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<length>+', '10px 20px', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <length>+');
|
||||
|
||||
test(function(){
|
||||
assert_attribute_get_type('<length>#', '10px 20px', CSSUnitValue);
|
||||
}, 'attributeStyleMap.get returns CSSUnitValue for <length>#');
|
||||
|
||||
// attributeStyleMap.getAll
|
||||
|
||||
test(function(){
|
||||
let name = gen_prop('<length>+', '0px');
|
||||
target.attributeStyleMap.clear();
|
||||
target.attributeStyleMap.set(name, '10px 20px 30px');
|
||||
assert_equals(target.attributeStyleMap.getAll(name).length, 3);
|
||||
assert_true(target.attributeStyleMap.getAll(name).every(x => x instanceof CSSUnitValue));
|
||||
}, 'attributeStyleMap.getAll returns a list of CSSUnitValues for <length>+');
|
||||
|
||||
test(function(){
|
||||
let name = gen_prop('<length>#', '0px');
|
||||
target.attributeStyleMap.clear();
|
||||
target.attributeStyleMap.set(name, '10px, 20px, 30px');
|
||||
assert_equals(target.attributeStyleMap.getAll(name).length, 3);
|
||||
assert_true(target.attributeStyleMap.getAll(name).every(x => x instanceof CSSUnitValue));
|
||||
}, 'attributeStyleMap.getAll returns a list of CSSUnitValues for <length>#');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -22,6 +22,10 @@ div {
|
|||
--registered-token-stream-1:var(--invalid);
|
||||
--registered-token-stream-2:var(--invalid,fallback);
|
||||
--token-stream-1:var(--registered-token-stream-1,moo);
|
||||
|
||||
--registered-length-list-1: 1px, var(--registered-length-1), 2px;
|
||||
--registered-length-list-2: 1px, var(--length-1), var(--registered-length-1), 2px;
|
||||
--registered-length-list-3: var(--registered-length-list-1), var(--registered-length-list-2);
|
||||
}
|
||||
</style>
|
||||
<div id=element></div>
|
||||
|
@ -58,4 +62,39 @@ test(function() {
|
|||
assert_equals(computedStyle.getPropertyValue('--registered-token-stream-2'), 'fallback');
|
||||
assert_equals(computedStyle.getPropertyValue('--token-stream-1'), 'moo');
|
||||
}, "var() references work with registered properties");
|
||||
|
||||
test(function(){
|
||||
CSS.registerProperty({
|
||||
name: '--registered-length-list-1',
|
||||
syntax: '<length>#',
|
||||
initialValue: '0px',
|
||||
inherits: false
|
||||
});
|
||||
let computedStyle = getComputedStyle(element);
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-length-list-1'), '1px, 10px, 2px');
|
||||
}, 'References to registered var()-properties work in registered lists');
|
||||
|
||||
test(function(){
|
||||
CSS.registerProperty({
|
||||
name: '--registered-length-list-2',
|
||||
syntax: '<length>#',
|
||||
initialValue: '0px',
|
||||
inherits: false
|
||||
});
|
||||
let computedStyle = getComputedStyle(element);
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-length-list-2'), '1px, 20px, 10px, 2px');
|
||||
}, 'References to mixed registered and unregistered var()-properties work in registered lists');
|
||||
|
||||
test(function(){
|
||||
CSS.registerProperty({
|
||||
name: '--registered-length-list-3',
|
||||
syntax: '<length>#',
|
||||
initialValue: '0px',
|
||||
inherits: false
|
||||
});
|
||||
let computedStyle = getComputedStyle(element);
|
||||
assert_equals(computedStyle.getPropertyValue('--registered-length-list-3'), '1px, 10px, 2px, 1px, 20px, 10px, 2px');
|
||||
}, 'Registered lists may be concatenated');
|
||||
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue