Bug 131443

Summary: NodeList should be iterable
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: DOMAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: annevk, arv, barraclough, benjamin, bfulgham, buildbot, cdumez, commit-queue, eoconnor, fpizlo, ggaren, jiewen_tan, kling, koivisto, mhahnenberg, mmaxfield, rniwa, sam, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: https://dom.spec.whatwg.org/#old-style-collections
See Also: https://bugs.webkit.org/show_bug.cgi?id=159020
Bug Depends on:    
Bug Blocks: 157453    
Attachments:
Description Flags
WIP
none
Rebasing WIP
none
Archive of layout-test-results from ews103 for mac-yosemite
none
Archive of layout-test-results from ews113 for mac-yosemite
none
Archive of layout-test-results from ews105 for mac-yosemite-wk2
none
Archive of layout-test-results from ews123 for ios-simulator-wk2
none
Patch
none
Archive of layout-test-results from ews101 for mac-yosemite
none
Archive of layout-test-results from ews126 for ios-simulator-wk2
none
Archive of layout-test-results from ews107 for mac-yosemite-wk2
none
Archive of layout-test-results from ews115 for mac-yosemite
none
Fixing key/value order
none
Patch
none
Archive of layout-test-results from ews103 for mac-yosemite
none
Archive of layout-test-results from ews105 for mac-yosemite-wk2
none
Archive of layout-test-results from ews117 for mac-yosemite
none
Fixing for-of loop for set iterators
none
Patch for landing none

Description Ryosuke Niwa 2014-04-09 10:35:00 PDT
It's ridiculous that every JS library is converting the result of querySelectorAll into an array.

Since querySelectorAll returns a new NodeList each time, I don't think the backwards compatibility risk is that high.
We should make it return a JS array instead.
Comment 1 Geoffrey Garen 2014-04-09 10:43:15 PDT
How would this help with the fact that library code copies out the result into a new array?

