Fix null handling of SVGAngle/SVGLength.valueAsString attribute
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jul 2016 21:31:16 +0000 (21:31 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jul 2016 21:31:16 +0000 (21:31 +0000)
commite1aea7a758f704b78c66e66c42912e7f6b84b81f
treedde8fab8c328f54e02ecbe353dcc5dd284b3028f
parente7352adfedca3a91e3fa9d6918ccc5aaeb4c4d73
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/svg/dom/svg-element-attribute-js-null-expected.txt
LayoutTests/svg/dom/svg-element-attribute-js-null.xhtml
LayoutTests/svg/dom/valueAsString-null-expected.txt [new file with mode: 0644]
LayoutTests/svg/dom/valueAsString-null.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGAngle.idl
Source/WebCore/svg/SVGLength.idl