Changeset 133932 in webkit
- Timestamp:
- Nov 8, 2012 12:33:42 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r133930 r133932 1 2012-11-08 Erik Arvidsson <arv@chromium.org> 2 3 Wrong error type is thrown for type errors in callbacks 4 https://bugs.webkit.org/show_bug.cgi?id=101502 5 6 Reviewed by Adam Barth. 7 8 We should be throwing a TypeError and not a DOMException with code TYPE_MISMATCH_ERR. 9 10 http://www.w3.org/TR/WebIDL/#es-callback-function 11 12 * fast/mediastream/argument-types-expected.txt: 13 * fast/mediastream/peerconnection-argument-types-expected.txt: 14 * fast/mediastream/script-tests/argument-types.js: 15 * fast/mediastream/script-tests/peerconnection-argument-types.js: 16 * fast/workers/storage/open-database-inputs-sync-expected.txt: 17 1 18 2012-11-08 Yael Aharon <yael.aharon@intel.com> 2 19 -
trunk/LayoutTests/fast/mediastream/argument-types-expected.txt
r115810 r133932 23 23 PASS navigator.webkitGetUserMedia(-Infinity, emptyFunction) threw exception TypeError: Not an object.. 24 24 PASS navigator.webkitGetUserMedia(emptyFunction, emptyFunction) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 25 PASS navigator.webkitGetUserMedia({video: true}, "foobar") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.26 PASS navigator.webkitGetUserMedia({video: true}, undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.27 PASS navigator.webkitGetUserMedia({video: true}, null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.28 PASS navigator.webkitGetUserMedia({video: true}, {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.29 PASS navigator.webkitGetUserMedia({video: true}, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.30 PASS navigator.webkitGetUserMedia({video: true}, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.31 PASS navigator.webkitGetUserMedia({video: true}, Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.32 PASS navigator.webkitGetUserMedia({video: true}, -Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.25 PASS navigator.webkitGetUserMedia({video: true}, "foobar") threw exception TypeError: Type error. 26 PASS navigator.webkitGetUserMedia({video: true}, undefined) threw exception TypeError: Type error. 27 PASS navigator.webkitGetUserMedia({video: true}, null) threw exception TypeError: Type error. 28 PASS navigator.webkitGetUserMedia({video: true}, {}) threw exception TypeError: Type error. 29 PASS navigator.webkitGetUserMedia({video: true}, true) threw exception TypeError: Type error. 30 PASS navigator.webkitGetUserMedia({video: true}, 42) threw exception TypeError: Type error. 31 PASS navigator.webkitGetUserMedia({video: true}, Infinity) threw exception TypeError: Type error. 32 PASS navigator.webkitGetUserMedia({video: true}, -Infinity) threw exception TypeError: Type error. 33 33 PASS navigator.webkitGetUserMedia({ }, emptyFunction, emptyFunction) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 34 34 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, emptyFunction) did not throw exception. … … 36 36 PASS navigator.webkitGetUserMedia({audio:true, video:true}, emptyFunction, undefined) did not throw exception. 37 37 PASS navigator.webkitGetUserMedia({audio:true}, emptyFunction, undefined) did not throw exception. 38 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, "video") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.38 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, "video") threw exception TypeError: Type error. 39 39 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, null) did not throw exception. 40 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.41 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.42 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.43 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.44 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, -Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.40 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, {}) threw exception TypeError: Type error. 41 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, true) threw exception TypeError: Type error. 42 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, 42) threw exception TypeError: Type error. 43 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, Infinity) threw exception TypeError: Type error. 44 PASS navigator.webkitGetUserMedia({video: true}, emptyFunction, -Infinity) threw exception TypeError: Type error. 45 45 PASS successfullyParsed is true 46 46 -
trunk/LayoutTests/fast/mediastream/peerconnection-argument-types-expected.txt
r123724 r133932 45 45 PASS new webkitPeerConnection00("STUN NONE",emptyFunction) did not throw exception. 46 46 PASS new webkitPeerConnection00("STUNS NONE",emptyFunction) did not throw exception. 47 PASS new webkitPeerConnection00("TURN NONE",undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.48 PASS new webkitPeerConnection00("TURNS NONE",{}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.49 PASS new webkitPeerConnection00("STUN NONE",42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.50 PASS new webkitPeerConnection00("STUNS NONE",Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.51 PASS new webkitPeerConnection00("STUNS NONE",-Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.47 PASS new webkitPeerConnection00("TURN NONE",undefined) threw exception TypeError: Type error. 48 PASS new webkitPeerConnection00("TURNS NONE",{}) threw exception TypeError: Type error. 49 PASS new webkitPeerConnection00("STUN NONE",42) threw exception TypeError: Type error. 50 PASS new webkitPeerConnection00("STUNS NONE",Infinity) threw exception TypeError: Type error. 51 PASS new webkitPeerConnection00("STUNS NONE",-Infinity) threw exception TypeError: Type error. 52 52 PASS successfullyParsed is true 53 53 -
trunk/LayoutTests/fast/mediastream/script-tests/argument-types.js
r116511 r133932 4 4 if (expressionShouldThrow) { 5 5 if (expectedException) 6 shouldThrow(expression, ' (function() { return "' + expectedException + '"; })();');6 shouldThrow(expression, '"' + expectedException + '"'); 7 7 else 8 shouldThrow(expression, ' (function() { return "TypeError: Not enough arguments"; })();');8 shouldThrow(expression, '"TypeError: Not enough arguments"'); 9 9 } else { 10 10 shouldNotThrow(expression); … … 13 13 14 14 var notSupportedError = new Error('NOT_SUPPORTED_ERR: DOM Exception 9'); 15 var type MismatchError = new Error('TYPE_MISMATCH_ERR: DOM Exception 17');15 var typeError = new TypeError('Type error'); 16 16 var typeNotAnObjectError = new TypeError('Not an object.'); 17 17 … … 42 42 test('navigator.webkitGetUserMedia(-Infinity, emptyFunction)', true, typeNotAnObjectError); 43 43 test('navigator.webkitGetUserMedia(emptyFunction, emptyFunction)', true, notSupportedError); 44 test('navigator.webkitGetUserMedia({video: true}, "foobar")', true, type MismatchError);45 test('navigator.webkitGetUserMedia({video: true}, undefined)', true, type MismatchError);46 test('navigator.webkitGetUserMedia({video: true}, null)', true, type MismatchError);47 test('navigator.webkitGetUserMedia({video: true}, {})', true, type MismatchError);48 test('navigator.webkitGetUserMedia({video: true}, true)', true, type MismatchError);49 test('navigator.webkitGetUserMedia({video: true}, 42)', true, type MismatchError);50 test('navigator.webkitGetUserMedia({video: true}, Infinity)', true, type MismatchError);51 test('navigator.webkitGetUserMedia({video: true}, -Infinity)', true, type MismatchError);44 test('navigator.webkitGetUserMedia({video: true}, "foobar")', true, typeError); 45 test('navigator.webkitGetUserMedia({video: true}, undefined)', true, typeError); 46 test('navigator.webkitGetUserMedia({video: true}, null)', true, typeError); 47 test('navigator.webkitGetUserMedia({video: true}, {})', true, typeError); 48 test('navigator.webkitGetUserMedia({video: true}, true)', true, typeError); 49 test('navigator.webkitGetUserMedia({video: true}, 42)', true, typeError); 50 test('navigator.webkitGetUserMedia({video: true}, Infinity)', true, typeError); 51 test('navigator.webkitGetUserMedia({video: true}, -Infinity)', true, typeError); 52 52 53 53 // 3 Arguments. … … 57 57 test('navigator.webkitGetUserMedia({audio:true, video:true}, emptyFunction, undefined)', false); 58 58 test('navigator.webkitGetUserMedia({audio:true}, emptyFunction, undefined)', false); 59 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, "video")', true, type MismatchError);59 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, "video")', true, typeError); 60 60 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, null)', false ); 61 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, {})', true, type MismatchError);62 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, true)', true, type MismatchError);63 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, 42)', true, type MismatchError);64 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, Infinity)', true, type MismatchError);65 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, -Infinity)', true, type MismatchError);61 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, {})', true, typeError); 62 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, true)', true, typeError); 63 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, 42)', true, typeError); 64 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, Infinity)', true, typeError); 65 test('navigator.webkitGetUserMedia({video: true}, emptyFunction, -Infinity)', true, typeError); 66 66 67 67 window.jsTestIsAsync = false; -
trunk/LayoutTests/fast/mediastream/script-tests/peerconnection-argument-types.js
r123724 r133932 4 4 if (expressionShouldThrow) { 5 5 if (expectedException) 6 shouldThrow(expression, ' (function() { return "' + expectedException + '"; })();');6 shouldThrow(expression, '"' + expectedException + '"'); 7 7 else 8 shouldThrow(expression, ' (function() { return "Error: TYPE_MISMATCH_ERR: DOM Exception 17"; })();');8 shouldThrow(expression, '"TypeError: Type error"'); 9 9 } else { 10 10 shouldNotThrow(expression); -
trunk/LayoutTests/fast/workers/storage/open-database-inputs-sync-expected.txt
r65005 r133932 5 5 PASS: undefined 6 6 PASS: undefined 7 PASS: T YPE_MISMATCH_ERR: DOM Exception 177 PASS: Type error 8 8 PASS: openDatabaseSync() succeeded. 9 9 PASS: openDatabaseSync() succeeded. -
trunk/Source/WebCore/ChangeLog
r133926 r133932 1 2012-11-08 Erik Arvidsson <arv@chromium.org> 2 3 Wrong error type is thrown for type errors in callbacks 4 https://bugs.webkit.org/show_bug.cgi?id=101502 5 6 Reviewed by Adam Barth. 7 8 We should be throwing a TypeError and not a DOMException with code TYPE_MISMATCH_ERR. 9 10 http://www.w3.org/TR/WebIDL/#es-callback-function 11 12 Updated existing tests. 13 14 * bindings/scripts/CodeGeneratorJS.pm: 15 * bindings/scripts/CodeGeneratorV8.pm: 16 * bindings/scripts/test/JS/JSTestObj.cpp: 17 * bindings/scripts/test/V8/V8TestObj.cpp: 18 1 19 2012-11-08 Andreas Kling <kling@webkit.org> 2 20 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r132973 r133932 2704 2704 push(@$outputArray, " RefPtr<$argType> $name;\n"); 2705 2705 push(@$outputArray, " if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isUndefinedOrNull()) {\n"); 2706 push(@$outputArray, " if (!exec->argument($argsIndex).isFunction()) {\n"); 2707 push(@$outputArray, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); 2708 push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); 2709 push(@$outputArray, " }\n"); 2706 push(@$outputArray, " if (!exec->argument($argsIndex).isFunction())\n"); 2707 push(@$outputArray, " return throwVMTypeError(exec);\n"); 2710 2708 push(@$outputArray, " $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); 2711 2709 push(@$outputArray, " }\n"); 2712 2710 } else { 2713 push(@$outputArray, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isFunction()) {\n"); 2714 push(@$outputArray, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); 2715 push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); 2716 push(@$outputArray, " }\n"); 2711 push(@$outputArray, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isFunction())\n"); 2712 push(@$outputArray, " return throwVMTypeError(exec);\n"); 2717 2713 push(@$outputArray, " RefPtr<$argType> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); 2718 2714 } -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r133829 r133932 1746 1746 $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; 1747 1747 $parameterCheckString .= " if (!args[$paramIndex]->IsFunction())\n"; 1748 $parameterCheckString .= " return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());\n";1748 $parameterCheckString .= " return throwTypeError(0, args.GetIsolate());\n"; 1749 1749 $parameterCheckString .= " $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n"; 1750 1750 $parameterCheckString .= " }\n"; 1751 1751 } else { 1752 1752 $parameterCheckString .= " if (args.Length() <= $paramIndex || !args[$paramIndex]->IsFunction())\n"; 1753 $parameterCheckString .= " return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());\n";1753 $parameterCheckString .= " return throwTypeError(0, args.GetIsolate());\n"; 1754 1754 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n"; 1755 1755 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r132698 r133932 231 231 if (exec->argumentCount() < 1) 232 232 return throwVMError(exec, createNotEnoughArgumentsError(exec)); 233 if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) { 234 setDOMException(exec, TYPE_MISMATCH_ERR); 235 return JSValue::encode(jsUndefined()); 236 } 233 if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) 234 return throwVMTypeError(exec); 237 235 RefPtr<TestCallback> testCallback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); 238 236 RefPtr<TestObj> object = TestObj::create(testCallback); … … 1994 1992 if (exec->argumentCount() < 1) 1995 1993 return throwVMError(exec, createNotEnoughArgumentsError(exec)); 1996 if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) { 1997 setDOMException(exec, TYPE_MISMATCH_ERR); 1998 return JSValue::encode(jsUndefined()); 1999 } 1994 if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) 1995 return throwVMTypeError(exec); 2000 1996 RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); 2001 1997 impl->methodWithCallbackArg(callback); … … 2016 2012 if (exec->hadException()) 2017 2013 return JSValue::encode(jsUndefined()); 2018 if (exec->argumentCount() <= 1 || !exec->argument(1).isFunction()) { 2019 setDOMException(exec, TYPE_MISMATCH_ERR); 2020 return JSValue::encode(jsUndefined()); 2021 } 2014 if (exec->argumentCount() <= 1 || !exec->argument(1).isFunction()) 2015 return throwVMTypeError(exec); 2022 2016 RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(1)), castedThis->globalObject()); 2023 2017 impl->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback); … … 2035 2029 RefPtr<TestCallback> callback; 2036 2030 if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull()) { 2037 if (!exec->argument(0).isFunction()) { 2038 setDOMException(exec, TYPE_MISMATCH_ERR); 2039 return JSValue::encode(jsUndefined()); 2040 } 2031 if (!exec->argument(0).isFunction()) 2032 return throwVMTypeError(exec); 2041 2033 callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); 2042 2034 } … … 2182 2174 if (exec->argumentCount() < 1) 2183 2175 return throwVMError(exec, createNotEnoughArgumentsError(exec)); 2184 if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) { 2185 setDOMException(exec, TYPE_MISMATCH_ERR); 2186 return JSValue::encode(jsUndefined()); 2187 } 2176 if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) 2177 return throwVMTypeError(exec); 2188 2178 RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); 2189 2179 impl->overloadedMethod(callback); -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r133719 r133932 1428 1428 TestObj* imp = V8TestObj::toNative(args.Holder()); 1429 1429 if (args.Length() <= 0 || !args[0]->IsFunction()) 1430 return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());1430 return throwTypeError(0, args.GetIsolate()); 1431 1431 RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext()); 1432 1432 imp->methodWithCallbackArg(callback); … … 1442 1442 EXCEPTION_BLOCK(int, nonCallback, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); 1443 1443 if (args.Length() <= 1 || !args[1]->IsFunction()) 1444 return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());1444 return throwTypeError(0, args.GetIsolate()); 1445 1445 RefPtr<TestCallback> callback = V8TestCallback::create(args[1], getScriptExecutionContext()); 1446 1446 imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback); … … 1455 1455 if (args.Length() > 0 && !args[0]->IsNull() && !args[0]->IsUndefined()) { 1456 1456 if (!args[0]->IsFunction()) 1457 return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());1457 return throwTypeError(0, args.GetIsolate()); 1458 1458 callback = V8TestCallback::create(args[0], getScriptExecutionContext()); 1459 1459 } … … 1554 1554 TestObj* imp = V8TestObj::toNative(args.Holder()); 1555 1555 if (args.Length() <= 0 || !args[0]->IsFunction()) 1556 return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());1556 return throwTypeError(0, args.GetIsolate()); 1557 1557 RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext()); 1558 1558 imp->overloadedMethod(callback); … … 2173 2173 return throwNotEnoughArgumentsError(args.GetIsolate()); 2174 2174 if (args.Length() <= 0 || !args[0]->IsFunction()) 2175 return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());2175 return throwTypeError(0, args.GetIsolate()); 2176 2176 RefPtr<TestCallback> testCallback = V8TestCallback::create(args[0], getScriptExecutionContext()); 2177 2177
Note: See TracChangeset
for help on using the changeset viewer.