[WebIDL] Support serializing sequences and FrozenArrays of non-interfaces
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Feb 2019 18:18:28 +0000 (18:18 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Feb 2019 18:18:28 +0000 (18:18 +0000)
commitef80851836cc78d89e21d9fa194efab806fb6ef0
tree71c06cdcc580f35ce49912f8a4ce4ef84ce80dc6
parentfbb6dbaaeb8c4d69ba2b867c575f94929b125b6c
[WebIDL] Support serializing sequences and FrozenArrays of non-interfaces
https://bugs.webkit.org/show_bug.cgi?id=190997
<rdar://problem/35983035>

Reviewed by Brent Fulgham.

Source/WebCore:

Support serializing sequences and FrozenArrays of types that aren't interfaces. This is
needed to properly serialize PaymentAddress, which has a FrozenArray of DOMStrings.

We should support serializing sequences of interfaces too, but that's slightly more
complicated since it involves iterating the sequence and serializing each of its items. I
left that as a follow-up task, since I don't see any IDLs that currently need this.

We also don't support serializing sequences with the CachedAttribute or CustomGetter
extended attributes, because WebIDL specifies that a new array should be created when
converting an IDL sequence into an ECMAScript value.

Added bindings test cases to TestSerialization.idl and PaymentAddress test cases to
http/tests/paymentrequest/payment-address-attributes-and-toJSON-method.https.html.

* bindings/scripts/CodeGenerator.pm:
(GetInterfaceForType): Renamed from GetInterfaceForAttribute.
(IsSerializableType): Modified to allow sequences and FrozenArrays of non-interface types.
(hasCachedAttributeOrCustomGetterExtendedAttribute): Added a helper to determine if an
attribute has the CachedAttribute or CustomGetter extended attributes.
(IsSerializableAttribute): Checked for sequences with the CachedAttribute or CustomGetter
extended attributes before calling IsSerializableType.
(GetInterfaceForAttribute): Renamed to GetInterfaceForType.
* bindings/scripts/test/JS/JSTestSerialization.cpp:
* bindings/scripts/test/TestSerialization.idl:

LayoutTests:

* http/tests/paymentrequest/payment-address-attributes-and-toJSON-method.https.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241198 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/paymentrequest/payment-address-attributes-and-toJSON-method.https.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp
Source/WebCore/bindings/scripts/test/TestSerialization.idl