Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[css-typed-om] Upstream CSSKeywordValue tests.
This patch upstreams CSSKeywordValue tests to WPT. We split the original test into two seperate tests (one for valid and one for invalid inputs). Bug: 774887 Change-Id: Ic215178739e7a6d6399297b31e4ecf540a2b046b Reviewed-on: https://chromium-review.googlesource.com/866518 Reviewed-by: nainar <nainar@chromium.org> Commit-Queue: Darren Shen <shend@chromium.org> Cr-Commit-Position: refs/heads/master@{#529205}
- Loading branch information
1 parent
f86c744
commit 1dc4e23
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
css/css-typed-om/stylevalue-subclasses/cssKeywordValue-invalid.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>CSSKeywordValue Error Handling</title> | ||
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue"> | ||
<meta name="assert" content="Test CSSKeywordValue constructor and attributes error handling" /> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<body> | ||
<div id="log"> | ||
<script> | ||
'use strict'; | ||
|
||
test(() => { | ||
assert_throws(new TypeError(), () => new CSSKeywordValue('')); | ||
}, 'Constructing CSSKeywordValue with an empty string throws a TypeError'); | ||
|
||
test(() => { | ||
let result = new CSSKeywordValue('lemon'); | ||
assert_throws(new TypeError(), () => result.value = ''); | ||
assert_equals(result.value, 'lemon'); | ||
}, 'Updating CSSKeywordValue.value with an empty string throws a TypeError'); | ||
|
||
</script> |
40 changes: 40 additions & 0 deletions
40
css/css-typed-om/stylevalue-subclasses/cssKeywordValue.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>CSSKeywordValue</title> | ||
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue"> | ||
<meta name="assert" content="Test CSSKeywordValue constructor and attributes" /> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<body> | ||
<div id="log"> | ||
<script> | ||
'use strict'; | ||
|
||
const gTestArguments = [ | ||
{ keyword: 'initial', description: 'a CSS wide keyword' }, | ||
{ keyword: 'auto', description: 'a CSS keyword' }, | ||
{ keyword: 'lemon', description: 'an unsupported CSS keyword' }, | ||
{ keyword: '3! + 4@', description: 'a string containing multiple tokens' }, | ||
{ keyword: '☺', description: 'a unicode string' }, | ||
]; | ||
|
||
for (const {keyword, description} of gTestArguments) { | ||
test(() => { | ||
const result = new CSSKeywordValue(keyword); | ||
|
||
assert_not_equals(result, null, | ||
'A CSSKeywordValue should be created'); | ||
assert_equals(result.value, keyword, | ||
'Value attribute should be same as passed in the constructor'); | ||
}, 'CSSKeywordValue can be constructed from ' + description); | ||
|
||
test(() => { | ||
let result = new CSSKeywordValue('auto'); | ||
result.value = keyword; | ||
|
||
assert_equals(result.value, keyword, | ||
'Value attribute should be same as passed in the setter'); | ||
}, 'CSSKeywordValue.value can be updated to ' + description); | ||
} | ||
|
||
</script> |