Skip to content

Commit 1643aab

Browse files
committed
[css-typed-om] Run worker-exposed value tests in workers
Convert the stylevalue-subclasses tests whose interfaces are exposed to Worker to the .any.js template (global=window,worker), and add new worker-context tests for CSSUnitValue and CSSNumericValue: These are DOM-free value tests, so they run unchanged in dedicated, shared and service workers. They avoid CSSNumericValue.parse() and CSSStyleValue.parse() (which are Exposed=Window) and operations that produce types not exposed to workers (e.g. CSSMathSum).
1 parent 177f223 commit 1643aab

11 files changed

Lines changed: 66 additions & 119 deletions

css/css-typed-om/stylevalue-subclasses/cssKeywordValue-value.html renamed to css/css-typed-om/stylevalue-subclasses/cssKeywordValue-value.any.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
<!doctype html>
2-
<meta charset="utf-8">
3-
<title>CSSKeywordValue.value</title>
4-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-csskeywordvalue-value">
5-
<script src="/resources/testharness.js"></script>
6-
<script src="/resources/testharnessreport.js"></script>
7-
<body>
8-
<div id="log"></div>
9-
<script>
1+
// META: global=window,worker
2+
// META: title=CSSKeywordValue.value
3+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-csskeywordvalue-csskeywordvalue
4+
105
'use strict';
116

127
const gTestArguments = [
@@ -30,5 +25,3 @@
3025
assert_throws_js(TypeError, () => result.value = '');
3126
assert_equals(result.value, 'lemon', 'value does not change');
3227
}, 'Updating CSSKeywordValue.value with an empty string throws a TypeError');
33-
34-
</script>

css/css-typed-om/stylevalue-subclasses/cssKeywordValue.html renamed to css/css-typed-om/stylevalue-subclasses/cssKeywordValue.any.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
<!doctype html>
2-
<meta charset="utf-8">
3-
<title>CSSKeywordValue Constructor</title>
4-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-csskeywordvalue-csskeywordvalue">
5-
<script src="/resources/testharness.js"></script>
6-
<script src="/resources/testharnessreport.js"></script>
7-
<body>
8-
<div id="log"></div>
9-
<script>
1+
// META: global=window,worker
2+
// META: title=CSSKeywordValue Constructor
3+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-csskeywordvalue-value
4+
105
'use strict';
116

127
const gTestArguments = [
@@ -25,5 +20,3 @@
2520
'value is same as given by constructor');
2621
}, `CSSKeywordValue can be constructed from ${args.description}`);
2722
}
28-
29-
</script>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// META: global=window,worker
2+
// META: title=CSSUnparsedValue: Don't crash for empty values
3+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunparsedvalue-cssunparsedvalue
4+
5+
'use strict';
6+
7+
// https://crbug.com/1169941
8+
test(() => {
9+
const result = new CSSUnparsedValue(['']);
10+
assert_equals('', result.toString()); // Don't crash.
11+
}, `Don't crash when serializing empty CSSUnparsedValue`);

css/css-typed-om/stylevalue-subclasses/cssUnparsedValue-empty.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

css/css-typed-om/stylevalue-subclasses/numeric-objects/add-two-types.tentative.html renamed to css/css-typed-om/stylevalue-subclasses/numeric-objects/add-two-types.tentative.any.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
<!doctype html>
2-
<meta charset="utf-8">
3-
<title>Adding Two Numeric Types</title>
4-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#add-two-types">
5-
<script src="/resources/testharness.js"></script>
6-
<script src="/resources/testharnessreport.js"></script>
7-
<script src="../../resources/testhelper.js"></script>
8-
<body>
9-
<div id="log">
10-
<script>
1+
// META: global=window,worker
2+
// META: script=../../resources/testhelper.js
3+
// META: title=Adding Two Numeric Types
4+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#add-two-types
5+
116
'use strict';
127

138
const gAddTypesMathValueSubclasses = [
@@ -72,5 +67,3 @@
7267
assert_numeric_type_equals(result.type(), { length: 1, percentHint: 'length' });
7368
}, 'Adding two types with the same percent hint in the ' + subclass.name + ' constructor returns a type with that percent hint');
7469
}
75-
76-
</script>

css/css-typed-om/stylevalue-subclasses/numeric-objects/arithmetic.tentative.html renamed to css/css-typed-om/stylevalue-subclasses/numeric-objects/arithmetic.tentative.any.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
<!doctype html>
2-
<meta charset="utf-8">
3-
<title>Arithmetic operations on CSSNumericValue tests</title>
4-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-add">
5-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-sub">
6-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-mul">
7-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-div">
8-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-min">
9-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-max">
10-
<script src="/resources/testharness.js"></script>
11-
<script src="/resources/testharnessreport.js"></script>
12-
<script src="../../resources/testhelper.js"></script>
13-
<script>
1+
// META: global=window,worker
2+
// META: script=../../resources/testhelper.js
3+
// META: title=Arithmetic operations on CSSNumericValue tests
4+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-add
5+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-sub
6+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-mul
7+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-div
8+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-min
9+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-max
10+
1411
'use strict';
1512

