bindings: Make the sequence conversion code more compliant with WebIDL.

Desktop / Chromium - raphael.kubo.da.costa [intel.com] - 19 April 2017 13:21 EDT

The existing bindings still referenced WebIDL array types that were removed from the spec in 2015, and converting JS types to IDL sequences with an algorithm that expected either a JS array (in which case it just iterated over each element) or an object that adhered to an outdated protocol where a "length" property was expected.

The current WebIDL sequence conversion steps are simpler and described in https://heycam.github.io/webidl/#es-sequence. In short, JS objects are converted to sequences via @@iterator and the regular iteration protocol of calling next() and checking the returned object.

This works with arrays as well as any object that implements a valid Symbol.iterator property. It opens the way for custom iterators, the lack of which was causing some layout tests to fail. In other words, any iterable JS object can now be converted into a sequence<>.

The downside is that the Blink-V8 communication required for calling @@iterator, invoking next() and checking objects on every iteration step is costlier than what we had before, so the "fast case" has been preserved for JS arrays (even though it is not 100% clear if this is a valid shortcut to take, it at least does not introduce any regression compared to the previous code).

This is part 1: several functions in V8Binding.h that implement the old conversion algorithm (e.g. ToMemberNativeArray(), ToImplArray(), ToV8Sequence() and ToImplSequence()) have not been removed yet, and their callers in the code base have not yet been changed. This will come at a later point in the future.

BUG=690428 R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org

Review-Url: https://codereview.chromium.org/2826673004 Cr-Commit-Position: refs/heads/master@{#465649}

941cc09 bindings: Make the sequence conversion code more compliant with WebIDL.
.../WebKit/LayoutTests/bindings/sequence-type.html | 207 +++++++++++++++++++++
.../aes-cbc/generateKey-failures-expected.txt | 4 +-
.../subtle/unwrapKey-badParameters-expected.txt | 2 +-
.../wpt/FileAPI/blob/Blob-constructor-expected.txt | 10 +-
.../fetch/api/headers/headers-record-expected.txt | 14 --
.../processing-a-keyframes-argument-expected.txt | 11 +-
.../canvas/canvas-lineDash-input-sequence.html | 23 ++-
.../fast/dom/idl-union-type-unittest-expected.txt | 12 +-
.../message-event-constructor-expected.txt | 26 +--
.../constructors/message-event-constructor.html | 2 +-
.../events/message-event-max-ports-expected.txt | 2 +-
.../fast/events/message-event-max-ports.html | 4 +-
.../fast/files/blob-constructor-expected.txt | 10 +-
.../LayoutTests/fast/files/blob-constructor.html | 61 +++---
.../fast/files/file-constructor-expected.txt | 10 +-
.../LayoutTests/fast/files/file-constructor.html | 21 ++-
.../MediaStreamConstructor-expected.txt | 8 +-
.../peerconnection/RTCPeerConnection-expected.txt | 8 +-
.../wpt/FileAPI/blob/Blob-constructor-expected.txt | 10 +-
.../wpt/FileAPI/blob/Blob-constructor-expected.txt | 10 +-
.../storage/websql/execute-sql-args-expected.txt | 6 +-
.../LayoutTests/storage/websql/execute-sql-args.js | 17 +-
.../fast/files/blob-constructor-expected.txt | 10 +-
.../webaudio/dom-exceptions-expected.txt | 6 +-
.../webaudio/dom-exceptions-expected.txt | 6 +-
.../sequence-conversion-custom-iterator.html | 30 +++
.../bindings/core/v8/NativeValueTraitsImpl.h | 116 +++++++++++-
.../bindings/core/v8/NativeValueTraitsImplTest.cpp | 178 ++++++++++++++++++
.../WebKit/Source/bindings/core/v8/ScriptValue.h | 10 +
.../WebKit/Source/bindings/core/v8/V8Binding.cpp | 17 ++
.../WebKit/Source/bindings/core/v8/V8Binding.h | 18 +-
.../WebKit/Source/bindings/scripts/v8_methods.py | 2 +-
.../WebKit/Source/bindings/scripts/v8_types.py | 49 +----
.../bindings/templates/union_container.cpp.tmpl | 5 +-
.../results/core/BooleanOrElementSequence.cpp | 4 +-
...equenceSequenceOrByteStringByteStringRecord.cpp | 4 +-
.../results/core/DoubleOrLongOrBooleanSequence.cpp | 4 +-
.../DoubleOrStringOrDoubleOrStringSequence.cpp | 4 +-
...entSequenceOrByteStringDoubleOrStringRecord.cpp | 4 +-
.../tests/results/core/LongSequenceOrEvent.cpp | 4 +-
...tOrStringOrStringByteStringOrNodeListRecord.cpp | 4 +-
.../tests/results/core/StringOrStringSequence.cpp | 4 +-
...ringSequenceCallbackFunctionLongSequenceArg.cpp | 2 +-
.../tests/results/core/V8TestDictionary.cpp | 16 +-
.../tests/results/core/V8TestDictionaryDerived.cpp | 2 +-
.../results/core/V8TestInterfaceConstructor.cpp | 6 +-
.../results/core/V8TestInterfaceConstructor2.cpp | 2 +-
.../bindings/tests/results/core/V8TestObject.cpp | 44 ++---
.../bindings/tests/results/core/V8TestTypedefs.cpp | 8 +-
third_party/WebKit/Source/core/BUILD.gn | 2 +
third_party/WebKit/Source/core/core_idl_files.gni | 1 +
.../WebKit/Source/core/testing/Internals.cpp | 5 +
third_party/WebKit/Source/core/testing/Internals.h | 2 +
.../WebKit/Source/core/testing/Internals.idl | 1 +
.../WebKit/Source/core/testing/SequenceTest.cpp | 54 ++++++
.../WebKit/Source/core/testing/SequenceTest.h | 49 +++++
.../WebKit/Source/core/testing/SequenceTest.idl | 24 +++
57 files changed, 918 insertions(+), 257 deletions(-)

Upstream: git.chromium.org


  • Share