Commit dc558473 authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

[css-typed-om] Throw when setting multiple values on non list prop.

When setting multiple values on a non list valued property, we resolved
to throw a TypeError.

Spec:
https://github.com/w3c/css-houdini-drafts/issues/512

Bug: 785132
Change-Id: I2a1a06ffc3eb6db66e08e2537eeaa570feaff0d3
Reviewed-on: https://chromium-review.googlesource.com/826744Reviewed-by: default avatarnainar <nainar@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524182}
parent 2ddece52
...@@ -3,6 +3,7 @@ PASS Setting a StylePropertyMap with an unsupported property name throws TypeErr ...@@ -3,6 +3,7 @@ PASS Setting a StylePropertyMap with an unsupported property name throws TypeErr
PASS Setting a StylePropertyMap with an null property name throws TypeError PASS Setting a StylePropertyMap with an null property name throws TypeError
PASS Setting a StylePropertyMap with an invalid CSSStyleValue throws TypeError PASS Setting a StylePropertyMap with an invalid CSSStyleValue throws TypeError
PASS Setting a StylePropertyMap with an invalid String throws TypeError PASS Setting a StylePropertyMap with an invalid String throws TypeError
PASS Setting a non list-valued property with multiple arguments throws TypeError
PASS Setting a property with CSSStyleValue or String updates its value PASS Setting a property with CSSStyleValue or String updates its value
PASS Setting a list-valued property with CSSStyleValue or String updates its values PASS Setting a list-valued property with CSSStyleValue or String updates its values
FAIL Setting a custom property with CSSStyleValue or String updates its value Failed to execute 'set' on 'StylePropertyMap': Invalid propertyName: --foo FAIL Setting a custom property with CSSStyleValue or String updates its value Failed to execute 'set' on 'StylePropertyMap': Invalid propertyName: --foo
......
...@@ -22,6 +22,11 @@ for (const {property, values, desc} of gInvalidTestCases) { ...@@ -22,6 +22,11 @@ for (const {property, values, desc} of gInvalidTestCases) {
}, 'Setting a StylePropertyMap with ' + desc + ' throws TypeError'); }, 'Setting a StylePropertyMap with ' + desc + ' throws TypeError');
} }
test(() => {
let styleMap = newDivWithStyle().attributeStyleMap;
assert_throws(new TypeError(), () => styleMap.set('width', CSS.px(10), CSS.px(10)));
}, 'Setting a non list-valued property with multiple arguments throws TypeError');
test(() => { test(() => {
let styleMap = newDivWithStyle().attributeStyleMap; let styleMap = newDivWithStyle().attributeStyleMap;
......
...@@ -97,8 +97,9 @@ void StylePropertyMap::set(const ExecutionContext* execution_context, ...@@ -97,8 +97,9 @@ void StylePropertyMap::set(const ExecutionContext* execution_context,
SetProperty(property_id, result); SetProperty(property_id, result);
} else { } else {
if (values.size() != 1) { if (values.size() != 1) {
// FIXME: Is this actually the correct behaviour? exception_state.ThrowTypeError(
exception_state.ThrowTypeError("Not supported"); "Cannot set " + property_name +
" with multiple values as it is not list-valued");
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment