Changeset 206966 in webkit
- Timestamp:
- Oct 9, 2016 12:34:08 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206965 r206966 1 2016-10-09 Youenn Fablet <youenn@apple.com> 2 3 Promise attribute getters should reject promises in case of casted-this errors 4 https://bugs.webkit.org/show_bug.cgi?id=163167 5 6 Reviewed by Darin Adler. 7 8 * fast/text/font-face-set-javascript-expected.txt: 9 * fast/text/font-face-set-javascript.html: 10 1 11 2016-10-08 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/LayoutTests/fast/text/font-face-set-javascript-expected.txt
r204500 r206966 60 60 PASS fontFaceSet.status is "loading" 61 61 PASS item is fontFaceSet 62 PASS TypeError: The FontFaceSet.ready getter can only be used on instances of FontFaceSet 62 63 PASS successfullyParsed is true 63 64 -
trunk/LayoutTests/fast/text/font-face-set-javascript.html
r204500 r206966 164 164 item = arg; 165 165 shouldBe("item", "fontFaceSet"); 166 }, function(arg) { 167 testFailed("Ready attribute should never fail"); 168 }).then(function() { 169 return Object.getOwnPropertyDescriptor(Object.getPrototypeOf(fontFaceSet), 'ready').get.apply(fontFace5); 170 }).then(function(arg) { 171 testFailed("Ready attribute should be rejected when used with an object which is not FontFaceSet"); 166 172 finishJSTest(); 167 173 }, function(arg) { 168 test Failed("Ready attribute should never fail");174 testPassed("" + arg); 169 175 finishJSTest(); 170 176 }); -
trunk/Source/WebCore/ChangeLog
r206965 r206966 1 2016-10-09 Youenn Fablet <youenn@apple.com> 2 3 Promise attribute getters should reject promises in case of casted-this errors 4 https://bugs.webkit.org/show_bug.cgi?id=163167 5 6 Reviewed by Darin Adler. 7 8 Covered by updated test and binding test. 9 10 * bindings/js/JSDOMBinding.cpp: 11 (WebCore::throwGetterTypeError): 12 (WebCore::rejectPromiseWithGetterTypeError): Added to reject promises for attribute getters 13 * bindings/js/JSDOMBinding.h: 14 (WebCore::BindingCaller::attribute): Introducing promise rejection for type cast errors. 15 * bindings/scripts/CodeGeneratorJS.pm: 16 (GenerateImplementation): 17 * bindings/scripts/test/JS/JSTestObj.cpp: Rebased test. As can be seen, only custom promise attributes are supported. 18 (WebCore::jsTestObjTestReadOnlyPromiseAttribute): 19 (WebCore::jsTestObjTestReadOnlyPromiseAttributeGetter): 20 * bindings/scripts/test/TestObj.idl: 21 1 22 2016-10-08 Chris Dumez <cdumez@apple.com> 2 23 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r206960 r206966 33 33 #include "IDBDatabaseException.h" 34 34 #include "JSDOMConvert.h" 35 #include "JSDOMPromise.h" 35 36 #include "JSDOMWindowCustom.h" 36 37 #include "JSExceptionBase.h" … … 974 975 } 975 976 977 JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName) 978 { 979 return createRejectedPromiseWithTypeError(state, makeGetterTypeErrorMessage(interfaceName, attributeName)); 980 } 981 976 982 bool throwSetterTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName) 977 983 { -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r206960 r206966 135 135 WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* functionName); 136 136 137 JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::ExecState&, const char* interfaceName, const char* attributeName); 138 137 139 WEBCORE_EXPORT JSC::Structure* getCachedDOMStructure(JSDOMGlobalObject&, const JSC::ClassInfo*); 138 140 WEBCORE_EXPORT JSC::Structure* cacheDOMStructure(JSDOMGlobalObject&, JSC::Structure*, const JSC::ClassInfo*); … … 330 332 331 333 332 enum class CastedThisErrorBehavior { Throw, ReturnEarly };334 enum class CastedThisErrorBehavior { Throw, ReturnEarly, RejectPromise }; 333 335 334 336 template<typename JSClass> … … 344 346 if (UNLIKELY(!thisObject)) { 345 347 ASSERT(JSClass::info()); 346 return shouldThrow == CastedThisErrorBehavior::Throw ? 347 throwGetterTypeError(*state, throwScope, JSClass::info()->className, attributeName) : JSC::JSValue::encode(JSC::jsUndefined()); 348 if (shouldThrow == CastedThisErrorBehavior::Throw) 349 return throwGetterTypeError(*state, throwScope, JSClass::info()->className, attributeName); 350 if (shouldThrow == CastedThisErrorBehavior::RejectPromise) 351 return rejectPromiseWithGetterTypeError(*state, JSClass::info()->className, attributeName); 352 return JSC::JSValue::encode(JSC::jsUndefined()); 348 353 } 349 354 // FIXME: We should refactor the binding generated code to use references for state and thisObject. -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r206964 r206966 2921 2921 if (!$attribute->isStatic || $attribute->signature->type =~ /Constructor$/) { 2922 2922 my $templateParameters = "${getFunctionName}Getter"; 2923 $templateParameters .= ", CastedThisErrorBehavior::ReturnEarly" if ($attribute->signature->extendedAttributes->{LenientThis}); 2923 if ($attribute->signature->extendedAttributes->{LenientThis}) { 2924 $templateParameters .= ", CastedThisErrorBehavior::ReturnEarly"; 2925 } elsif (IsReturningPromise($attribute)) { 2926 $templateParameters .= ", CastedThisErrorBehavior::RejectPromise"; 2927 } 2928 2924 2929 push(@implContent, "static inline JSValue ${getFunctionName}Getter(ExecState*, ${className}*, ThrowScope& throwScope);\n\n"); 2925 2930 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r206964 r206966 45 45 #include "JSFetchRequest.h" 46 46 #include "JSNode.h" 47 #include "JSPromise.h" 47 48 #include "JSSVGDocument.h" 48 49 #include "JSSVGPoint.h" … … 1192 1193 JSC::EncodedJSValue jsTestObjAttributeWithReservedEnumType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); 1193 1194 bool setJSTestObjAttributeWithReservedEnumType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); 1195 JSC::EncodedJSValue jsTestObjTestReadOnlyPromiseAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); 1194 1196 JSC::EncodedJSValue jsTestObjPutForwardsAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); 1195 1197 bool setJSTestObjPutForwardsAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); … … 1480 1482 { "attribute", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, 1481 1483 { "attributeWithReservedEnumType", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttributeWithReservedEnumType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttributeWithReservedEnumType) } }, 1484 { "testReadOnlyPromiseAttribute", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestReadOnlyPromiseAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, 1482 1485 { "putForwardsAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjPutForwardsAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjPutForwardsAttribute) } }, 1483 1486 { "putForwardsNullableAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjPutForwardsNullableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjPutForwardsNullableAttribute) } }, … … 3186 3189 } 3187 3190 3191 static inline JSValue jsTestObjTestReadOnlyPromiseAttributeGetter(ExecState*, JSTestObj*, ThrowScope& throwScope); 3192 3193 EncodedJSValue jsTestObjTestReadOnlyPromiseAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName) 3194 { 3195 return BindingCaller<JSTestObj>::attribute<jsTestObjTestReadOnlyPromiseAttributeGetter, CastedThisErrorBehavior::RejectPromise>(state, thisValue, "testReadOnlyPromiseAttribute"); 3196 } 3197 3198 static inline JSValue jsTestObjTestReadOnlyPromiseAttributeGetter(ExecState* state, JSTestObj* thisObject, ThrowScope& throwScope) 3199 { 3200 UNUSED_PARAM(throwScope); 3201 UNUSED_PARAM(state); 3202 auto& impl = thisObject->wrapped(); 3203 JSValue result = toJS(state, thisObject->globalObject(), impl.testReadOnlyPromiseAttribute()); 3204 return result; 3205 } 3206 3188 3207 static inline JSValue jsTestObjPutForwardsAttributeGetter(ExecState*, JSTestObj*, ThrowScope& throwScope); 3189 3208 -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r206964 r206966 387 387 void _any(unrestricted float a, long b); 388 388 389 390 readonly attribute Promise testReadOnlyPromiseAttribute; 389 391 // Promise function 390 392 Promise testPromiseFunction();
Note: See TracChangeset
for help on using the changeset viewer.