Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-typed-om] Upstream CSSKeywordValue tests. #9028

Merged
merged 1 commit into from Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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>