Are you proposing a spec change, which other browsers would adopt, which would then lead to library authors removing their copying code?
Comment 2 Ryosuke Niwa 2014-04-09 10:43:26 PDT
Anne says he can change the spec if we successfully change our implementation.
Comment 3 Ryosuke Niwa 2014-04-09 10:53:00 PDT
(In reply to comment #1)
> How would this help with the fact that library code copies out the result into a new array?
>
> Are you proposing a spec change, which other browsers would adopt, which would then lead to library authors removing their copying code?

Yes. Also JSC can optimize native JS array operations better than the one involving NodeLists although we should be teaching JSC now to access NodeList fast as well.

e.g. jQuery executes:

push.apply( results, slice.call( newContext.querySelectorAll(
    newSelector
), 0 ) );

and optimizing this code is much easier if querySelectorAll simply returned a JS array.
Comment 4 Ryosuke Niwa 2014-04-09 11:04:11 PDT
Also note that queryAll in DOM4 returns Elements, which is a subclass of Array so making querySelectorAll return Array or Elements when it's introduced will align the return types of two functions:

Excerpts from http://dom.spec.whatwg.org/#collections:-elements

interface ParentNode {
  readonly attribute HTMLCollection children;
  readonly attribute Element? firstElementChild;
  readonly attribute Element? lastElementChild;
  readonly attribute unsigned long childElementCount;

  void prepend((Node or DOMString)... nodes);
  void append((Node or DOMString)... nodes);

  Element? query(DOMString relativeSelectors);
  [NewObject] Elements queryAll(DOMString relativeSelectors);
  Element? querySelector(DOMString selectors);
  [NewObject] NodeList querySelectorAll(DOMString selectors);
};
Document implements ParentNode;
DocumentFragment implements ParentNode;
Element implements ParentNode;

class Elements extends Array {
  Element? query(DOMString relativeSelectors);
  Elements queryAll(DOMString relativeSelectors);
};
Comment 5 Ryosuke Niwa 2014-04-09 11:06:03 PDT
Erik (arv) from Google also says they will happily change Blink to match the new behavior if we successfully make this change on our side as well.
Comment 6 Ryosuke Niwa 2016-04-11 01:02:50 PDT
I think NodeList / HTMLCollection are now iteratorable so we should be able to fix this bug with that!
Comment 7 Brent Fulgham 2016-04-14 11:50:20 PDT
<rdar://problem/25731519>
Comment 8 Chris Dumez 2016-04-14 11:52:28 PDT
What is left to be done here concretely?
Comment 9 Ryosuke Niwa 2016-04-14 17:00:03 PDT
for (var e of document.all)
  console.log(e)

needs to work.  Someone from JSC team should be able to tell us what we need to make an object iterable.
Comment 10 Chris Dumez 2016-04-14 17:05:01 PDT
(In reply to comment #9)
> for (var e of document.all)
>   console.log(e)
> 
> needs to work.  Someone from JSC team should be able to tell us what we need
> to make an object iterable.

document.all ??
Comment 11 Ryosuke Niwa 2016-04-14 17:06:10 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > for (var e of document.all)
> >   console.log(e)
> > 
> > needs to work.  Someone from JSC team should be able to tell us what we need
> > to make an object iterable.
> 
> document.all ??

Oh oops, this is about querySelectorAll, so it should be:

for (var e of document.querySelectorAll('*'))
  console.log(e)
Comment 12 Chris Dumez 2016-04-14 17:09:40 PDT
I see, so basically we need to make NodeList iterable to match the spec:
[Exposed=Window]
interface NodeList {
  getter Node? item(unsigned long index);
  readonly attribute unsigned long length;
  iterable<Node>; // We are missing this.
};
Comment 13 youenn fablet 2016-05-03 07:38:30 PDT
Created attachment 277991 [details]
WIP
Comment 14 youenn fablet 2016-05-03 08:00:33 PDT
Created attachment 277995 [details]
Rebasing WIP
Comment 15 Darin Adler 2016-05-03 08:13:42 PDT
Comment on attachment 277991 [details]
WIP

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

> Source/WebCore/css/FontFaceSet.cpp:89
> +    return RefPtr<FontFace>(m_target->backing()[m_index++].wrapper(state));

What error do we get without the explicit RefPtr<FontFace> typecast?

> Source/WebCore/css/FontFaceSet.h:64
> +        Optional<RefPtr<FontFace>> next(JSC::ExecState&);

I’d like to know more about the type Optional<RefPtr<X>> for this? Is there a distinct null value separate from Nullopt? Can this just be RefPtr and use nullptr to mean null?

> Source/WebCore/dom/NodeList.h:34
> +};

Semicolon here is incorrect.
Comment 16 Darin Adler 2016-05-03 08:14:20 PDT
Comment on attachment 277995 [details]
Rebasing WIP

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

> Source/WebCore/css/FontFaceSet.h:64
> +        Optional<RefPtr<FontFace>> next(JSC::ExecState&);

Another question about the return type: Does this need to be RefPtr instead of a raw pointer? If so, why?
Comment 17 Build Bot 2016-05-03 08:33:27 PDT
Comment on attachment 277995 [details]
Rebasing WIP

Attachment 277995 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/1261213

New failing tests:
fast/dom/domListEnumeration.html
fast/text/font-face-set-javascript.html
Comment 18 Build Bot 2016-05-03 08:33:34 PDT
Created attachment 277998 [details]
Archive of layout-test-results from ews103 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 19 Build Bot 2016-05-03 08:51:23 PDT
Comment on attachment 277995 [details]
Rebasing WIP

Attachment 277995 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1261227

New failing tests:
fast/dom/domListEnumeration.html
fast/text/font-face-set-javascript.html
Comment 20 Build Bot 2016-05-03 08:51:28 PDT
Created attachment 278000 [details]
Archive of layout-test-results from ews113 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 21 Build Bot 2016-05-03 08:53:30 PDT
Comment on attachment 277995 [details]
Rebasing WIP

Attachment 277995 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1261280

New failing tests:
fast/dom/domListEnumeration.html
fast/text/font-face-set-javascript.html
Comment 22 Build Bot 2016-05-03 08:53:34 PDT
Created attachment 278001 [details]
Archive of layout-test-results from ews105 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 23 Build Bot 2016-05-03 09:00:13 PDT
Comment on attachment 277995 [details]
Rebasing WIP

Attachment 277995 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/1261287

New failing tests:
fast/dom/domListEnumeration.html
fast/text/font-face-set-javascript.html
Comment 24 Build Bot 2016-05-03 09:00:18 PDT
Created attachment 278002 [details]
Archive of layout-test-results from ews123 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.4
Comment 25 youenn fablet 2016-05-03 10:26:59 PDT
> I’d like to know more about the type Optional<RefPtr<X>> for this? Is there
> a distinct null value separate from Nullopt? Can this just be RefPtr and use
> nullptr to mean null?

I wanted to check that and will update the patch if there cannot be a null JS value in the iteration.
JSKeyValueIterator updated implementation should just require operator* and operator bool() for set iterators.

> > Source/WebCore/css/FontFaceSet.h:64
> > +        Optional<RefPtr<FontFace>> next(JSC::ExecState&);
> 
> Another question about the return type: Does this need to be RefPtr instead
> of a raw pointer? If so, why?

I seem to recall there was a need for it but do not remember that.
Probably mmaxfield would know more about this.
Comment 26 Ryosuke Niwa 2016-05-03 10:32:01 PDT
Comment on attachment 277995 [details]
Rebasing WIP

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

> Source/WebCore/dom/NodeList.h:69
> +    if (m_index < m_list->length())

This is inefficient because length() can cache the entire node list / collection.
Just call item(m_index++) and check the return type instead.
Comment 27 WebKit Commit Bot 2016-05-03 17:29:52 PDT
Attachment 277995 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/NodeList.h:50:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
Total errors found: 1 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 28 youenn fablet 2016-05-04 05:15:14 PDT
Created attachment 278080 [details]
Patch
Comment 29 WebKit Commit Bot 2016-05-04 05:16:55 PDT
Attachment 278080 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/NodeList.h:49:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
Total errors found: 1 in 12 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 30 youenn fablet 2016-05-04 05:52:40 PDT
Comment on attachment 278080 [details]
Patch

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

> Source/WebCore/dom/NodeList.h:33
> +};

