Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Range API should throw a TypeError for null Node parameters
https://bugs.webkit.org/show_bug.cgi?id=148692 Reviewed by Ryosuke Niwa. Source/WebCore: Range API should throw a TypeError for null Node parameters. We currently throw a NotFoundError. As per the DOM specification, the Node arguments are not optional nor nullable [1]: https://dom.spec.whatwg.org/#range Therefore, as per the Web IDL specification, we should throw a TypeError if the Node parameter is null or missing: https://heycam.github.io/webidl/#es-interface (step 1). [1] https://heycam.github.io/webidl/#es-nullable-type No new tests, covered by existing tests which have been rebaselined. * dom/Range.cpp: (WebCore::Range::setStart): (WebCore::Range::setEnd): (WebCore::Range::isPointInRange): (WebCore::Range::comparePoint): (WebCore::Range::compareNode): (WebCore::Range::compareBoundaryPoints): (WebCore::Range::intersectsNode): (WebCore::Range::insertNode): (WebCore::Range::setStartAfter): (WebCore::Range::setEndBefore): (WebCore::Range::setEndAfter): (WebCore::Range::selectNode): (WebCore::Range::selectNodeContents): (WebCore::Range::surroundContents): (WebCore::Range::setStartBefore): Set the Exception code to TypeError instead of NOT_FOUND_ERR if the Node parameter is null. * dom/Range.idl: Stop marking the Node parameters as optional. They are not optional in the specification and they are not really optional in our implementation. Previously, if the Node parameter was missing, we would call the implementation with a null pointer and the implementation would throw a NotFoundError. Now that they are mandatory, the bindings will directly throw a TypeError (as per the Web IDL spec) if the Node parameter is missing. However, if the JavaScript explicitely passes null or undefined, the implementation will still be called with a null pointer (because our bindings generator does not distinguish nullable / non-nullable parameters). For this reason, we still need to handle null pointers on the implementation side. LayoutTests: Update / rebaseline existing tests. * fast/dom/Range/range-compareNode.html: * fast/dom/Range/range-intersectsNode-expected.txt: * fast/text/text-combine-crash-expected.txt: * http/tests/w3c/dom/interfaces-expected.txt: * http/tests/w3c/dom/ranges/Range-comparePoint-2-expected.txt: * http/tests/w3c/dom/ranges/Range-intersectsNode-binding-expected.txt: Canonical link: https://commits.webkit.org/166818@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
10 changed files
with
157 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,5 +1,5 @@ | ||
|
||
PASS Range.comparePoint | ||
FAIL Range.comparePoint 1 assert_throws: function "function () { r.comparePoint(null, 0) }" threw object "Error: HierarchyRequestError: DOM Exception 3" ("HierarchyRequestError") expected object "TypeError" ("TypeError") | ||
PASS Range.comparePoint 1 | ||
PASS Range.comparePoint 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,3 +1,3 @@ | ||
|
||
FAIL Calling intersectsNode without an argument or with an invalid argument should throw a TypeError. assert_throws: function "function () { r.intersectsNode(); }" threw object "Error: NotFoundError: DOM Exception 8" ("NotFoundError") expected object "TypeError" ("TypeError") | ||
PASS Calling intersectsNode without an argument or with an invalid argument should throw a TypeError. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters