blob: c58bf76bac3cd7da3919a126bb8352ca91091c5a [file] [log] [blame]
<!doctype html>
<meta charset="utf-8">
<title>CSSVariableReferenceValue Error Handling</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#cssvariablereferencevalue">
<meta name="assert" content="Test CSSVariableReferenceValue 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 CSSVariableReferenceValue(''));
}, 'Constructing a CSSVariableReferenceValue with an empty variable name ' +
'throws a TypeError');
test(() => {
assert_throws(new TypeError(), () => new CSSVariableReferenceValue('bar'));
}, 'Constructing a CSSVariableReferenceValue with an invalid variable name ' +
'throws SyntaxError');
test(() => {
let result = new CSSVariableReferenceValue('--foo');
assert_throws(new TypeError(), () => result.variable = '');
assert_equals(result.variable, '--foo',
'Variable member should not have changed');
}, 'Updating CSSVariableReferenceValue.variable to an empty variable name ' +
'throws TypeError');
test(() => {
let result = new CSSVariableReferenceValue('--foo');
assert_throws(new TypeError(), () => result.variable = 'bar');
assert_equals(result.variable, '--foo',
'Variable member should not have changed');
}, 'Updating CSSVariableReferenceValue.variable to an invalid variable name ' +
'throws TypeError');
</script>