Will i
Comment 31 Build Bot 2016-05-04 05:54:54 PDT
Comment on attachment 278080 [details]
Patch

Attachment 278080 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/1265801

New failing tests:
imported/w3c/web-platform-tests/fetch/api/headers/headers-basic.html
Comment 32 Build Bot 2016-05-04 05:55:00 PDT
Created attachment 278084 [details]
Archive of layout-test-results from ews101 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 33 youenn fablet 2016-05-04 05:55:59 PDT
> > Source/WebCore/css/FontFaceSet.h:64
> > +        Optional<RefPtr<FontFace>> next(JSC::ExecState&);
> 
> I’d like to know more about the type Optional<RefPtr<X>> for this? Is there
> a distinct null value separate from Nullopt? Can this just be RefPtr and use
> nullptr to mean null?

I think it can be a RefPtr<> since CSSFontFace.wrapper() is returning a Ref<>.
nullptr will mean end of the iteration.

CSSFontFace is creating a FontFace (and keeping a WeakPtr).
I don't know the reason but this require using a RefPtr<> as returned value to next().

> > Source/WebCore/dom/NodeList.h:34
> > +};
> 
> Semicolon here is incorrect.

OK, forgot to fix it in uploaded patch but will do in next one.

> > Source/WebCore/dom/NodeList.h:69
> > +    if (m_index < m_list->length())
> 
> This is inefficient because length() can cache the entire node list /
> collection.
> Just call item(m_index++) and check the return type instead.

OK
Comment 34 Build Bot 2016-05-04 06:05:14 PDT
Comment on attachment 278080 [details]
Patch

Attachment 278080 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/1265806

New failing tests:
imported/w3c/web-platform-tests/fetch/api/headers/headers-basic.html
Comment 35 Build Bot 2016-05-04 06:05:20 PDT
Created attachment 278085 [details]
Archive of layout-test-results from ews126 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews126  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.4
Comment 36 Build Bot 2016-05-04 06:08:30 PDT
Comment on attachment 278080 [details]
Patch

Attachment 278080 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1265833

New failing tests:
imported/w3c/web-platform-tests/fetch/api/headers/headers-basic.html
Comment 37 Build Bot 2016-05-04 06:08:36 PDT
Created attachment 278086 [details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 38 Build Bot 2016-05-04 06:24:57 PDT
Comment on attachment 278080 [details]
Patch

Attachment 278080 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1265847

New failing tests:
imported/w3c/web-platform-tests/fetch/api/headers/headers-basic.html
Comment 39 Build Bot 2016-05-04 06:25:03 PDT
Created attachment 278087 [details]
Archive of layout-test-results from ews115 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 40 youenn fablet 2016-05-04 06:29:23 PDT
Created attachment 278088 [details]
Fixing key/value order
Comment 41 WebKit Commit Bot 2016-05-04 06:31:39 PDT
Attachment 278088 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/NodeList.h:49:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 42 Darin Adler 2016-05-04 08:35:33 PDT
Comment on attachment 278088 [details]
Fixing key/value order

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

Looks good.

When we have function templates in a header, I think it’s useful to declare the templates first and then define them, so we can look at the declarations and get an overview of what’s present. If we just put all the template definitions in, then the implementation and interface are all mixed up.

For bindings code, I think it’s valuable to use generic programming techniques. This means that we want to use overloading rather than naming the types of the arguments in function names, letting the type system work for us to make our code less type specific. That’s why there are a lot of pre-existing functions named "toJS", and I think that "iteratorValueToJS" should just be named toJS. Or some other clearer name, but not one that specifies which types are involved. I suggest we also consider giving fillForEachArgumentsWithIteratorValue a shorter name that doesn’t name the type involved. Maybe appendForEachArguments.

> Source/WebCore/dom/NodeList.h:49
> +        explicit Iterator(NodeList& list) : m_list(list) { }

I think this can probably be private. I believe that the outer class gets access to the private members of classes that are nested inside it.
Comment 43 youenn fablet 2016-05-04 08:48:58 PDT
(In reply to comment #42)
> Comment on attachment 278088 [details]
> Fixing key/value order
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=278088&action=review
> 
> Looks good.
> 
> When we have function templates in a header, I think it’s useful to declare
> the templates first and then define them, so we can look at the declarations
> and get an overview of what’s present. If we just put all the template
> definitions in, then the implementation and interface are all mixed up.
> 
> For bindings code, I think it’s valuable to use generic programming
> techniques. This means that we want to use overloading rather than naming
> the types of the arguments in function names, letting the type system work
> for us to make our code less type specific. That’s why there are a lot of
> pre-existing functions named "toJS", and I think that "iteratorValueToJS"
> should just be named toJS. Or some other clearer name, but not one that
> specifies which types are involved. I suggest we also consider giving
> fillForEachArgumentsWithIteratorValue a shorter name that doesn’t name the
> type involved. Maybe appendForEachArguments.
> 
> > Source/WebCore/dom/NodeList.h:49
> > +        explicit Iterator(NodeList& list) : m_list(list) { }
> 
> I think this can probably be private. I believe that the outer class gets
> access to the private members of classes that are nested inside it.

Thanks, I'll try to improve the patch accordingly.

There is an additional thing which I am not yet sure about.
Currently, DOMClass::Iterators are keeping a Ref<> to the iterated object.
I wonder whether we might want to move that to a RefPtr<>.

That would allow releasing the ref when the iterator is done.
That would also ensure that a "done: true" iterator could never be "done: false" later on, like in the case of an inserted node in NodeList or if calling NodeList::Iterator::next() enough times so that the iterator index is back to zero.
Comment 44 youenn fablet 2016-05-04 09:25:22 PDT
I'll tackle this issue in a follow up patch, maybe at JSDomIterator level.
Comment 45 youenn fablet 2016-05-07 12:52:39 PDT
Created attachment 278335 [details]
Patch
Comment 46 WebKit Commit Bot 2016-05-07 12:55:17 PDT
Attachment 278335 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/NodeList.h:49:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 47 Build Bot 2016-05-07 13:45:46 PDT
Comment on attachment 278335 [details]
Patch

Attachment 278335 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/1283661

New failing tests:
inspector/console/command-line-api.html
Comment 48 Build Bot 2016-05-07 13:45:53 PDT
Created attachment 278338 [details]
Archive of layout-test-results from ews103 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 49 Build Bot 2016-05-07 13:46:21 PDT
Comment on attachment 278335 [details]
Patch

Attachment 278335 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1283657

New failing tests:
inspector/console/command-line-api.html
Comment 50 Build Bot 2016-05-07 13:46:27 PDT
Created attachment 278339 [details]
Archive of layout-test-results from ews105 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 51 Build Bot 2016-05-07 14:10:11 PDT
Comment on attachment 278335 [details]
Patch

Attachment 278335 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1283666

New failing tests:
inspector/console/command-line-api.html
Comment 52 Build Bot 2016-05-07 14:10:17 PDT
Created attachment 278340 [details]
Archive of layout-test-results from ews117 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 53 youenn fablet 2016-05-09 06:37:00 PDT
Created attachment 278404 [details]
Fixing for-of loop for set iterators
Comment 54 WebKit Commit Bot 2016-05-09 06:39:51 PDT
Attachment 278404 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/NodeList.h:45:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
Total errors found: 1 in 19 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 55 youenn fablet 2016-05-09 07:24:37 PDT
(In reply to comment #53)
> Created attachment 278404 [details]
> Fixing for-of loop for set iterators

This patch does not provide the correct behavior for entries and forEach for set iterators (a counter value should be provided).
Also, it does not ensure done iterators remain done.

I plan to fix these two limitations in a follow-up patch.
Comment 56 Darin Adler 2016-05-09 19:54:46 PDT
Comment on attachment 278404 [details]
Fixing for-of loop for set iterators

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

Do we really need to call this createDOMIterator and domIteratorForEach? Maybe instead iteratorCreate and iteratorForEach?

> Source/WebCore/bindings/js/JSDOMBinding.h:647
> +template<typename Value1, typename Value2> inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, const Value1& value1, const Value2& value2)

The types should not be named "Value".
Comment 57 youenn fablet 2016-05-10 00:16:39 PDT
Created attachment 278482 [details]
Patch for landing
Comment 58 youenn fablet 2016-05-10 00:17:37 PDT
(In reply to comment #56)
> Comment on attachment 278404 [details]
> Fixing for-of loop for set iterators
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=278404&action=review
> 
> Do we really need to call this createDOMIterator and domIteratorForEach?
> Maybe instead iteratorCreate and iteratorForEach?

OK.

> > Source/WebCore/bindings/js/JSDOMBinding.h:647
> > +template<typename Value1, typename Value2> inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, const Value1& value1, const Value2& value2)
> 
> The types should not be named "Value".

Updated to FirstType/SecondType.
Comment 59 WebKit Commit Bot 2016-05-10 02:46:57 PDT
Comment on attachment 278482 [details]
Patch for landing

Clearing flags on attachment: 278482

Committed r200619: <http://trac.webkit.org/changeset/200619>
Comment 60 WebKit Commit Bot 2016-05-10 02:47:06 PDT
All reviewed patches have been landed.  Closing bug.
Comment 61 Chris Dumez 2016-06-21 15:57:02 PDT
Comment on attachment 278482 [details]
Patch for landing

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

> LayoutTests/fast/dom/nodeListIterator-expected.txt:12
> +FAIL forEachIndex should be 0 (of type number). Was [object HTMLDivElement] (of type object).

What are all these FAIL lines?
Comment 62 Chris Dumez 2016-06-21 16:20:57 PDT
This patch seems to have broken m.yahoo.co.jp (content does not load at the bottom of the page).

JS Error:
[Error] TypeError: this.isCollectedElem is not a function. (In 'this.isCollectedElem(b)', 'this.isCollectedElem' is undefined)
	(anonymous function) (rappie_stream-1.8.0.js:4:6139)
	forEach
	forEach (rappie_stream-1.8.0.js:3:1710)
	collectTargets (rappie_stream-1.8.0.js:4:6018)
	(anonymous function) (rappie_stream-1.8.0.js:4:5450)
	forEach
	forEach (rappie_stream-1.8.0.js:3:1710)
	initRapid (rappie_stream-1.8.0.js:4:5380)
	r (rappie_stream-1.8.0.js:4:4024)
	(anonymous function) (rappie_stream-1.8.0.js:4:11207)
	(anonymous function) (rappie_stream-1.8.0.js:4:11497)
	Global Code (rappie_stream-1.8.0.js:4:11500)
[Error] TypeError: undefined is not an object (evaluating 'RappieStream.setNewPageParameter')
	initializer (mtop-page-top.js:657:2451)
	_initHierarchy (mtop-page-top.js:197:3768)
	_baseInit (mtop-page-top.js:197:1101)
	init (mtop-page-top.js:205:704)
	_initBase (mtop-page-top.js:197:954)
	v (mtop-page-top.js:197:105)
	o (mtop-page-top.js:213)
	n (mtop-page-top.js:279)
	r (mtop-page-top.js:639:3635)
	o (mtop-page-top.js:657:1955)
	initializer (mtop-page-top.js:655:288)
	_initHierarchy (mtop-page-top.js:197:3768)
	_baseInit (mtop-page-top.js:197:1101)
	init (mtop-page-top.js:205:704)
	_initBase (mtop-page-top.js:197:954)
	v (mtop-page-top.js:197:105)
	o (mtop-page-top.js:213)
	n (mtop-page-top.js:279)
	r (mtop-page-top.js:639:3635)
	r (mtop-page-top.js:654:5182)
	initializer (mtop-page-top.js:639:3251)
	r (mtop-page-top.js:639:1784)
	(anonymous function) (mtop-page-top.js:676)
	_notify (mtop-page-top.js:9:1497)
	(anonymous function) (mtop-page-top.js:9:974)
	_notify (mtop-page-top.js:9:1497)
	T (mtop-page-top.js:9:2429)
	_finish (mtop-page-top.js:16:4858)
	_onSuccess (mtop-page-top.js:16:5375)
	p (mtop-page-top.js:17:1326)
	_insert (mtop-page-top.js:17:1390)
	(anonymous function) (mtop-page-top.js:17:2386)
	_continue (mtop-page-top.js:17:2273)
	insert (mtop-page-top.js:17:2412)
	_use (mtop-page-top.js:9:2988)
	use (mtop-page-top.js:9:948)
	Global Code (mtop-page-top.js:676)


The page falls back nicely if forEach is not available:
            forEach: function(a, b, c) {
                if (a.forEach)
                    a.forEach(b, c);
                else
                    for (var d = 0; d < a.length; d++)
                        b.call(c, a[d], d, a)
            },

So presumably the if and else code paths are currently not equivalent.

c.f. rdar://problem/26812953
Comment 63 Jiewen Tan 2016-06-21 16:24:57 PDT
Reverted r200619 for reason:

This incompleted feature broke http://m.yahoo.co.jp. Roll it out together with r200678.

Committed r202303: <http://trac.webkit.org/changeset/202303>
Comment 64 Jiewen Tan 2016-06-21 17:05:10 PDT
Reverted r202302, r202303, r202305, and r202306 for reason:

Roll out the rollouts because of breaking the build.

Committed r202307: <http://trac.webkit.org/changeset/202307>
Comment 65 youenn fablet 2016-06-21 23:59:24 PDT
(In reply to comment #61)
> Comment on attachment 278482 [details]
> Patch for landing
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=278482&action=review
> 
> > LayoutTests/fast/dom/nodeListIterator-expected.txt:12
> > +FAIL forEachIndex should be 0 (of type number). Was [object HTMLDivElement] (of type object).
> 
> What are all these FAIL lines?

This was fixed in bug 157453.
Comment 66 youenn fablet 2016-06-22 00:04:41 PDT
It might be that support for thisArg is missing. Let me check further.
Comment 67 youenn fablet 2016-06-22 02:45:14 PDT
(In reply to comment #66)
> It might be that support for thisArg is missing. Let me check further.

I filed bug 159020 for that purpose.
Comment 68 youenn fablet 2016-06-22 11:00:19 PDT
Can we close this one and bug 157453?
Comment 69 Chris Dumez 2016-06-22 11:05:35 PDT
(In reply to comment #68)
> Can we close this one and bug 157453?

Yes, they eventually weren't rolled out after all.
Comment 70 Chris Dumez 2016-06-22 11:06:09 PDT
Jiewen will follow up if issues remain but things looked good to me after your fix.