Title: [203744] trunk
Revision
203744
Author
[email protected]
Date
2016-07-26 15:38:13 -0700 (Tue, 26 Jul 2016)

Log Message

Align CSSStyleDeclaration with the specification
https://bugs.webkit.org/show_bug.cgi?id=160214

Reviewed by Darin Adler.

Source/WebCore:

Align CSSStyleDeclaration with the specification:
- https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface

In particular, the parameters to removeProperty() / item() and
getPropertyPriority() should be mandatory.

Firefox and Chrome match the specification.

Tests: fast/css/CSSStyleDeclaration-cssText-null.html
       fast/css/CSSStyleDeclaration-parameters.html

* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::getPropertyCSSValue):
* css/CSSStyleDeclaration.idl:

LayoutTests:

* fast/css/CSSStyleDeclaration-cssText-null-expected.txt: Added.
* fast/css/CSSStyleDeclaration-cssText-null.html: Added.
Add layout test coverage for setting cssText to null. This test
passes in WebKit, Firefox and Chrome, with or without my change.
Our IDL wrongly reported the cssText attribute as nullable but
WebKit was already behaving correctly.

* fast/css/CSSStyleDeclaration-parameters-expected.txt: Added.
* fast/css/CSSStyleDeclaration-parameters.html: Added.
Add testing for omitting CSSStyleDeclaration API parameters, to
make sure they are mandatory. This test passes in Firefox and
Chrome.

* fast/dom/non-numeric-values-numeric-parameters-expected.txt:
* fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
Update existing test to reflect behavior change.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203743 => 203744)


--- trunk/LayoutTests/ChangeLog	2016-07-26 22:31:25 UTC (rev 203743)
+++ trunk/LayoutTests/ChangeLog	2016-07-26 22:38:13 UTC (rev 203744)
@@ -1,3 +1,27 @@
+2016-07-26  Chris Dumez  <[email protected]>
+
+        Align CSSStyleDeclaration with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=160214
+
+        Reviewed by Darin Adler.
+
+        * fast/css/CSSStyleDeclaration-cssText-null-expected.txt: Added.
+        * fast/css/CSSStyleDeclaration-cssText-null.html: Added.
+        Add layout test coverage for setting cssText to null. This test
+        passes in WebKit, Firefox and Chrome, with or without my change.
+        Our IDL wrongly reported the cssText attribute as nullable but
+        WebKit was already behaving correctly.
+
+        * fast/css/CSSStyleDeclaration-parameters-expected.txt: Added.
+        * fast/css/CSSStyleDeclaration-parameters.html: Added.
+        Add testing for omitting CSSStyleDeclaration API parameters, to
+        make sure they are mandatory. This test passes in Firefox and
+        Chrome.
+
+        * fast/dom/non-numeric-values-numeric-parameters-expected.txt:
+        * fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
+        Update existing test to reflect behavior change.
+
 2016-07-26  David Kilzer <[email protected]>
 
         Networking process crash due to missing -[WebCoreAuthenticationClientAsChallengeSender performDefaultHandlingForAuthenticationChallenge:] implementation

Added: trunk/LayoutTests/fast/css/CSSStyleDeclaration-cssText-null-expected.txt (0 => 203744)


--- trunk/LayoutTests/fast/css/CSSStyleDeclaration-cssText-null-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/CSSStyleDeclaration-cssText-null-expected.txt	2016-07-26 22:38:13 UTC (rev 203744)
@@ -0,0 +1,14 @@
+Tests that CSSStyleDeclaration.cssText is not nullable
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS style.cssText is ""
+PASS style.cssText = 'margin: 0px;' did not throw exception.
+PASS style.cssText is "margin: 0px;"
+PASS style.cssText = null did not throw exception.
+PASS style.cssText is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/css/CSSStyleDeclaration-cssText-null.html (0 => 203744)


--- trunk/LayoutTests/fast/css/CSSStyleDeclaration-cssText-null.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/CSSStyleDeclaration-cssText-null.html	2016-07-26 22:38:13 UTC (rev 203744)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that CSSStyleDeclaration.cssText is not nullable");
+
+var div = document.createElement("div");
+var style = div.style;
+shouldBeEqualToString("style.cssText", "");
+shouldNotThrow("style.cssText = 'margin: 0px;'");
+shouldBeEqualToString("style.cssText", "margin: 0px;");
+shouldNotThrow("style.cssText = null");
+shouldBeEqualToString("style.cssText", "");
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/CSSStyleDeclaration-parameters-expected.txt (0 => 203744)


--- trunk/LayoutTests/fast/css/CSSStyleDeclaration-parameters-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/CSSStyleDeclaration-parameters-expected.txt	2016-07-26 22:38:13 UTC (rev 203744)
@@ -0,0 +1,13 @@
+Tests that parameters to CSSStyleDeclaration API are mandatory.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS style.item() threw exception TypeError: Not enough arguments.
+PASS style.removeProperty() threw exception TypeError: Not enough arguments.
+PASS style.getPropertyPriority() threw exception TypeError: Not enough arguments.
+PASS style.getPropertyCSSValue() threw exception TypeError: Not enough arguments.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/css/CSSStyleDeclaration-parameters.html (0 => 203744)


