Range.compareBoundaryPoints() should throw a NotSupportedError for invalid compareHow...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Aug 2015 22:33:40 +0000 (22:33 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Aug 2015 22:33:40 +0000 (22:33 +0000)
commita4d1bd7547279927e523b2b1342340ae26aa672c
treeb7473711d96ac6e2a6d5d7bd5c34be49ad5ad805
parent72047dd6e5a04dbdb968c7cef5c368bc053adae3
Range.compareBoundaryPoints() should throw a NotSupportedError for invalid compareHow values
https://bugs.webkit.org/show_bug.cgi?id=148483

Reviewed by Geoffrey Garen.

Source/WebCore:

Range.compareBoundaryPoints() should throw a NotSupportedError for
invalid compareHow values:
https://dom.spec.whatwg.org/#dom-range-compareboundarypoints (step 1)

Firefox and Chrome conform to the specification already.

Previously, WebKit would not throw and simply cast the value to our
internal CompareHow enum type. This patch aligns WebKit's behavior with
the DOM specificaiton and other browsers.

W3C test suite:
http://w3c-test.org/dom/ranges/Range-compareBoundaryPoints.html

Test: fast/dom/Range/compareBoundaryPoints-compareHow-exception.html

* bindings/scripts/CodeGenerator.pm:
* bindings/scripts/CodeGeneratorGObject.pm:
* bindings/scripts/CodeGeneratorJS.pm:
* bindings/scripts/CodeGeneratorObjC.pm:
Drop CompareHow special casing from bindings generator as we now use
unsigned short instead in the IDL.

* dom/Range.cpp:
(WebCore::Range::compareBoundaryPointsForBindings):
* dom/Range.h:
* dom/Range.idl:
Use "unsigned short" type instead of WebCore's CompareHow for the
parameter, as per the specification. On implementation side, we
now validate the compareHow value before casting it to a CompareHow
enum type. If the value is not value, we throw and abort early.

LayoutTests:

Add new layout test to confirm that Range.compareBoundaryPoints() throws
when passed in invalid compareHow values.

* fast/dom/Range/compareBoundaryPoints-compareHow-exception-expected.txt: Added.
* fast/dom/Range/compareBoundaryPoints-compareHow-exception.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189062 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/Range/compareBoundaryPoints-compareHow-exception-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Range/compareBoundaryPoints-compareHow-exception.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm
Source/WebCore/dom/Range.cpp
Source/WebCore/dom/Range.h
Source/WebCore/dom/Range.idl