- Revision
- 203531
- Author
- cdu...@apple.com
- Date
- 2016-07-21 14:31:16 -0700 (Thu, 21 Jul 2016)
Log Message
Fix null handling of SVGAngle/SVGLength.valueAsString attribute
https://bugs.webkit.org/show_bug.cgi?id=160025
Reviewed by Ryosuke Niwa.
Source/WebCore:
Fix null handling of SVGAngle/SVGLength.valueAsString attribute
to match the specification:
- https://www.w3.org/TR/SVG2/types.html#InterfaceSVGAngle
- https://www.w3.org/TR/SVG2/types.html#InterfaceSVGLength
In particular, this patch drops [TreatNullAs=EmptyString] IDL
extended attribute from this attribute. This is not supposed
to change behavior given that both "" and "null" are invalid
numbers and the specification says to throw a SYNTAX_ERR in
this case.
However, WebKit currently ignores assignments to "" instead
of throwing. As a result, assigning to null will now throw
instead of being ignored. The compatibility risk should be
low because both Firefox and Chrome throw when assigning
null.
I did not change the behavior when assigning to "" because
it is a bit out of scope for this patch and browsers to not
seem to agree:
- Firefox throws
- Chrome set value to "0"
- WebKit ignores the assignment
The specification seems to agree with Firefox as far as I
can tell given that "" is not a valid number as per:
- https://www.w3.org/TR/css3-values/#numbers
Test: svg/dom/valueAsString-null.html
* svg/SVGAngle.idl:
* svg/SVGLength.idl:
LayoutTests:
Add test coverage.
* svg/dom/svg-element-attribute-js-null-expected.txt:
* svg/dom/svg-element-attribute-js-null.xhtml:
* svg/dom/valueAsString-null-expected.txt: Added.
* svg/dom/valueAsString-null.html: Added.
There are a couple of failures in this test because WebKit ignores
assignments to "" instead of throwing. Firefox passes all the checks.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (203530 => 203531)
--- trunk/LayoutTests/ChangeLog 2016-07-21 21:25:45 UTC (rev 203530)
+++ trunk/LayoutTests/ChangeLog 2016-07-21 21:31:16 UTC (rev 203531)
@@ -1,5 +1,21 @@
2016-07-21 Chris Dumez <cdu...@apple.com>
+ Fix null handling of SVGAngle/SVGLength.valueAsString attribute
+ https://bugs.webkit.org/show_bug.cgi?id=160025
+
+ Reviewed by Ryosuke Niwa.
+
+ Add test coverage.
+
+ * svg/dom/svg-element-attribute-js-null-expected.txt:
+ * svg/dom/svg-element-attribute-js-null.xhtml:
+ * svg/dom/valueAsString-null-expected.txt: Added.
+ * svg/dom/valueAsString-null.html: Added.
+ There are a couple of failures in this test because WebKit ignores
+ assignments to "" instead of throwing. Firefox passes all the checks.
+
+2016-07-21 Chris Dumez <cdu...@apple.com>
+
Fix null handling of HTMLFontElement.color
https://bugs.webkit.org/show_bug.cgi?id=160036
Modified: trunk/LayoutTests/svg/dom/svg-element-attribute-js-null-expected.txt (203530 => 203531)
--- trunk/LayoutTests/svg/dom/svg-element-attribute-js-null-expected.txt 2016-07-21 21:25:45 UTC (rev 203530)
+++ trunk/LayoutTests/svg/dom/svg-element-attribute-js-null-expected.txt 2016-07-21 21:31:16 UTC (rev 203531)
@@ -2,10 +2,6 @@
TEST SUCCEEDED: The value was the string 'null'. [tested SVGElement.id]
-TEST SUCCEEDED: The value was the string '0'. [tested SVGAngle.valueAsString]
-
-TEST SUCCEEDED: The value was the string '0'. [tested SVGLength.valueAsString]
-
TEST SUCCEEDED: The value was the string 'null'. [tested SVGScriptElement.type]
Modified: trunk/LayoutTests/svg/dom/svg-element-attribute-js-null.xhtml (203530 => 203531)
--- trunk/LayoutTests/svg/dom/svg-element-attribute-js-null.xhtml 2016-07-21 21:25:45 UTC (rev 203530)
+++ trunk/LayoutTests/svg/dom/svg-element-attribute-js-null.xhtml 2016-07-21 21:31:16 UTC (rev 203531)
@@ -56,20 +56,6 @@
]
},
{
- type: 'SVGAngle',
- elementToUse: svg.createSVGAngle(),
- attributes: [
- {name: 'valueAsString', expectedNull: '0'}
- ]
- },
- {
- type: 'SVGLength',
- elementToUse: svg.createSVGLength(),
- attributes: [
- {name: 'valueAsString', expectedNull: '0'}
- ]
- },
- {
type: 'SVGScriptElement',
elementToUse: document.createElementNS(svgNS, 'script'),
attributes: [
Added: trunk/LayoutTests/svg/dom/valueAsString-null-expected.txt (0 => 203531)
--- trunk/LayoutTests/svg/dom/valueAsString-null-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/dom/valueAsString-null-expected.txt 2016-07-21 21:31:16 UTC (rev 203531)
@@ -0,0 +1,24 @@
+Test assigning null to SVGAngle.valueAsString / SVGLength.valueAsString
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS angle.valueAsString is "0"
+PASS angle.valueAsString = null threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
+PASS angle.valueAsString is "0"
+PASS angle.valueAsString = '10' did not throw exception.
+PASS angle.valueAsString is "10"
+FAIL angle.valueAsString = '' should throw an exception. Was .
+PASS angle.valueAsString is "10"
+
+PASS length.valueAsString is "0"
+PASS length.valueAsString = null threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
+PASS length.valueAsString is "0"
+PASS length.valueAsString = '10' did not throw exception.
+PASS length.valueAsString is "10"
+FAIL length.valueAsString = '' should throw an exception. Was .
+PASS length.valueAsString is "10"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/svg/dom/valueAsString-null.html (0 => 203531)
--- trunk/LayoutTests/svg/dom/valueAsString-null.html (rev 0)
+++ trunk/LayoutTests/svg/dom/valueAsString-null.html 2016-07-21 21:31:16 UTC (rev 203531)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Test assigning null to SVGAngle.valueAsString / SVGLength.valueAsString");
+
+var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+var angle = svg.createSVGAngle();
+shouldBeEqualToString("angle.valueAsString", "0");
+shouldThrow("angle.valueAsString = null");
+shouldBeEqualToString("angle.valueAsString", "0");
+shouldNotThrow("angle.valueAsString = '10'");
+shouldBeEqualToString("angle.valueAsString", "10");
+shouldThrow("angle.valueAsString = ''");
+shouldBeEqualToString("angle.valueAsString", "10");
+
+debug("");
+var length = svg.createSVGLength();
+shouldBeEqualToString("length.valueAsString", "0");
+shouldThrow("length.valueAsString = null");
+shouldBeEqualToString("length.valueAsString", "0");
+shouldNotThrow("length.valueAsString = '10'");
+shouldBeEqualToString("length.valueAsString", "10");
+shouldThrow("length.valueAsString = ''");
+shouldBeEqualToString("length.valueAsString", "10");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (203530 => 203531)
--- trunk/Source/WebCore/ChangeLog 2016-07-21 21:25:45 UTC (rev 203530)
+++ trunk/Source/WebCore/ChangeLog 2016-07-21 21:31:16 UTC (rev 203531)
@@ -1,5 +1,45 @@
2016-07-21 Chris Dumez <cdu...@apple.com>
+ Fix null handling of SVGAngle/SVGLength.valueAsString attribute
+ https://bugs.webkit.org/show_bug.cgi?id=160025
+
+ Reviewed by Ryosuke Niwa.
+
+ Fix null handling of SVGAngle/SVGLength.valueAsString attribute
+ to match the specification:
+ - https://www.w3.org/TR/SVG2/types.html#InterfaceSVGAngle
+ - https://www.w3.org/TR/SVG2/types.html#InterfaceSVGLength
+
+ In particular, this patch drops [TreatNullAs=EmptyString] IDL
+ extended attribute from this attribute. This is not supposed
+ to change behavior given that both "" and "null" are invalid
+ numbers and the specification says to throw a SYNTAX_ERR in
+ this case.
+
+ However, WebKit currently ignores assignments to "" instead
+ of throwing. As a result, assigning to null will now throw
+ instead of being ignored. The compatibility risk should be
+ low because both Firefox and Chrome throw when assigning
+ null.
+
+ I did not change the behavior when assigning to "" because
+ it is a bit out of scope for this patch and browsers to not
+ seem to agree:
+ - Firefox throws
+ - Chrome set value to "0"
+ - WebKit ignores the assignment
+
+ The specification seems to agree with Firefox as far as I
+ can tell given that "" is not a valid number as per:
+ - https://www.w3.org/TR/css3-values/#numbers
+
+ Test: svg/dom/valueAsString-null.html
+
+ * svg/SVGAngle.idl:
+ * svg/SVGLength.idl:
+
+2016-07-21 Chris Dumez <cdu...@apple.com>
+
Fix null handling of HTMLFontElement.color
https://bugs.webkit.org/show_bug.cgi?id=160036
Modified: trunk/Source/WebCore/svg/SVGAngle.idl (203530 => 203531)
--- trunk/Source/WebCore/svg/SVGAngle.idl 2016-07-21 21:25:45 UTC (rev 203530)
+++ trunk/Source/WebCore/svg/SVGAngle.idl 2016-07-21 21:31:16 UTC (rev 203531)
@@ -32,8 +32,7 @@
[StrictTypeChecking] attribute unrestricted float value;
[StrictTypeChecking] attribute unrestricted float valueInSpecifiedUnits;
- // FIXME: This should not have [TreatNullAs=EmptyString].
- [TreatNullAs=EmptyString, SetterRaisesException] attribute DOMString valueAsString;
+ [SetterRaisesException] attribute DOMString valueAsString;
[StrictTypeChecking, RaisesException] void newValueSpecifiedUnits(unsigned short unitType, unrestricted float valueInSpecifiedUnits);
Modified: trunk/Source/WebCore/svg/SVGLength.idl (203530 => 203531)
--- trunk/Source/WebCore/svg/SVGLength.idl 2016-07-21 21:25:45 UTC (rev 203530)
+++ trunk/Source/WebCore/svg/SVGLength.idl 2016-07-21 21:31:16 UTC (rev 203531)
@@ -39,8 +39,7 @@
[StrictTypeChecking] attribute unrestricted float valueInSpecifiedUnits;
- // FIXME: This should not use [TreatNullAs=EmptyString].
- [TreatNullAs=EmptyString, StrictTypeChecking, SetterRaisesException] attribute DOMString valueAsString;
+ [StrictTypeChecking, SetterRaisesException] attribute DOMString valueAsString;
[StrictTypeChecking, RaisesException] void newValueSpecifiedUnits(unsigned short unitType,
unrestricted float valueInSpecifiedUnits);