summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-typed-om/stylevalue-subclasses/cssUnparsedValue-length.html
blob: cb2b9c9b7066c001966fcb67b9925d52dca20239 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!doctype html>
<meta charset="utf-8">
<title>CSSUnparsedValue.length</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunparsedvalue-length">
<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>