--- trunk/LayoutTests/fast/css/CSSStyleDeclaration-parameters.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/CSSStyleDeclaration-parameters.html	2016-07-26 22:38:13 UTC (rev 203744)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that parameters to CSSStyleDeclaration API are mandatory.");
+
+var style = document.body.style;
+shouldThrow("style.item()", "'TypeError: Not enough arguments'");
+shouldThrow("style.removeProperty()", "'TypeError: Not enough arguments'");
+shouldThrow("style.getPropertyPriority()", "'TypeError: Not enough arguments'");
+shouldThrow("style.getPropertyCSSValue()", "'TypeError: Not enough arguments'");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt (203743 => 203744)


--- trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt	2016-07-26 22:31:25 UTC (rev 203743)
+++ trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt	2016-07-26 22:38:13 UTC (rev 203744)
@@ -14,7 +14,7 @@
 PASS nonNumericPolicy('createCSSMediaRule().insertRule(ruleText, x)') is 'any type allowed'
 PASS nonNumericPolicy('createCSSMediaRule().deleteRule(x)') is 'any type allowed'
 PASS nonNumericPolicy('createCSSRuleList().item(x)') is 'any type allowed'
-PASS nonNumericPolicy('createCSSStyleDeclaration().item(x)') is 'any type allowed'
+PASS nonNumericPolicy('createCSSStyleDeclaration().item(x)') is 'any type allowed (but not omitted)'
 PASS nonNumericPolicy('createCSSStyleSheet().insertRule(ruleText, x)') is 'any type allowed'
 PASS nonNumericPolicy('createCSSStyleSheet().deleteRule(x)') is 'any type allowed (but not omitted)'
 PASS nonNumericPolicy('createCSSStyleSheet().addRule(selector, styleText, x)') is 'any type allowed'

Modified: trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js (203743 => 203744)


--- trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js	2016-07-26 22:31:25 UTC (rev 203743)
+++ trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js	2016-07-26 22:38:13 UTC (rev 203744)
@@ -204,7 +204,7 @@
 
 // CSSStyleDeclaration
 
-shouldBe("nonNumericPolicy('createCSSStyleDeclaration().item(x)')", "'any type allowed'");
+shouldBe("nonNumericPolicy('createCSSStyleDeclaration().item(x)')", "'any type allowed (but not omitted)'");
 
 // CSSStyleSheet
 

Modified: trunk/Source/WebCore/ChangeLog (203743 => 203744)


--- trunk/Source/WebCore/ChangeLog	2016-07-26 22:31:25 UTC (rev 203743)
+++ trunk/Source/WebCore/ChangeLog	2016-07-26 22:38:13 UTC (rev 203744)
@@ -1,3 +1,25 @@
+2016-07-26  Chris Dumez  <[email protected]>
+
+        Align CSSStyleDeclaration with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=160214
+
+        Reviewed by Darin Adler.
+
+        Align CSSStyleDeclaration with the specification:
+        - https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface
+
+        In particular, the parameters to removeProperty() / item() and
+        getPropertyPriority() should be mandatory.
+
+        Firefox and Chrome match the specification.
+
+        Tests: fast/css/CSSStyleDeclaration-cssText-null.html
+               fast/css/CSSStyleDeclaration-parameters.html
+
+        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+        (WebCore::JSCSSStyleDeclaration::getPropertyCSSValue):
+        * css/CSSStyleDeclaration.idl:
+
 2016-07-26  David Kilzer <[email protected]>
 
         Networking process crash due to missing -[WebCoreAuthenticationClientAsChallengeSender performDefaultHandlingForAuthenticationChallenge:] implementation

Modified: trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp (203743 => 203744)


--- trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp	2016-07-26 22:31:25 UTC (rev 203743)
+++ trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp	2016-07-26 22:38:13 UTC (rev 203744)
@@ -349,7 +349,10 @@
 
 JSValue JSCSSStyleDeclaration::getPropertyCSSValue(ExecState& state)
 {
-    const String& propertyName = state.argument(0).toString(&state)->value(&state);
+    if (UNLIKELY(state.argumentCount() < 1))
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    String propertyName = state.uncheckedArgument(0).toWTFString(&state);
     if (state.hadException())
         return jsUndefined();
 

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.idl (203743 => 203744)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.idl	2016-07-26 22:31:25 UTC (rev 203743)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.idl	2016-07-26 22:38:13 UTC (rev 203744)
@@ -29,20 +29,19 @@
     SkipVTableValidation,
     ExportMacro=WEBCORE_EXPORT,
 ] interface CSSStyleDeclaration {
-    [SetterRaisesException] attribute DOMString? cssText;
+    [SetterRaisesException] attribute DOMString cssText;
 
     DOMString getPropertyValue(DOMString propertyName);
-    [Custom] CSSValue getPropertyCSSValue(optional DOMString propertyName);
+    [Custom] CSSValue? getPropertyCSSValue(DOMString propertyName);
 
-    // FIXME: Using "undefined" as default parameter value is wrong.
-    [RaisesException] DOMString removeProperty(optional DOMString propertyName = "undefined");
-    DOMString? getPropertyPriority(optional DOMString propertyName = "undefined");
+    [RaisesException] DOMString removeProperty(DOMString propertyName);
+    DOMString? getPropertyPriority(DOMString propertyName);
 
     [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);
-    readonly attribute CSSRule          parentRule;
+    readonly attribute unsigned long length;
+    getter DOMString item(unsigned long index);
+    readonly attribute CSSRule? parentRule;
 
     // Extensions
     // FIXME: Using "undefined" as default parameter value is wrong.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to