WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
149126
Document.createNodeIterator(null) / Document.createTreeWalker(null) should throw a TypeError
https://bugs.webkit.org/show_bug.cgi?id=149126
Summary
Document.createNodeIterator(null) / Document.createTreeWalker(null) should th...
Chris Dumez
Reported
2015-09-14 13:59:47 PDT
Document.createNodeIterator(null) / Document.createTreeWalker(null) should throw a TypeError:
https://dom.spec.whatwg.org/#interface-document
This is because the parameter is not nullable and Web IDL says we should throw a TypeError in this case. Firefox and Chrome throw an exception in this case.
Attachments
Patch
(14.63 KB, patch)
2015-09-14 15:07 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(18.75 KB, patch)
2015-09-14 16:40 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2015-09-14 14:00:15 PDT
rdar://problem/22564891
Chris Dumez
Comment 2
2015-09-14 15:07:21 PDT
Created
attachment 261134
[details]
Patch
Ryosuke Niwa
Comment 3
2015-09-14 15:57:10 PDT
Comment on
attachment 261134
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=261134&action=review
> Source/WebCore/dom/Document.h:540 > + RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, bool expandEntityReferences, ExceptionCode&); > + RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, ExceptionCode&); > + RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, ExceptionCode&); > + RefPtr<NodeIterator> createNodeIterator(Node* root, ExceptionCode&); > +
We can't rely on default arguments!? Can we somehow fix the bidding code generator to take care of this instead?
> LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-basic-expected.txt:7 > -FAIL Give an invalid root node to document.createTreeWalker(). assert_throws: function "function () { document.createTreeWalker(null); }" did not throw > +PASS Give an invalid root node to document.createTreeWalker().
Does this test all the combinations? If not, it might be worth adding a new test case.
Chris Dumez
Comment 4
2015-09-14 16:05:44 PDT
Comment on
attachment 261134
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=261134&action=review
>> Source/WebCore/dom/Document.h:540 >> + > > We can't rely on default arguments!? > Can we somehow fix the bidding code generator to take care of this instead?
Well, the issue is that the function now takes an ExceptionCode& so we cannot use default arguments. Longer term, my plan is to use WTF::Optional for optional parameters. This will probably be needed when we supposed passing undefined for optional parameters, e.g. document.createNodeIterator(node, undefined, filter, false); In this case, we should use the default value for whatToShow parameter.
>> LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-basic-expected.txt:7 >> +PASS Give an invalid root node to document.createTreeWalker(). > > Does this test all the combinations? > If not, it might be worth adding a new test case.
All combinations? I only changed the behavior of the first argument of createNodeIterator() / createTreeWalker(). Now that I look at it though, there is no coverage for createNodeIterator(null) but I'll add a test before landing.
Chris Dumez
Comment 5
2015-09-14 16:40:24 PDT
Created
attachment 261152
[details]
Patch
WebKit Commit Bot
Comment 6
2015-09-14 17:30:17 PDT
Comment on
attachment 261152
[details]
Patch Clearing flags on attachment: 261152 Committed
r189765
: <
http://trac.webkit.org/changeset/189765
>
WebKit Commit Bot
Comment 7
2015-09-14 17:30:21 PDT
All reviewed patches have been landed. Closing bug.
Joseph Pecoraro
Comment 8
2015-09-14 17:33:14 PDT
Comment on
attachment 261152
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=261152&action=review
> Source/WebCore/dom/Document.cpp:1744 > + return createNodeIterator(root, 0xFFFFFFFF, nullptr, false, ec);
Would have been nice if this 0xFFFFFFFF was a constant somewhere. It is used in a couple places.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug