Update web-platform-tests to revision 8fed98324bc133df221d778c62cbff210d43b0ce

This commit is contained in:
WPT Sync Bot 2018-02-19 20:08:38 -05:00
parent be902d56c0
commit 8a6476740e
246 changed files with 15482 additions and 1281 deletions

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<title>Zero width floats</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visudet.html#float-width" title="10.3.5 Floating, non-replaced elements">
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="margin-left:50px; width:100px;">
<div style="float:left; width:0; height:50px;"></div>
<div style="float:right; clear:left; width:0; height:150px;"></div>
<div style="overflow:hidden; margin:0 -50px; height:100px; background:green;"></div>
</div>
<div style="position:relative; top:-100px; overflow:hidden; clear:both; width:200px; height:100px; background:green;"></div>

View file

@ -0,0 +1,19 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS Test: font shorthand serialization</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="help" href="https://drafts.csswg.org/css-fonts-4/#propdef-font">
<link rel="help" href="https://drafts.csswg.org/cssom/">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/1564">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1436031">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div style="font: bold medium serif"></div>
<script>
test(function() {
assert_equals(
document.querySelector('div').style.font, "bold medium serif",
"Default values of the longhands don't get serialized on the font shorthand"
);
}, "Default values of the longhands don't get serialized on the font shorthand");
</script>

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<style>
.container {
position: relative;
margin: 20px 0;
width: 200px;
height: 200px;
border: solid 2px;
}
.result {
position: absolute;
background: green;
}
</style>
<div class="container">
<div class="result" style="width: 100px; height: 100px; bottom: 0px;"></div>
</div>
<div class="container">
<div class="result" style="width: 100px; height: 200px;"></div>
</div>
<div class="container">
<div class="result" style="width: 100px; height: 100px;"></div>
</div>
<div class="container">
<div class="result" style="width: 200px; height: 100px;"></div>
</div>

View file

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#interaction-sizing">
<link rel="match" href="auto-block-size-absolute-ref.html">
<meta name="assert" content="This test checks that the absolute positioning respects the auto-block-size." />
<style>
.test {
position: absolute;
background: red;
}
@supports (display: layout(block-size-100)) {
.test {
display: layout(block-size-100);
background: green;
}
}
.container {
position: relative;
margin: 20px 0;
width: 200px;
height: 200px;
border: solid 2px;
}
.width-100 {
width: 100px;
writing-mode: horizontal-tb;
}
.height-100 {
height: 100px;
writing-mode: vertical-rl;
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<!-- 100px x 100px, bottom-left -->
<div class="container">
<div class="test width-100" style="bottom: 0px"></div>
</div>
<!-- 100px x 200px, left, auto-size is ignored. -->
<div class="container">
<div class="test width-100" style="top: 0px; bottom: 0px"></div>
</div>
<!-- 100px x 100px, top-left -->
<div class="container">
<div class="test height-100" style="left: 0px;"></div>
</div>
<!-- 100px x 100px, top, auto-size is ignored. -->
<div class="container">
<div class="test height-100" style="left: 0px; right: 0px;"></div>
</div>
<script id="code" type="text/worklet">
registerLayout('block-size-100', class {
*intrinsicSizes() {}
*layout() {
return {autoBlockSize: 100};
}
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
</script>
</html>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<style>
.container {
border: solid 2px;
display: flow-root;
width: 300px;
}
.child {
background: green;
border: solid 2px;
box-sizing: border-box;
float: left;
height: 100px;
}
</style>
<div class="container">
<div class="child" style="width: 100px;"></div>
<div class="child" style="width: 200px;"></div>
</div>

View file

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#interaction-sizing">
<link rel="match" href="auto-block-size-flex-ref.html">
<meta name="assert" content="This test checks that the flex layout respects the auto-block-size." />
<style>
.flex {
width: 300px;
display: flex;
border: solid 2px;
}
.custom {
background: red;
box-sizing: border-box;
border: solid 2px;
height: 100px;
writing-mode: vertical-rl;
}
@supports (display: layout(block-size-100)) {
.custom-100 {
display: layout(block-size-100);
background: green;
}
.custom-50 {
display: layout(block-size-50);
background: green;
flex: 1;
}
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<!-- Tests that floats using an auto block size get positioned correctly. -->
<div class="flex">
<div class="custom custom-100"></div>
<div class="custom custom-50"></div>
</div>
<script id="code" type="text/worklet">
registerLayout('block-size-100', class {
*intrinsicSizes() {}
*layout() {
return {autoBlockSize: 100};
}
});
registerLayout('block-size-50', class {
*intrinsicSizes() {}
*layout() {
return {autoBlockSize: 50};
}
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
</script>
</html>

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<style>
.container {
width: 150px;
border: solid 2px;
}
.left {
float: left;
background: green;
width: 100px;
height: 100px;
}
.right {
float: right;
background: green;
width: 100px;
height: 100px;
}
</style>
<div class="container">
<div class="left"></div>
<div class="right"></div>
</div>

View file

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#interaction-sizing">
<link rel="match" href="auto-block-size-floats-ref.html">
<meta name="assert" content="This test checks that if the layout() is a float, the flow layout respects the auto-block-size." />
<style>
.test {
background: red;
}
@supports (display: layout(block-size-100)) {
.test {
display: layout(block-size-100);
background: green;
}
}
.container {
width: 150px;
border: solid 2px;
}
.left {
float: left;
width: 100px;
writing-mode: horizontal-tb;
}
.right {
float: right;
height: 100px;
writing-mode: vertical-rl;
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<!-- Tests that floats using an auto block size get positioned correctly. -->
<div class="container">
<div class="left test"></div>
<div class="right test"></div>
</div>
<script id="code" type="text/worklet">
registerLayout('block-size-100', class {
*intrinsicSizes() {}
*layout() {
return {autoBlockSize: 100};
}
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
</script>
</html>

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<style>
.result {
margin: 20px 0;
background: green;
}
</style>
<div class="result" style="width: 100px; height: 100px;"></div>
<div class="result" style="width: 100px; height: 150px;"></div>
<div class="result" style="width: 100px; height: 50px;"></div>
<div class="result" style="width: 100px; height: 100px;"></div>
<div class="result" style="width: 150px; height: 100px;"></div>
<div class="result" style="width: 50px; height: 100px;"></div>

View file

@ -0,0 +1,63 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#interaction-sizing">
<link rel="match" href="auto-block-size-inflow-ref.html">
<meta name="assert" content="This test checks that min/max-block-size constraints are applied correctly to a layout()." />
<style>
.test {
margin: 20px 0;
background: red;
}
@supports (display: layout(block-size-100)) {
.test {
display: layout(block-size-100);
background: green;
}
}
.width-100 {
width: 100px;
writing-mode: horizontal-tb;
}
.height-100 {
height: 100px;
writing-mode: vertical-rl;
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<!-- 100px x 100px -->
<div class="test width-100"></div>
<!-- 100px x 150px -->
<div class="test width-100" style="min-height: 150px"></div>
<!-- 100px x 50px -->
<div class="test width-100" style="max-height: 50px"></div>
<!-- 100px x 100px -->
<div class="test height-100"></div>
<!-- 150px x 100px -->
<div class="test height-100" style="min-width: 150px"></div>
<!-- 50px x 100px -->
<div class="test height-100" style="max-width: 50px"></div>
<script id="code" type="text/worklet">
registerLayout('block-size-100', class {
*intrinsicSizes() {}
*layout() {
return {autoBlockSize: 100};
}
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
</script>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<style>
.result {
background: green;
border: solid 2px;
margin: 20px 0;
}
</style>
<div class="result" style="width: 100px; height: 0px;"></div>
<div class="result" style="width: 0px; height: 100px;"></div>

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#interaction-sizing">
<link rel="match" href="auto-block-size-negative-ref.html">
<meta name="assert" content="This test checks that auto-block-size is correctly clamped to zero." />
<meta name="assert" content="TODO" />
<style>
.test {
background: red;
border: solid 2px;
margin: 20px 0;
}
.width-100 {
width: 100px;
writing-mode: horizontal-tb;
}
.height-100 {
height: 100px;
writing-mode: vertical-rl;
}
@supports (display: layout(block-size-negative)) {
.test {
display: layout(block-size-negative);
background: green;
}
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<div class="test width-100"></div>
<div class="test height-100"></div>
<script id="code" type="text/worklet">
registerLayout('block-size-negative', class {
*intrinsicSizes() {}
*layout() {
return {autoBlockSize: -100};
}
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
</script>
</html>

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#get-a-layout-class-instance">
<link rel="match" href="fallback-ref.html">
<meta name="assert" content="This test checks that a layout() class with a throwing constructor will fallback to block layout." />
<style>
.test {
background: red;
border: solid 2px;
width: 100px;
}
.float {
float: left;
width: 50%;
height: 100px;
}
.fc {
display: flow-root;
height: 100px;
}
@supports (display: layout(throwing-ctor)) {
.test {
display: layout(throwing-ctor);
background: green;
}
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<!-- This tests that when the "layout()" constructor fails, it will fallback to block layout. -->
<div class="test">
<div class="float"></div>
<div class="fc"></div>
</div>
<script id="code" type="text/worklet">
registerLayout('throwing-ctor', class {
constructor() { throw Error('fail!'); }
*intrinsicSizes() {}
*layout() {}
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
</script>
</html>

View file

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#invoke-a-layout-callback">
<link rel="match" href="fallback-ref.html">
<meta name="assert" content="This test checks that a layout() class with a throwing layout function will fallback to block layout." />
<style>
.test {
background: red;
border: solid 2px;
width: 100px;
}
.float {
float: left;
width: 50%;
height: 100px;
}
.fc {
display: flow-root;
height: 100px;
}
@supports (display: layout(throwing-layout)) {
.test {
display: layout(throwing-layout);
background: green;
}
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<!-- This tests that when the "layout()" layout function fails, it will fallback to block layout. -->
<div class="test">
<div class="float"></div>
<div class="fc"></div>
</div>
<script id="code" type="text/worklet">
registerLayout('throwing-layout', class {
*intrinsicSizes() {}
*layout() { throw Error('fail!'); }
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
</script>
</html>

View file

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#invoke-a-layout-callback">
<link rel="match" href="fallback-ref.html">
<meta name="assert" content="This test checks that a layout() class with the layout function returning a bad value will fallback to block layout." />
<style>
.test {
background: red;
border: solid 2px;
width: 100px;
}
.float {
float: left;
width: 50%;
height: 100px;
}
.fc {
display: flow-root;
height: 100px;
}
@supports (display: layout(bad-return)) {
.test {
display: layout(bad-return);
background: green;
}
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<!-- This tests that when the "layout()" layout function returns a bad value, it will fallback to block layout. -->
<div class="test">
<div class="float"></div>
<div class="fc"></div>
</div>
<script id="code" type="text/worklet">
registerLayout('bad-return', class {
*intrinsicSizes() {}
*layout() { return 42; }
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
</script>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<style>
.result {
background: green;
border: solid 2px;
height: 100px;
width: 100px;
}
</style>
<div class="result"></div>

View file

@ -64,6 +64,11 @@ const gTestCases = [
cssText: 'perspective(1px)',
desc: 'CSSPerspective'
},
{
value: new CSSPerspective(CSS.px(-1)),
cssText: 'perspective(calc(-1px))',
desc: 'CSSPerspective with negative length'
},
{
value: new CSSTransformValue([new CSSPerspective(CSS.px(1))]),
cssText: 'perspective(1px)',

View file

@ -5,6 +5,7 @@
<meta name="assert" content="Test CSSUnparsedValue constructor and members">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testhelper.js"></script>
<body>
<div id="log">
<script>
@ -47,4 +48,44 @@ for (const {args, description} of gTestArguments) {
}, 'CSSUnparsedValue can be constructed from ' + description);
}
test(() => {
let result = new CSSUnparsedValue([new CSSVariableReferenceValue('--foo')]);
result[0] = 'A';
assert_equals(result[0], 'A', 'Item should be updated to new value');
}, 'Can update item in CSSUnparsedValue to a string');
test(() => {
let result = new CSSUnparsedValue(['foo']);
result[0] = new CSSVariableReferenceValue('--A');
assert_style_value_equals(result[0], new CSSVariableReferenceValue('--A'),
'Item should be updated to new value');
}, 'Can update item in CSSUnparsedValue to a variable reference');
test(() => {
let result = new CSSUnparsedValue([]);
result[0] = new CSSVariableReferenceValue('--A');
assert_equals(result.length, 1,
'Length of CSSUnparsedValue should have increased');
assert_style_value_equals(result[0], new CSSVariableReferenceValue('--A'),
'New item should be appended');
result[1] = 'foo';
assert_equals(result.length, 2,
'Length of CSSUnparsedValue should have increased');
assert_equals(result[1], 'foo', 'New item should be appended');
}, 'Can append items to CSSUnparsedValue');
test(() => {
const result = new CSSUnparsedValue(['foo', 'bar']);
assert_equals(result[3], undefined);
}, 'Getting invalid index in CSSUnparsedValue returns undefined');
test(() => {
let result = new CSSUnparsedValue(['foo', 'bar']);
assert_throws(new RangeError(), () => result[3] = 'foo');
}, 'Setting invalid index in CSSUnparsedValue throws RangeError');
</script>

View file

@ -21,10 +21,23 @@ for (const suffix of ['top', 'left', 'right', 'bottom']) {
runPropertyTests('border-' + suffix + '-width', [
// Computed value is 0 when border-style is 'none'.
// FIXME: Add separate test where border-style is not 'none' or 'hidden'.
{ syntax: 'thin', computed: assert_is_zero_px },
{ syntax: 'medium', computed: assert_is_zero_px },
{ syntax: 'thick', computed: assert_is_zero_px },
{ syntax: '<length>' },
{
syntax: 'thin',
computed: (_, result) => assert_is_zero_px(result)
},
{
syntax: 'medium',
computed: (_, result) => assert_is_zero_px(result)
},
{
syntax: 'thick',
computed: (_, result) => assert_is_zero_px(result)
},
{
syntax: '<length>',
specified: assert_is_equal_with_range_handling,
computed: (_, result) => assert_is_zero_px(result)
},
]);
}

View file

@ -15,8 +15,8 @@
runPropertyTests('height', [
{ syntax: 'auto' },
{ syntax: '<percentage>' },
{ syntax: '<length>' },
{ syntax: '<percentage>', specified: assert_is_equal_with_range_handling },
{ syntax: '<length>', specified: assert_is_equal_with_range_handling },
]);
</script>

View file

@ -15,8 +15,14 @@
for (const suffix of ['top', 'left', 'right', 'bottom']) {
runPropertyTests('padding-' + suffix, [
{ syntax: '<percentage>' },
{ syntax: '<length>' },
{
syntax: '<percentage>',
specified: assert_is_equal_with_range_handling
},
{
syntax: '<length>',
specified: assert_is_equal_with_range_handling
},
]);
}

View file

@ -1,3 +1,21 @@
function assert_is_unit(unit, result) {
assert_class_string(result, 'CSSUnitValue',
'relative lengths must compute to a CSSUnitValue');
assert_equals(result.unit, unit, 'unit');
}
function assert_is_calc_sum(result) {
assert_class_string(result, 'CSSMathSum',
'specified calc must be a CSSMathSum');
}
function assert_is_equal_with_range_handling(input, result) {
if (input instanceof CSSUnitValue && input.value < 0)
assert_style_value_equals(result, new CSSMathSum(input));
else
assert_style_value_equals(result, input);
}
const gTestSyntaxExamples = {
'<length>': {
description: 'a length',
@ -9,23 +27,23 @@ const gTestSyntaxExamples = {
{
description: "a negative em",
input: new CSSUnitValue(-3.14, 'em'),
defaultComputed: value => {
// 'ems' are relative units, so just check that it computes to px
assert_class_string(value, 'CSSUnitValue',
'"em" lengths must compute to a CSSUnitValue');
assert_equals(value.unit, 'px', 'unit');
}
// 'ems' are relative units, so just check that it computes to px
defaultComputed: (_, result) => assert_is_unit('px', result)
},
{
description: "a positive cm",
input: new CSSUnitValue(3.14, 'cm'),
defaultComputed: value => {
// 'cms' are relative units, so just check that it computes to px
assert_class_string(value, 'CSSUnitValue',
'"cm" lengths must compute to a CSSUnitValue');
assert_equals(value.unit, 'px', 'unit');
}
// 'cms' are relative units, so just check that it computes to px
defaultComputed: (_, result) => assert_is_unit('px', result)
},
{
description: "a calc length",
input: new CSSMathSum(new CSSUnitValue(0, 'px'), new CSSUnitValue(0, 'em')),
// Specified/computed calcs are usually simplified.
// FIXME: Test this properly
defaultSpecified: (_, result) => assert_is_calc_sum(result),
defaultComputed: (_, result) => assert_is_unit('px', result)
}
],
},
'<percentage>': {
@ -43,6 +61,14 @@ const gTestSyntaxExamples = {
description: "a positive percent",
input: new CSSUnitValue(3.14, 'percent')
},
{
description: "a calc percent",
input: new CSSMathSum(new CSSUnitValue(0, 'percent'), new CSSUnitValue(0, 'percent')),
// Specified/computed calcs are usually simplified.
// FIXME: Test this properly
defaultSpecified: (_, result) => assert_is_calc_sum(result),
defaultComputed: (_, result) => assert_is_unit('percent', result)
}
],
},
'<time>': {
@ -60,6 +86,14 @@ const gTestSyntaxExamples = {
description: "positive seconds",
input: new CSSUnitValue(3.14, 's')
},
{
description: "a calc time",
input: new CSSMathSum(new CSSUnitValue(0, 's'), new CSSUnitValue(0, 'ms')),
// Specified/computed calcs are usually simplified.
// FIXME: Test this properly
defaultSpecified: (_, result) => assert_is_calc_sum(result),
defaultComputed: (_, result) => assert_is_unit('s', result)
}
],
},
'<position>': {
@ -77,7 +111,7 @@ const gTestSyntaxExamples = {
{
description: "a PNG image",
input: new CSSURLImageValue('/media/1x1.png'),
defaultComputed: result => {
defaultComputed: (_, result) => {
// URLs compute to absolute URLs
assert_true(result instanceof CSSURLImageValue,
'Computed value should be a CSSURLImageValue');
@ -116,7 +150,7 @@ function testPropertyValid(propertyName, examples, specified, computed, descript
// specified style
const specifiedResult = element.attributeStyleMap.get(propertyName);
if (specified || example.defaultSpecified) {
(specified || example.defaultSpecified)(specifiedResult);
(specified || example.defaultSpecified)(example.input, specifiedResult);
} else {
assert_not_equals(specifiedResult, null,
'Specified value must not be null');
@ -129,7 +163,7 @@ function testPropertyValid(propertyName, examples, specified, computed, descript
// computed style
const computedResult = element.computedStyleMap().get(propertyName);
if (computed || example.defaultComputed) {
(computed || example.defaultComputed)(computedResult);
(computed || example.defaultComputed)(example.input, computedResult);
} else {
assert_not_equals(computedResult, null,
'Computed value must not be null');
@ -169,12 +203,20 @@ function createKeywordExample(keyword) {
// }
//
// If a callback is passed to |specified|, then the callback will be passed
// the result of calling get() on the inline style map (specified values).
// two arguments:
// 1. The input test case
// 2. The result of calling get() on the inline style map (specified values).
//
// The callback should check if the result is expected using assert_* functions.
// If no callback is passed, then we assert that the result is the same as
// the input.
//
// Same goes for |computed|, but with the computed style map (computed values).
//
// FIXME: The reason we pass argument #2 is that it's sometimes difficult to
// compute exactly what the expected result should be (e.g. browser-specific
// values). Once we can do that, we can remove argument #2 and just return
// the expected result.
function runPropertyTests(propertyName, testCases) {
let syntaxTested = new Set();

View file

@ -15,8 +15,14 @@
runPropertyTests('width', [
{ syntax: 'auto' },
{ syntax: '<percentage>' },
{ syntax: '<length>' },
{
syntax: '<percentage>',
specified: assert_is_equal_with_range_handling
},
{
syntax: '<length>',
specified: assert_is_equal_with_range_handling
},
]);
</script>