Commit 27198849 authored by nikhil's avatar nikhil Committed by Commit Bot

CSSKeywordValue.value should never be empty string.

Currently CSSKeywordValue.value can be set to empty string if
empty string is assigned to that,instead it should 
throw a type error as per below spec.

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

BUG: 776647

Change-Id: I4bb635a26e25dcb35d971bb2a7a1b7d3445a6aca
Reviewed-on: https://chromium-review.googlesource.com/745743
Commit-Queue: srirama chandra sekhar <srirama.m@samsung.com>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512818}
parent a0fb2177
This is a testharness.js-based test.
PASS Constructing CSSKeywordValue with an empty string throws a TypeError
FAIL Updating CSSKeywordValue.value with an empty string throws a TypeError assert_throws: function "() => result.value = value" did not throw
PASS Constructing CSSKeywordValue with an object that serializes to empty string throws a TypeError
FAIL Updating CSSKeywordValue.value with an object that serializes to empty string throws a TypeError assert_throws: function "() => result.value = value" did not throw
PASS CSSKeywordValue can be constructed from a CSS keyword
PASS CSSKeywordValue can be constructed from an unsupported CSS keyword
PASS CSSKeywordValue can be constructed from a string containing multiple tokens
PASS CSSKeywordValue can be constructed from a unicode string
PASS CSSKeywordValue can be constructed from an object that serializes to a nonempty string
Harness: the test ran to completion.
......@@ -58,6 +58,16 @@ const String& CSSKeywordValue::value() const {
return keyword_value_;
}
void CSSKeywordValue::setValue(const String& keyword,
ExceptionState& exception_state) {
if (keyword.IsEmpty()) {
exception_state.ThrowTypeError(
"CSSKeywordValue does not support empty strings");
return;
}
keyword_value_ = keyword;
}
CSSValueID CSSKeywordValue::KeywordValueID() const {
return CssValueKeywordID(keyword_value_);
}
......
......@@ -25,7 +25,7 @@ class CORE_EXPORT CSSKeywordValue final : public CSSStyleValue {
StyleValueType GetType() const override { return kKeywordType; }
const String& value() const;
void setValue(const String& keyword) { keyword_value_ = keyword; }
void setValue(const String& keyword, ExceptionState&);
CSSValueID KeywordValueID() const;
const CSSValue* ToCSSValue() const override;
......
......@@ -10,5 +10,5 @@
Exposed(Window CSSTypedOM, PaintWorklet CSSTypedOM),
RaisesException=Constructor
] interface CSSKeywordValue : CSSStyleValue {
attribute DOMString value;
[RaisesException=Setter] attribute DOMString value;
};
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