WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-178542-20171020114336.patch (text/plain), 10.29 KB, created by
Andy Estes
on 2017-10-20 11:43:37 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andy Estes
Created:
2017-10-20 11:43:37 PDT
Size:
10.29 KB
patch
obsolete
>Subversion Revision: 223719 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1852e31a66c983c9b91894b7a3b6ce40b58d3966..4bdba1422dad9eeb794cddec238d89c9db3e17eb 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,15 @@ >+2017-10-20 Andy Estes <aestes@apple.com> >+ >+ Generated serializers do not properly handle optional interface attributes >+ https://bugs.webkit.org/show_bug.cgi?id=178542 >+ >+ Reviewed by Sam Weinig. >+ >+ * bindings/scripts/CodeGeneratorJS.pm: >+ (GenerateSerializerDefinition): >+ * bindings/scripts/test/JS/JSTestSerialization.cpp: >+ (WebCore::JSTestSerialization::serialize): >+ > 2017-10-19 Youenn Fablet <youenn@apple.com> > > Add preliminary support for ServiceWorker Handle Fetch >diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >index f143d74f580b88883d71996329f5e6cce541499d..595cd0d6d492978b81416a3d93aae4a75f129ce1 100644 >--- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >+++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >@@ -5255,8 +5255,16 @@ sub GenerateSerializerDefinition > > if ($codeGenerator->IsInterfaceType($attribute->type)) { > my $attributeInterfaceName = $attribute->type->name; >- push(@implContent, " auto* ${name}SerializedValue = JS${attributeInterfaceName}::serialize(state, *jsCast<JS${attributeInterfaceName}*>(${name}Value), globalObject, throwScope);\n"); >- push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}SerializedValue);\n"); >+ if ($attribute->type->isNullable) { >+ push(@implContent, " if (!${name}Value.isNull()) {\n"); >+ push(@implContent, " auto* ${name}SerializedValue = JS${attributeInterfaceName}::serialize(state, *jsCast<JS${attributeInterfaceName}*>(${name}Value), globalObject, throwScope);\n"); >+ push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}SerializedValue);\n"); >+ push(@implContent, " } else\n"); >+ push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n"); >+ } else { >+ push(@implContent, " auto* ${name}SerializedValue = JS${attributeInterfaceName}::serialize(state, *jsCast<JS${attributeInterfaceName}*>(${name}Value), globalObject, throwScope);\n"); >+ push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}SerializedValue);\n"); >+ } > } else { > push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n"); > } >diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp >index 7c919b85bcb9a2d02bfd1aa6213d55528d4c1919..f184f19349dd9d5fa4b1fda12c5309daaba2febe 100644 >--- a/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp >+++ b/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp >@@ -25,6 +25,7 @@ > #include "JSDOMBinding.h" > #include "JSDOMConstructorNotConstructable.h" > #include "JSDOMConvertInterface.h" >+#include "JSDOMConvertNullable.h" > #include "JSDOMConvertNumbers.h" > #include "JSDOMConvertStrings.h" > #include "JSDOMExceptionHandling.h" >@@ -67,6 +68,8 @@ JSC::EncodedJSValue jsTestSerializationSeventhDirectlySerializableAttribute(JSC: > bool setJSTestSerializationSeventhDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); > JSC::EncodedJSValue jsTestSerializationEighthIndirectlyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); > bool setJSTestSerializationEighthIndirectlyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); >+JSC::EncodedJSValue jsTestSerializationNinthOptionalDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); >+bool setJSTestSerializationNinthOptionalDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); > > class JSTestSerializationPrototype : public JSC::JSNonFinalObject { > public: >@@ -123,6 +126,7 @@ static const HashTableValue JSTestSerializationPrototypeTableValues[] = > { "sixthTypedefAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSixthTypedefAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSixthTypedefAttribute) } }, > { "seventhDirectlySerializableAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSeventhDirectlySerializableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSeventhDirectlySerializableAttribute) } }, > { "eighthIndirectlyAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationEighthIndirectlyAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationEighthIndirectlyAttribute) } }, >+ { "ninthOptionalDirectlySerializableAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationNinthOptionalDirectlySerializableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationNinthOptionalDirectlySerializableAttribute) } }, > { "toJSON", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestSerializationPrototypeFunctionToJSON), (intptr_t) (0) } }, > }; > >@@ -450,6 +454,37 @@ bool setJSTestSerializationEighthIndirectlyAttribute(ExecState* state, EncodedJS > return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationEighthIndirectlyAttributeSetter>(*state, thisValue, encodedValue, "eighthIndirectlyAttribute"); > } > >+static inline JSValue jsTestSerializationNinthOptionalDirectlySerializableAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope) >+{ >+ UNUSED_PARAM(throwScope); >+ UNUSED_PARAM(state); >+ auto& impl = thisObject.wrapped(); >+ JSValue result = toJS<IDLNullable<IDLInterface<TestSerializationInheritFinal>>>(state, *thisObject.globalObject(), throwScope, impl.ninthOptionalDirectlySerializableAttribute()); >+ return result; >+} >+ >+EncodedJSValue jsTestSerializationNinthOptionalDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName) >+{ >+ return IDLAttribute<JSTestSerialization>::get<jsTestSerializationNinthOptionalDirectlySerializableAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ninthOptionalDirectlySerializableAttribute"); >+} >+ >+static inline bool setJSTestSerializationNinthOptionalDirectlySerializableAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope) >+{ >+ UNUSED_PARAM(throwScope); >+ auto& impl = thisObject.wrapped(); >+ auto nativeValue = convert<IDLNullable<IDLInterface<TestSerializationInheritFinal>>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "ninthOptionalDirectlySerializableAttribute", "TestSerializationInheritFinal"); }); >+ RETURN_IF_EXCEPTION(throwScope, false); >+ AttributeSetter::call(state, throwScope, [&] { >+ return impl.setNinthOptionalDirectlySerializableAttribute(WTFMove(nativeValue)); >+ }); >+ return true; >+} >+ >+bool setJSTestSerializationNinthOptionalDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) >+{ >+ return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationNinthOptionalDirectlySerializableAttributeSetter>(*state, thisValue, encodedValue, "ninthOptionalDirectlySerializableAttribute"); >+} >+ > JSC::JSObject* JSTestSerialization::serialize(ExecState& state, JSTestSerialization& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope) > { > auto& vm = state.vm(); >@@ -485,6 +520,14 @@ JSC::JSObject* JSTestSerialization::serialize(ExecState& state, JSTestSerializat > auto* eighthIndirectlyAttributeSerializedValue = JSTestSerializationIndirectInheritance::serialize(state, *jsCast<JSTestSerializationIndirectInheritance*>(eighthIndirectlyAttributeValue), globalObject, throwScope); > result->putDirect(vm, Identifier::fromString(&vm, "eighthIndirectlyAttribute"), eighthIndirectlyAttributeSerializedValue); > >+ auto ninthOptionalDirectlySerializableAttributeValue = jsTestSerializationNinthOptionalDirectlySerializableAttributeGetter(state, thisObject, throwScope); >+ throwScope.assertNoException(); >+ if (!ninthOptionalDirectlySerializableAttributeValue.isNull()) { >+ auto* ninthOptionalDirectlySerializableAttributeSerializedValue = JSTestSerializationInheritFinal::serialize(state, *jsCast<JSTestSerializationInheritFinal*>(ninthOptionalDirectlySerializableAttributeValue), globalObject, throwScope); >+ result->putDirect(vm, Identifier::fromString(&vm, "ninthOptionalDirectlySerializableAttribute"), ninthOptionalDirectlySerializableAttributeSerializedValue); >+ } else >+ result->putDirect(vm, Identifier::fromString(&vm, "ninthOptionalDirectlySerializableAttribute"), ninthOptionalDirectlySerializableAttributeValue); >+ > return result; > } > >diff --git a/Source/WebCore/bindings/scripts/test/TestSerialization.idl b/Source/WebCore/bindings/scripts/test/TestSerialization.idl >index a6ead7f9e27491db591a0cd11bc653e398800657..0c72e919623e95b9215a2e72ef463a565537d68f 100644 >--- a/Source/WebCore/bindings/scripts/test/TestSerialization.idl >+++ b/Source/WebCore/bindings/scripts/test/TestSerialization.idl >@@ -35,6 +35,7 @@ interface TestSerialization { > > attribute TestSerializationInheritFinal seventhDirectlySerializableAttribute; > attribute TestSerializationIndirectInheritance eighthIndirectlyAttribute; >+ attribute TestSerializationInheritFinal? ninthOptionalDirectlySerializableAttribute; > > serializer = { attribute }; > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 178542
:
324285
|
324412
| 324421