URLSearchParams / Headers objects @@iterator is not as per Web IDL spec
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 23:07:40 +0000 (23:07 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 23:07:40 +0000 (23:07 +0000)
commite45e310edfad334009e0e054a90be26cf44966a7
tree6ab65d8f741bac85227942a5151ea26f263b293b
parentc5f26c8e66c96a242a5cec0fd0c7c69468965135
URLSearchParams / Headers objects @@iterator is not as per Web IDL spec
https://bugs.webkit.org/show_bug.cgi?id=172218

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline web-platform-tests that are now passing.

* web-platform-tests/fetch/api/headers/headers-idl-expected.txt:
* web-platform-tests/url/interfaces.any-expected.txt:
* web-platform-tests/url/interfaces.any.worker-expected.txt:

Source/WebCore:

Both URLSearchParams and Headers interfaces are iterable as per their
respective specification, and they both have a pair iterator:
- https://url.spec.whatwg.org/#interface-urlsearchparams
- https://fetch.spec.whatwg.org/#headers-class

As per the WebIDL specification for 'entries'[1], "If the interface has a pair
iterator, then the Function object is the value of the @@iterator property",
the value of @@iterator being defined at [2]. In WebKit, we were using
different values/functions for 'entries' and @@iterator, although those
functions were doing the same thing (and the right thing).

Also, as per [2], the name of the @@iterator function should be "entries",
which I also implemented in this patch. Previously, we were using
"[Symbol.Iterator]" as function name.

[1] https://heycam.github.io/webidl/#es-iterable-entries
[2] https://heycam.github.io/webidl/#es-iterator

No new tests, rebaselined existing tests.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
(GenerateImplementationIterableFunctions):
* bindings/scripts/test/JS/JSMapLike.cpp:
* bindings/scripts/test/JS/JSReadOnlyMapLike.cpp:
* bindings/scripts/test/JS/JSTestIterable.cpp:
(WebCore::JSTestIterablePrototype::finishCreation):
(WebCore::jsTestIterablePrototypeFunctionEntriesCaller):
* bindings/scripts/test/JS/JSTestNode.cpp:
(WebCore::JSTestNodePrototype::finishCreation):
(WebCore::jsTestNodePrototypeFunctionEntriesCaller):

LayoutTests:

* fast/text/font-face-set-javascript-expected.txt:
* fast/text/font-face-set-javascript.html:
Fix FontFaceSet test which wrong expected FontFaceSet's entries() to return
a pair iterator. It does not make sense to return a pair iterator here given
that this is not a key-value structure. FontFaceSet should not even have an
entries() method but this is an artifact of us using iterable<FontFace> instead of
setlike<FontFace> until we support setlike<> (Bug 159140).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217166 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/font-face-set-javascript-expected.txt
LayoutTests/fast/text/font-face-set-javascript.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-idl-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/interfaces.any-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/interfaces.any.worker-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSMapLike.cpp
Source/WebCore/bindings/scripts/test/JS/JSReadOnlyMapLike.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestIterable.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp