Diff
Modified: trunk/LayoutTests/ChangeLog (203436 => 203437)
--- trunk/LayoutTests/ChangeLog 2016-07-20 00:29:21 UTC (rev 203436)
+++ trunk/LayoutTests/ChangeLog 2016-07-20 01:20:23 UTC (rev 203437)
@@ -1,3 +1,16 @@
+2016-07-19 Chris Dumez <[email protected]>
+
+ Align CSSStyleDeclaration.setProperty() with the specification
+ https://bugs.webkit.org/show_bug.cgi?id=159955
+
+ Reviewed by Benjamin Poulain.
+
+ Add layout test coverage.
+
+ * fast/css/CSSStyleDeclaration-setProperty-expected.txt: Added.
+ * fast/css/CSSStyleDeclaration-setProperty.html: Added.
+ * fast/css/shorthand-priority.html:
+
2016-07-19 Daniel Bates <[email protected]>
CSP: Improve support for multiple policies to more closely conform to the CSP Level 2 spec.
Added: trunk/LayoutTests/fast/css/CSSStyleDeclaration-setProperty-expected.txt (0 => 203437)
--- trunk/LayoutTests/fast/css/CSSStyleDeclaration-setProperty-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/CSSStyleDeclaration-setProperty-expected.txt 2016-07-20 01:20:23 UTC (rev 203437)
@@ -0,0 +1,41 @@
+Test the behavior of CSSStyleDeclaration.setProperty()
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+* Not enough parameters
+PASS div.style.setProperty() threw exception TypeError: Not enough arguments.
+PASS div.style.setProperty('color') threw exception TypeError: Not enough arguments.
+
+* Should treat null as empty string for 'value' parameter
+PASS div.style.setProperty('color', null) did not throw exception.
+PASS div.style.getPropertyValue('color') is ""
+PASS div.style.getPropertyPriority('color') is ""
+
+* Should treat null as empty string for 'priority' parameter
+PASS div.style.setProperty('background-color', 'green', null) did not throw exception.
+PASS div.style.getPropertyValue('background-color') is "green"
+PASS div.style.getPropertyPriority('background-color') is ""
+
+* Last parameter should do a case-insensitive match to 'important'
+PASS div.style.setProperty('border-left-color', 'green', 'important') did not throw exception.
+PASS div.style.getPropertyValue('border-left-color') is "green"
+PASS div.style.getPropertyPriority('border-left-color') is "important"
+PASS div.style.setProperty('border-right-color', 'green', 'IMPORTANT') did not throw exception.
+PASS div.style.getPropertyValue('border-right-color') is "green"
+PASS div.style.getPropertyPriority('border-right-color') is "important"
+
+* Invalid 'priority' value, should abort
+PASS div.style.setProperty('border-top-color', 'red', 'invalid') did not throw exception.
+PASS div.style.getPropertyValue('border-top-color') is ""
+PASS div.style.getPropertyPriority('border-top-color') is ""
+PASS div.style.setProperty('border-top-color', 'red', 'important invalid') did not throw exception.
+PASS div.style.getPropertyValue('border-top-color') is ""
+PASS div.style.getPropertyPriority('border-top-color') is ""
+PASS div.style.setProperty('border-top-color', 'red', '!important') did not throw exception.
+PASS div.style.getPropertyValue('border-top-color') is ""
+PASS div.style.getPropertyPriority('border-top-color') is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css/CSSStyleDeclaration-setProperty.html (0 => 203437)
--- trunk/LayoutTests/fast/css/CSSStyleDeclaration-setProperty.html (rev 0)
+++ trunk/LayoutTests/fast/css/CSSStyleDeclaration-setProperty.html 2016-07-20 01:20:23 UTC (rev 203437)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Test the behavior of CSSStyleDeclaration.setProperty()");
+
+var div = document.createElement("div");
+debug("* Not enough parameters");
+shouldThrow("div.style.setProperty()");
+shouldThrow("div.style.setProperty('color')");
+
+debug("");
+debug("* Should treat null as empty string for 'value' parameter");
+shouldNotThrow("div.style.setProperty('color', null)");
+shouldBeEqualToString("div.style.getPropertyValue('color')", "");
+shouldBeEqualToString("div.style.getPropertyPriority('color')", "");
+
+debug("");
+debug("* Should treat null as empty string for 'priority' parameter");
+shouldNotThrow("div.style.setProperty('background-color', 'green', null)");
+shouldBeEqualToString("div.style.getPropertyValue('background-color')", "green");
+shouldBeEqualToString("div.style.getPropertyPriority('background-color')", "");
+
+debug("");
+debug("* Last parameter should do a case-insensitive match to 'important'");
+shouldNotThrow("div.style.setProperty('border-left-color', 'green', 'important')");
+shouldBeEqualToString("div.style.getPropertyValue('border-left-color')", "green");
+shouldBeEqualToString("div.style.getPropertyPriority('border-left-color')", "important");
+shouldNotThrow("div.style.setProperty('border-right-color', 'green', 'IMPORTANT')");
+shouldBeEqualToString("div.style.getPropertyValue('border-right-color')", "green");
+shouldBeEqualToString("div.style.getPropertyPriority('border-right-color')", "important");
+
+debug("");
+debug("* Invalid 'priority' value, should abort");
+shouldNotThrow("div.style.setProperty('border-top-color', 'red', 'invalid')");
+shouldBeEqualToString("div.style.getPropertyValue('border-top-color')", "");
+shouldBeEqualToString("div.style.getPropertyPriority('border-top-color')", "");
+shouldNotThrow("div.style.setProperty('border-top-color', 'red', 'important invalid')");
+shouldBeEqualToString("div.style.getPropertyValue('border-top-color')", "");
+shouldBeEqualToString("div.style.getPropertyPriority('border-top-color')", "");
+shouldNotThrow("div.style.setProperty('border-top-color', 'red', '!important')");
+shouldBeEqualToString("div.style.getPropertyValue('border-top-color')", "");
+shouldBeEqualToString("div.style.getPropertyPriority('border-top-color')", "");
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/css/shorthand-priority.html (203436 => 203437)
--- trunk/LayoutTests/fast/css/shorthand-priority.html 2016-07-20 00:29:21 UTC (rev 203436)
+++ trunk/LayoutTests/fast/css/shorthand-priority.html 2016-07-20 01:20:23 UTC (rev 203437)
@@ -17,7 +17,7 @@
e = document.getElementById('test');
// Sanity check.
-e.style.setProperty("border-bottom-style", "solid", "!important");
+e.style.setProperty("border-bottom-style", "solid", "important");
shouldBe("e.style.getPropertyValue('border-bottom-style')", "'solid'");
shouldBe("e.style.getPropertyPriority('border-bottom-style')", "'important'");
@@ -27,7 +27,7 @@
shouldBe("e.style.getPropertyPriority('border')", "''");
e.style.border = "";
-e.style.setProperty("border", "20px solid green", "!important");
+e.style.setProperty("border", "20px solid green", "important");
shouldBe("e.style.getPropertyValue('border')", "'20px solid green'");
shouldBe("e.style.getPropertyPriority('border')", "'important'");
Modified: trunk/Source/WebCore/ChangeLog (203436 => 203437)
--- trunk/Source/WebCore/ChangeLog 2016-07-20 00:29:21 UTC (rev 203436)
+++ trunk/Source/WebCore/ChangeLog 2016-07-20 01:20:23 UTC (rev 203437)
@@ -1,3 +1,33 @@
+2016-07-19 Chris Dumez <[email protected]>
+
+ Align CSSStyleDeclaration.setProperty() with the specification
+ https://bugs.webkit.org/show_bug.cgi?id=159955
+
+ Reviewed by Benjamin Poulain.
+
+ Align CSSStyleDeclaration.setProperty() with the specification:
+ - https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface
+
+ In particular, the following changes were needed:
+ 1. The 'value' parameter should not be optional
+ 2. The 'priority' parameter should treat null as the empty string
+ rather than the string "null".
+ 3. The 'priority' parameter's default value should be the empty string,
+ not the string "undefined".
+ 4. CSSStyleDeclaration.setProperty() should return early if 'priority'
+ is not the empty string and is not an ASCII case-insensitive match
+ for the string "important".
+
+ Chrome matches the specification entirely.
+ Firefox matches the specification with the exception that it does a
+ case-sensitive match for "important".
+
+ Test: fast/css/CSSStyleDeclaration-setProperty.html
+
+ * css/CSSStyleDeclaration.idl:
+ * css/PropertySetCSSStyleDeclaration.cpp:
+ (WebCore::PropertySetCSSStyleDeclaration::setProperty):
+
2016-07-19 Daniel Bates <[email protected]>
CSP: Improve support for multiple policies to more closely conform to the CSP Level 2 spec.
Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.idl (203436 => 203437)
--- trunk/Source/WebCore/css/CSSStyleDeclaration.idl 2016-07-20 00:29:21 UTC (rev 203436)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.idl 2016-07-20 01:20:23 UTC (rev 203437)
@@ -38,11 +38,7 @@
[RaisesException] DOMString removeProperty(optional DOMString propertyName = "undefined");
DOMString? getPropertyPriority(optional DOMString propertyName = "undefined");
- // FIXME: 'priority' should use [TreatNullAs=EmptyString].
- // FIXME: Using "undefined" as default parameter value is wrong.
- [ObjCLegacyUnnamedParameters, RaisesException] void setProperty(optional DOMString propertyName = "undefined",
- [TreatNullAs=EmptyString] optional DOMString value = "undefined",
- optional DOMString priority = "undefined");
+ [ObjCLegacyUnnamedParameters, RaisesException] void setProperty(DOMString propertyName, [TreatNullAs=EmptyString] DOMString value, [TreatNullAs=EmptyString] optional DOMString priority = "");
readonly attribute unsigned long length;
getter DOMString item(optional unsigned long index = 0);
Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp (203436 => 203437)
--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2016-07-20 00:29:21 UTC (rev 203436)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2016-07-20 01:20:23 UTC (rev 203437)
@@ -226,7 +226,9 @@
if (!willMutate())
return;
- bool important = priority.find("important", 0, false) != notFound;
+ bool important = equalIgnoringASCIICase(priority, "important");
+ if (!important && !priority.isEmpty())
+ return;
ec = 0;
bool changed = propertyID != CSSPropertyCustom ? m_propertySet->setProperty(propertyID, value, important, contextStyleSheet()) : m_propertySet->setCustomProperty(propertyName, value, important, contextStyleSheet());