Bug 148257

Summary: Fix passing null / undefined as NodeFilter parameter for createNodeIterator() / createTreeWalker()
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, commit-queue, darin, rniwa
Priority: P2    
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 148238    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2015-08-20 16:01:51 PDT
Fix passing null / undefined as NodeFilter parameter for createNodeIterator() / createTreeWalker(). It is supposed to be translated into a *null* NodeFilter. However, WebKit currently constructs a new NodeFilter.

Chrome and Firefox do not create a NodeFilter in this case.

Test Suite:
http://w3c-test.org/dom/traversal/NodeIterator.html
http://w3c-test.org/dom/traversal/TreeWalker.html
Comment 1 Chris Dumez 2015-08-20 16:04:13 PDT
Created attachment 259513 [details]
Patch
Comment 2 Chris Dumez 2015-08-20 17:01:27 PDT
Created attachment 259530 [details]
Patch
Comment 3 Chris Dumez 2015-08-20 17:03:15 PDT
Comment on attachment 259530 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259530&action=review

> Source/WebCore/bindings/js/JSNodeFilterCustom.cpp:43
> +    if (!value.isObject())

NodeFilter can be implemented as a JavaScript object. This is why we have a custom toWrapped() and we create a NodeFilter from that object. 
However, if we are not passed an object, we should simply return null instead of constructing a NodeFilter.
Comment 4 WebKit Commit Bot 2015-08-20 20:05:12 PDT
Comment on attachment 259530 [details]
Patch

Clearing flags on attachment: 259530

Committed r188745: <http://trac.webkit.org/changeset/188745>
Comment 5 WebKit Commit Bot 2015-08-20 20:05:18 PDT
All reviewed patches have been landed.  Closing bug.