Changeset 263638 in webkit
- Timestamp:
- Jun 28, 2020 3:49:40 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r263633 r263638 1 2020-06-28 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Improve error message for primitive callback interfaces 4 https://bugs.webkit.org/show_bug.cgi?id=213684 5 6 Reviewed by Darin Adler. 7 8 * fast/dom/createNodeIterator-parameters-expected.txt: 9 * fast/dom/createNodeIterator-parameters.html: 10 * fast/dom/createTreeWalker-parameters-expected.txt: 11 * fast/dom/createTreeWalker-parameters.html: 12 1 13 2020-06-28 Youenn Fablet <youenn@apple.com> 2 14 -
trunk/LayoutTests/fast/dom/createNodeIterator-parameters-expected.txt
r200583 r263638 9 9 Null root node 10 10 PASS document.createNodeIterator(null) threw exception TypeError: Argument 1 ('root') to Document.createNodeIterator must be an instance of Node. 11 12 Primitive (symbol) NodeFilter callback 13 PASS document.createNodeIterator(document, null, Symbol()) threw exception TypeError: Argument 3 ('filter') to Document.createNodeIterator must be an object. 11 14 12 15 Default parameters -
trunk/LayoutTests/fast/dom/createNodeIterator-parameters.html
r200583 r263638 12 12 debug("Null root node"); 13 13 shouldThrow("document.createNodeIterator(null)", "'TypeError: Argument 1 (\\'root\\') to Document.createNodeIterator must be an instance of Node'"); 14 15 debug(""); 16 debug("Primitive (symbol) NodeFilter callback"); 17 shouldThrow("document.createNodeIterator(document, null, Symbol())", "'TypeError: Argument 3 (\\'filter\\') to Document.createNodeIterator must be an object'"); 14 18 15 19 debug(""); -
trunk/LayoutTests/fast/dom/createTreeWalker-parameters-expected.txt
r200583 r263638 9 9 Null root node 10 10 PASS document.createTreeWalker(null) threw exception TypeError: Argument 1 ('root') to Document.createTreeWalker must be an instance of Node. 11 12 Primitive (string) NodeFilter callback 13 PASS document.createTreeWalker(document, null, 'str') threw exception TypeError: Argument 3 ('filter') to Document.createTreeWalker must be an object. 11 14 12 15 Default parameters -
trunk/LayoutTests/fast/dom/createTreeWalker-parameters.html
r200583 r263638 12 12 debug("Null root node"); 13 13 shouldThrow("document.createTreeWalker(null)", "'TypeError: Argument 1 (\\'root\\') to Document.createTreeWalker must be an instance of Node'"); 14 15 debug(""); 16 debug("Primitive (string) NodeFilter callback"); 17 shouldThrow("document.createTreeWalker(document, null, 'str')", "'TypeError: Argument 3 (\\'filter\\') to Document.createTreeWalker must be an object'"); 14 18 15 19 debug(""); -
trunk/Source/WebCore/ChangeLog
r263637 r263638 1 2020-06-28 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Improve error message for primitive callback interfaces 4 https://bugs.webkit.org/show_bug.cgi?id=213684 5 6 Reviewed by Darin Adler. 7 8 This patch rewords TypeError message for non-object callback interfaces 9 because apart from function, an object with certain method is also allowed. 10 New error message matches Chrome and Firefox. 11 12 Tests: fast/dom/createNodeIterator-parameters.html 13 fast/dom/createTreeWalker-parameters.html 14 15 * bindings/js/JSDOMExceptionHandling.cpp: 16 (WebCore::throwArgumentMustBeObjectError): 17 * bindings/js/JSDOMExceptionHandling.h: 18 * bindings/scripts/CodeGeneratorJS.pm: 19 (GetArgumentExceptionFunction): 20 * bindings/scripts/test/*: Updated. 21 1 22 2020-06-28 Rob Buis <rbuis@igalia.com> 2 23 -
trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp
r251425 r263638 213 213 } 214 214 215 JSC::EncodedJSValue throwArgumentMustBeObjectError(JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope, unsigned argumentIndex, const char* argumentName, const char* interfaceName, const char* functionName) 216 { 217 StringBuilder builder; 218 appendArgumentMustBe(builder, argumentIndex, argumentName, interfaceName, functionName); 219 builder.appendLiteral("an object"); 220 return throwVMTypeError(&lexicalGlobalObject, scope, builder.toString()); 221 } 222 215 223 JSC::EncodedJSValue throwArgumentTypeError(JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType) 216 224 { -
trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.h
r251445 r263638 51 51 WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentMustBeEnumError(JSC::JSGlobalObject&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedValues); 52 52 WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::JSGlobalObject&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName); 53 WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentMustBeObjectError(JSC::JSGlobalObject&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName); 53 54 WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentTypeError(JSC::JSGlobalObject&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType); 54 55 WEBCORE_EXPORT JSC::EncodedJSValue throwRequiredMemberTypeError(JSC::JSGlobalObject&, JSC::ThrowScope&, const char* memberName, const char* dictionaryName, const char* expectedType); -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r263628 r263638 1504 1504 my $typeName = GetTypeNameForDisplayInException($argument->type); 1505 1505 1506 if ($codeGenerator->IsCallbackInterface($argument->type) || $codeGenerator->IsCallbackFunction($argument->type)) { 1507 # FIXME: We should have specialized messages for callback interfaces vs. callback functions. 1506 if ($codeGenerator->IsCallbackInterface($argument->type)) { 1507 return "throwArgumentMustBeObjectError(lexicalGlobalObject, scope, ${argumentIndex}, \"${name}\", \"${visibleInterfaceName}\", ${quotedFunctionName});"; 1508 } 1509 1510 if ($codeGenerator->IsCallbackFunction($argument->type)) { 1508 1511 return "throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, ${argumentIndex}, \"${name}\", \"${visibleInterfaceName}\", ${quotedFunctionName});"; 1509 1512 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r262693 r263638 1973 1973 auto& document = downcast<Document>(*context); 1974 1974 EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); 1975 auto testCallback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBe FunctionError(lexicalGlobalObject, scope, 0, "testCallback", "TestObject", nullptr); });1975 auto testCallback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "testCallback", "TestObject", nullptr); }); 1976 1976 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 1977 1977 EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); … … 7371 7371 return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); 7372 7372 EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); 7373 auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBe FunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackArg"); });7373 auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackArg"); }); 7374 7374 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7375 7375 impl.methodWithCallbackArg(callback.releaseNonNull()); … … 7394 7394 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7395 7395 EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); 7396 auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument1.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBe FunctionError(lexicalGlobalObject, scope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackArg"); });7396 auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument1.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackArg"); }); 7397 7397 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7398 7398 impl.methodWithNonCallbackArgAndCallbackArg(WTFMove(nonCallback), callback.releaseNonNull()); … … 7412 7412 auto& impl = castedThis->wrapped(); 7413 7413 EnsureStillAliveScope argument0 = callFrame->argument(0); 7414 auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBe FunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackAndOptionalArg"); });7414 auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackAndOptionalArg"); }); 7415 7415 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7416 7416 impl.methodWithCallbackAndOptionalArg(WTFMove(callback)); … … 7490 7490 UNUSED_PARAM(throwScope); 7491 7491 EnsureStillAliveScope argument0 = callFrame->argument(0); 7492 auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBe FunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "staticMethodWithCallbackAndOptionalArg"); });7492 auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "staticMethodWithCallbackAndOptionalArg"); }); 7493 7493 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7494 7494 TestObj::staticMethodWithCallbackAndOptionalArg(WTFMove(callback)); … … 7509 7509 return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); 7510 7510 EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); 7511 auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBe FunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "staticMethodWithCallbackArg"); });7511 auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "staticMethodWithCallbackArg"); }); 7512 7512 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7513 7513 TestObj::staticMethodWithCallbackArg(callback.releaseNonNull()); … … 7639 7639 auto& impl = castedThis->wrapped(); 7640 7640 EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); 7641 auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBe FunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "overloadedMethod"); });7641 auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "overloadedMethod"); }); 7642 7642 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7643 7643 impl.overloadedMethod(callback.releaseNonNull()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
r262628 r263638 170 170 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 171 171 EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); 172 auto testCallbackInterface = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument2.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBe FunctionError(lexicalGlobalObject, scope, 2, "testCallbackInterface", "TestTypedefs", nullptr); });172 auto testCallbackInterface = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument2.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 2, "testCallbackInterface", "TestTypedefs", nullptr); }); 173 173 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 174 174 auto object = TestTypedefs::create(WTFMove(hello), testCallbackFunction.releaseNonNull(), testCallbackInterface.releaseNonNull());
Note: See TracChangeset
for help on using the changeset viewer.