mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 6c2d23b1b5e4dc00c944eedd16a11850e74a2d11
This commit is contained in:
parent
ad83faa745
commit
0114122fe0
140 changed files with 4328 additions and 1419 deletions
|
@ -1,11 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="author" title="Anders Hartvoll Ruud" href="andruud@chromium.org">
|
||||
<!-- TODO(andruud): Add Typed OM details to spec and link to it here. -->
|
||||
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api-1/#supported-syntax-strings" />
|
||||
<link rel="help" href="https://github.com/w3c/css-houdini-drafts/pull/783" />
|
||||
<meta name="assert" content="Verifies that registered custom properties interact correctly with CSS Typed OM" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<style id=style>
|
||||
div {}
|
||||
</style>
|
||||
<div id=target></div>
|
||||
|
||||
<script>
|
||||
|
@ -43,7 +45,7 @@ function assert_computed_type(name, value, expected) {
|
|||
}
|
||||
|
||||
if (value != null) {
|
||||
target.attributeStyleMap.set(name, value);
|
||||
target.style = `${name}: ${value}`;
|
||||
}
|
||||
|
||||
let computedValue = target.computedStyleMap().get(name);
|
||||
|
@ -52,7 +54,7 @@ function assert_computed_type(name, value, expected) {
|
|||
assert_true(computedValue instanceof expected);
|
||||
|
||||
if (value != null) {
|
||||
target.attributeStyleMap.delete(name);
|
||||
target.style = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +179,7 @@ test(function(){
|
|||
assert_equals(target.computedStyleMap().getAll(name).length, 2);
|
||||
assert_true(target.computedStyleMap().getAll(name).every(x => x instanceof CSSUnitValue));
|
||||
|
||||
target.attributeStyleMap.set(name, '10px 20px 30px');
|
||||
target.style = `${name}: 10px 20px 30px`;
|
||||
assert_equals(target.computedStyleMap().getAll(name).length, 3);
|
||||
assert_true(target.computedStyleMap().getAll(name).every(x => x instanceof CSSUnitValue));
|
||||
}, 'All computed values correctly reified in space-separated list');
|
||||
|
@ -187,7 +189,7 @@ test(function(){
|
|||
assert_equals(target.computedStyleMap().getAll(name).length, 2);
|
||||
assert_true(target.computedStyleMap().getAll(name).every(x => x instanceof CSSUnitValue));
|
||||
|
||||
target.attributeStyleMap.set(name, '10px, 20px, 30px');
|
||||
target.style = `${name}: 10px, 20px, 30px`;
|
||||
assert_equals(target.computedStyleMap().getAll(name).length, 3);
|
||||
assert_true(target.computedStyleMap().getAll(name).every(x => x instanceof CSSUnitValue));
|
||||
}, 'All computed values correctly reified in comma-separated list');
|
||||
|
@ -285,7 +287,7 @@ test(function(){
|
|||
test(function(){
|
||||
let name = gen_prop('<length>+', '0px');
|
||||
target.attributeStyleMap.clear();
|
||||
target.attributeStyleMap.set(name, '10px 20px 30px');
|
||||
target.style = `${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>+');
|
||||
|
@ -293,9 +295,145 @@ test(function(){
|
|||
test(function(){
|
||||
let name = gen_prop('<length>#', '0px');
|
||||
target.attributeStyleMap.clear();
|
||||
target.attributeStyleMap.set(name, '10px, 20px, 30px');
|
||||
target.style = `${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>#');
|
||||
|
||||
// StylePropertyMap.set
|
||||
|
||||
function test_style_property_map_set_using_property_map(propertyMapName, propertyMap, options) {
|
||||
test(function(){
|
||||
let name = gen_prop(options.syntax, options.initialValue);
|
||||
propertyMap.clear();
|
||||
|
||||
for (let value of options.shouldAccept)
|
||||
propertyMap.set(name, value);
|
||||
|
||||
for (let value of options.shouldReject) {
|
||||
assert_throws(new TypeError(), () => propertyMap.set(name, value));
|
||||
}
|
||||
}, `${propertyMapName}.set accepts correct CSSUnitValues for ${options.syntax}`);
|
||||
}
|
||||
|
||||
// Verify that the correct CSSStyleValues are accepted/rejected for a registered
|
||||
// property with the specified syntax.
|
||||
//
|
||||
// The same test is performed twice: once for attributeStyleMap, and once
|
||||
// for styleMap.
|
||||
function test_style_property_map_set(options) {
|
||||
test_style_property_map_set_using_property_map('attributeStyleMap', target.attributeStyleMap, options);
|
||||
test_style_property_map_set_using_property_map('styleMap', style.sheet.rules[0].styleMap, options);
|
||||
}
|
||||
|
||||
let unparsed = x => new CSSUnparsedValue([x]);
|
||||
let keyword = x => new CSSKeywordValue(x);
|
||||
let sum = (a, b) => new CSSMathSum(a, b);
|
||||
let url_image = x => CSSStyleValue.parse('background-image', x);
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '*',
|
||||
initialValue: 'none',
|
||||
shouldAccept: [unparsed('thing')],
|
||||
shouldReject: [CSS.px(15), keyword('none')],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<angle>',
|
||||
initialValue: '0deg',
|
||||
shouldAccept: [CSS.deg(42), CSS.turn(2)],
|
||||
shouldReject: [unparsed('42deg'), CSS.px(15)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<custom-ident>',
|
||||
initialValue: 'none',
|
||||
shouldAccept: [keyword('foo')],
|
||||
shouldReject: [unparsed('foo'), CSS.px(15)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<image>',
|
||||
initialValue: 'url(a)',
|
||||
shouldAccept: [url_image('url(b)')],
|
||||
shouldReject: [unparsed('url(b)'), CSS.px(100)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<integer>',
|
||||
initialValue: '0',
|
||||
shouldAccept: [CSS.number(1), CSS.number(-42)],
|
||||
shouldReject: [unparsed('42'), CSS.px(100)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<length-percentage>',
|
||||
initialValue: '0px',
|
||||
shouldAccept: [CSS.percent(10), CSS.px(1), CSS.em(1)],
|
||||
shouldReject: [unparsed('10%'), unparsed('10px'), CSS.dpi(1)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<length>',
|
||||
initialValue: '0px',
|
||||
shouldAccept: [CSS.px(10), CSS.em(10), CSS.vh(200), sum(CSS.px(10), CSS.em(20))],
|
||||
shouldReject: [unparsed('10px'), CSS.percent(1)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<number>',
|
||||
initialValue: '0',
|
||||
shouldAccept: [CSS.number(1337), CSS.number(-42.5)],
|
||||
shouldReject: [unparsed('42'), CSS.px(15)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<percentage>',
|
||||
initialValue: '0%',
|
||||
shouldAccept: [CSS.percent(10)],
|
||||
shouldReject: [unparsed('10%'), CSS.px(1)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<resolution>',
|
||||
initialValue: '0dpi',
|
||||
shouldAccept: [CSS.dpi(100), CSS.dpcm(10), CSS.dppx(50)],
|
||||
shouldReject: [unparsed('42'), CSS.px(15)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<time>',
|
||||
initialValue: '0s',
|
||||
shouldAccept: [CSS.s(42), CSS.ms(16)],
|
||||
shouldReject: [unparsed('42s'), CSS.px(15)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<url>',
|
||||
initialValue: 'url(a)',
|
||||
shouldAccept: [url_image('url(b)')],
|
||||
shouldReject: [unparsed('url(b)'), CSS.px(100)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<transform-list>',
|
||||
initialValue: 'translateX(0px)',
|
||||
shouldAccept: [CSSStyleValue.parse('transform', 'translateX(10px)')],
|
||||
shouldReject: [unparsed('transformX(10px'), CSS.px(100)],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: 'none | thing | THING',
|
||||
initialValue: 'none',
|
||||
shouldAccept: [keyword('thing'), keyword('THING')],
|
||||
shouldReject: [unparsed('thing'), CSS.px(15), keyword('notathing')],
|
||||
});
|
||||
|
||||
test_style_property_map_set({
|
||||
syntax: '<angle> | <length>',
|
||||
initialValue: '0deg',
|
||||
shouldAccept: [CSS.deg(42), CSS.turn(2), CSS.px(10), CSS.em(10)],
|
||||
shouldReject: [unparsed('42deg'), unparsed('20px'), CSS.s(1)],
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue