Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 4 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-typed-om/stylevalue-subclasses/cssUnparsedValue-length.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8">
<title>CSSUnparsedValue.length</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
test(() => {
const result = new CSSUnparsedValue([]);
assert_equals(result.length, 0, 'length');
}, 'Length of CSSUnparsedValue with no fragments is zero');
test(() => {
const result = new CSSUnparsedValue([
' ', new CSSVariableReferenceValue('--A')
]);
assert_equals(result.length, 2, 'length');
}, 'Length of CSSUnparsedValue with multiple fragments is the number of ' +
'fragments');
test(() => {
let result = new CSSUnparsedValue([' ']);
assert_equals(result.length, 1, 'initial length');
result[1] = new CSSVariableReferenceValue('--A');
assert_equals(result.length, 2, 'length after appending once');
result[2] = 'lemon';
assert_equals(result.length, 3, 'length after appending twice');
}, 'Length of CSSUnparsedValue updates when fragments are appended');
test(() => {
let result = new CSSUnparsedValue([' ']);
assert_equals(result.length, 1, 'initial length');
result[0] = new CSSVariableReferenceValue('--A');
assert_equals(result.length, 1, 'length after modification');
result[0] = 'lemon';
assert_equals(result.length, 1, 'length after modification');
}, 'Length of CSSUnparsedValue does not change when fragments are modified');
</script>