1613
const gArithmeticOps = [
@@ -164,5 +161,3 @@
164161
assert_throws_js(TypeError, () => a[methodName](b));
165162
}, 'CSSNumericValue.' + methodName + ' should throw TypeError when the types are different.');
166163
}
167-
168-
</script>

css/css-typed-om/stylevalue-subclasses/numeric-objects/create-a-type.tentative.html renamed to css/css-typed-om/stylevalue-subclasses/numeric-objects/create-a-type.tentative.any.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
<!doctype html>
2-
<meta charset="utf-8">
3-
<title>Creating Type From A Unit</title>
4-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#create-a-type">
5-
<script src="/resources/testharness.js"></script>
6-
<script src="/resources/testharnessreport.js"></script>
7-
<script src="../../resources/testhelper.js"></script>
8-
<script>
1+
// META: global=window,worker
2+
// META: script=../../resources/testhelper.js
3+
// META: title=Creating Type From A Unit
4+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#create-a-type
5+
96
'use strict';
107

118
test(() => {
@@ -47,5 +44,3 @@
4744
const value = new CSSUnitValue(0, 'fr');
4845
assert_numeric_type_equals(value.type(), { flex: 1 });
4946
}, 'Creating a type from <flex> returns { flex: 1 }');
50-
51-
</script>

css/css-typed-om/stylevalue-subclasses/numeric-objects/cssMathInvert-type.html renamed to css/css-typed-om/stylevalue-subclasses/numeric-objects/cssMathInvert-type.any.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
<!doctype html>
2-
<meta charset="utf-8">
3-
<title>CSSMathInvert.type</title>
4-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#type-of-a-cssmathvalue">
5-
<script src="/resources/testharness.js"></script>
6-
<script src="/resources/testharnessreport.js"></script>
7-
<script src="../../resources/testhelper.js"></script>
8-
<body>
9-
<div id="log">
10-
<script>
1+
// META: global=window,worker
2+
// META: script=../../resources/testhelper.js
3+
// META: title=CSSMathInvert.type
4+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#type-of-a-cssmathvalue
5+
116
'use strict';
127

138
test(() => {
@@ -26,5 +21,3 @@
2621
const result = new CSSMathInvert(new CSSMathInvert(x));
2722
assert_numeric_type_equals(result.type(), { length: 1 });
2823
}, 'Inverting an inverted type returns the original type');
29-
30-
</script>

css/css-typed-om/stylevalue-subclasses/numeric-objects/cssMathNegate-type.html renamed to css/css-typed-om/stylevalue-subclasses/numeric-objects/cssMathNegate-type.any.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
<!doctype html>
2-
<meta charset="utf-8">
3-
<title>CSSMathNegate.type</title>
4-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#type-of-a-cssmathvalue">
5-
<script src="/resources/testharness.js"></script>
6-
<script src="/resources/testharnessreport.js"></script>
7-
<script src="../../resources/testhelper.js"></script>
8-
<body>
9-
<div id="log">
10-
<script>
1+
// META: global=window,worker
2+
// META: script=../../resources/testhelper.js
3+
// META: title=CSSMathNegate.type
4+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#type-of-a-cssmathvalue
5+
116
'use strict';
127

138
test(() => {
@@ -19,5 +14,3 @@
1914
const result = new CSSMathNegate(new CSSUnitValue(0, 'px'));
2015
assert_numeric_type_equals(result.type(), { length: 1 });
2116
}, 'Negating a type returns the same type');
22-
23-
</script>

css/css-typed-om/stylevalue-subclasses/numeric-objects/cssnumericvalue-multiply-two-types.tentative.html renamed to css/css-typed-om/stylevalue-subclasses/numeric-objects/cssnumericvalue-multiply-two-types.tentative.any.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
<!doctype html>
2-
<meta charset="utf-8">
3-
<title>Multiplying Two Numeric Types</title>
4-
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue-multiply-two-types">
5-
<script src="/resources/testharness.js"></script>
6-
<script src="/resources/testharnessreport.js"></script>
7-
<script src="../../resources/testhelper.js"></script>
8-
<body>
9-
<div id="log">
10-
<script>
1+
// META: global=window,worker
2+
// META: script=../../resources/testhelper.js
3+
// META: title=Multiplying Two Numeric Types
4+
// META: spec=https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue-multiply-two-types
5+
116
'use strict';
127

138
test(() => {
@@ -57,5 +52,3 @@
5752
const result = new CSSMathProduct(a, b);
5853
assert_numeric_type_equals(result.type(), { length: 2, percentHint: 'length' });
5954
}, 'Multiplying two types with same percent hint applies the percent hint');
60-
61-
</script>

0 commit comments

Comments
 (0)