blob: d25408401ffc73f7c96f924167770297ca93c886 [file] [log] [blame]
<!doctype html>
<meta charset="utf-8">
<title>StylePropertyMap iterable tests</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#the-stylepropertymap">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<body>
<script>
'use strict';
function findInStyleMap(styleMap, property) {
const index = [...styleMap.keys()].indexOf(property);
if (index == -1)
return null;
return [...styleMap.values()][index];
}
test(t => {
const styleMap = createComputedStyleMap(t, '--A: A; width: 10px; --C: C; transition-duration: 1s, 2s; color: red; --B: B;');
const expectedKeys = [...getComputedStyle(document.body)].sort().concat('--A', '--B', '--C');
assert_array_equals([...styleMap.keys()], expectedKeys);
}, 'StylePropertyMap iterates properties in correct order');
test(t => {
const styleMap = createComputedStyleMap(t, 'width: 10px; transition-duration: 1s, 2s; height: 20px');
assert_style_value_array_equals(findInStyleMap(styleMap, 'width'), [CSS.px(10)]);
}, 'StylePropertyMap iterator returns CSS properties with the correct CSSStyleValue');
test(t => {
const styleMap = createComputedStyleMap(t, 'width: 10px; transition-duration: 1s, 2s; height: 20px');
assert_style_value_array_equals(findInStyleMap(styleMap, 'transition-duration'), [CSS.s(1), CSS.s(2)]);
}, 'StylePropertyMap iterator returns list-valued properties with the correct CSSStyleValue');
test(t => {
const styleMap = createComputedStyleMap(t, '--A: A; --C: C; color: red; --B: B;');
assert_style_value_array_equals(findInStyleMap(styleMap, '--A'), [new CSSUnparsedValue([' A'])]);
assert_style_value_array_equals(findInStyleMap(styleMap, '--B'), [new CSSUnparsedValue([' B'])]);
assert_style_value_array_equals(findInStyleMap(styleMap, '--C'), [new CSSUnparsedValue([' C'])]);
}, 'StylePropertyMap iterator returns custom properties with the correct CSSStyleValue');
</script>