Skip to content

Commit

Permalink
[css-typed-om] Upstream CSSKeywordValue tests.
Browse files Browse the repository at this point in the history
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
darrnshn authored and chromium-wpt-export-bot committed Jan 15, 2018
1 parent f86c744 commit 1dc4e23
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
@@ -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 css/css-typed-om/stylevalue-subclasses/cssKeywordValue.html
@@ -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>

0 comments on commit 1dc4e23

Please sign in to comment.