Skip to content

Commit 5ae09b7

Browse files
janvargamoz-wptsync-bot
authored andcommitted
Add WPT for rejecting CSSStyleValue with mismatched associated property
Add a new Web Platform Test verifying that StylePropertyMap.set() throws a TypeError when a CSSStyleValue with an existing [[associatedProperty]] does not match the property being assigned to. Differential Revision: https://phabricator.services.mozilla.com/D271810 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1990419 gecko-commit: d8b8593f357774f2c99fbd835e1d47f306ebae63 gecko-reviewers: emilio
1 parent 7f0aad1 commit 5ae09b7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

css/css-typed-om/the-stylepropertymap/declared/set.tentative.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,15 @@
9595
assert_style_value_array_equals(result, [CSS.s(1), CSS.s(2)]);
9696
}, 'StylePropertyMap.set is case-insensitive');
9797

98+
test(t => {
99+
let styleMap = createDeclaredStyleMap(t, 'margin: 10px');
100+
101+
const result = styleMap.get('margin');
102+
assert_equals(result.constructor.name, 'CSSStyleValue');
103+
104+
assert_throws_js(TypeError, () => {
105+
styleMap.set('padding', result);
106+
});
107+
}, 'Setting a property with a CSSStyleValue whose associated property does not match throws TypeError');
108+
98109
</script>

css/css-typed-om/the-stylepropertymap/inline/set.tentative.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,15 @@
9595
assert_style_value_array_equals(result, [CSS.s(1), CSS.s(2)]);
9696
}, 'StylePropertyMap.set is case-insensitive');
9797

98+
test(t => {
99+
let styleMap = createInlineStyleMap(t, 'margin: 10px');
100+
101+
const result = styleMap.get('margin');
102+
assert_equals(result.constructor.name, 'CSSStyleValue');
103+
104+
assert_throws_js(TypeError, () => {
105+
styleMap.set('padding', result);
106+
});
107+
}, 'Setting a property with a CSSStyleValue whose associated property does not match throws TypeError');
108+
98109
</script>

0 commit comments

Comments
 (0)