Title: [111825] trunk
Revision
111825
Author
[email protected]
Date
2012-03-22 21:31:32 -0700 (Thu, 22 Mar 2012)

Log Message

Implement strict testing criterion for callback function definition
https://bugs.webkit.org/show_bug.cgi?id=80005

Patch by Mao Yujie <[email protected]> on 2012-03-22
Reviewed by Adam Barth.

Source/WebCore:

Callback function should be defined as the function type instead of
the object type.

LayoutTest: fast/dom/MediaStream/argument-types.html

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheckExpression):
(GenerateParametersCheck):
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateParametersCheckExpression):
(GenerateParametersCheck):

LayoutTests:

Modify some tests to align with their behavior.

* fast/dom/MediaStream/argument-types-expected.txt:
* fast/dom/MediaStream/script-tests/argument-types.js:
* fast/mediastream/peerconnection-argument-types-expected.txt:
* fast/mediastream/script-tests/argument-types.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (111824 => 111825)


--- trunk/LayoutTests/ChangeLog	2012-03-23 04:15:47 UTC (rev 111824)
+++ trunk/LayoutTests/ChangeLog	2012-03-23 04:31:32 UTC (rev 111825)
@@ -1,3 +1,17 @@
+2012-03-22  Mao Yujie  <[email protected]>
+
+        Implement strict testing criterion for callback function definition
+        https://bugs.webkit.org/show_bug.cgi?id=80005
+
+        Reviewed by Adam Barth.
+
+        Modify some tests to align with their behavior.
+
+        * fast/dom/MediaStream/argument-types-expected.txt:
+        * fast/dom/MediaStream/script-tests/argument-types.js:
+        * fast/mediastream/peerconnection-argument-types-expected.txt:
+        * fast/mediastream/script-tests/argument-types.js:
+
 2012-03-22  Gyuyoung Kim  <[email protected]>
 
         Convert hasGrammarMarker to use Internals interface

Modified: trunk/LayoutTests/fast/dom/MediaStream/argument-types-expected.txt (111824 => 111825)


--- trunk/LayoutTests/fast/dom/MediaStream/argument-types-expected.txt	2012-03-23 04:15:47 UTC (rev 111824)
+++ trunk/LayoutTests/fast/dom/MediaStream/argument-types-expected.txt	2012-03-23 04:31:32 UTC (rev 111825)
@@ -27,8 +27,8 @@
 PASS navigator.webkitGetUserMedia("video", "video") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS navigator.webkitGetUserMedia("video", {}) did not throw exception.
-PASS navigator.webkitGetUserMedia("video", objectThrowingException) did not throw exception.
+PASS navigator.webkitGetUserMedia("video", {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS navigator.webkitGetUserMedia("video", objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
@@ -41,8 +41,8 @@
 PASS navigator.webkitGetUserMedia("audio, video environment", emptyFunction, undefined) did not throw exception.
 PASS navigator.webkitGetUserMedia("video", emptyFunction, "video") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", emptyFunction, null) did not throw exception.
-PASS navigator.webkitGetUserMedia("video", emptyFunction, {}) did not throw exception.
-PASS navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException) did not throw exception.
+PASS navigator.webkitGetUserMedia("video", emptyFunction, {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", emptyFunction, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", emptyFunction, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS navigator.webkitGetUserMedia("video", emptyFunction, Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.

Modified: trunk/LayoutTests/fast/dom/MediaStream/script-tests/argument-types.js (111824 => 111825)


--- trunk/LayoutTests/fast/dom/MediaStream/script-tests/argument-types.js	2012-03-23 04:15:47 UTC (rev 111824)
+++ trunk/LayoutTests/fast/dom/MediaStream/script-tests/argument-types.js	2012-03-23 04:31:32 UTC (rev 111825)
@@ -62,8 +62,8 @@
 test('navigator.webkitGetUserMedia("video", "video")', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", undefined)', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", null)', true, typeMismatchError);
-test('navigator.webkitGetUserMedia("video", {})', false);
-test('navigator.webkitGetUserMedia("video", objectThrowingException)', false);
+test('navigator.webkitGetUserMedia("video", {})', true, typeMismatchError);
+test('navigator.webkitGetUserMedia("video", objectThrowingException)', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", true)', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", 42)', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", Infinity)', true, typeMismatchError);
@@ -78,8 +78,8 @@
 test('navigator.webkitGetUserMedia("audio, video environment", emptyFunction, undefined)', false);
 test('navigator.webkitGetUserMedia("video", emptyFunction, "video")', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", emptyFunction, null)', false );
-test('navigator.webkitGetUserMedia("video", emptyFunction, {})', false);
-test('navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException)', false);
+test('navigator.webkitGetUserMedia("video", emptyFunction, {})', true, typeMismatchError);
+test('navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException)', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", emptyFunction, true)', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", emptyFunction, 42)', true, typeMismatchError);
 test('navigator.webkitGetUserMedia("video", emptyFunction, Infinity)', true, typeMismatchError);

Modified: trunk/LayoutTests/fast/mediastream/peerconnection-argument-types-expected.txt (111824 => 111825)


--- trunk/LayoutTests/fast/mediastream/peerconnection-argument-types-expected.txt	2012-03-23 04:15:47 UTC (rev 111824)
+++ trunk/LayoutTests/fast/mediastream/peerconnection-argument-types-expected.txt	2012-03-23 04:31:32 UTC (rev 111825)
@@ -45,7 +45,7 @@
 PASS new webkitDeprecatedPeerConnection("STUN NONE",emptyFunction) did not throw exception.
 PASS new webkitDeprecatedPeerConnection("STUNS NONE",emptyFunction) did not throw exception.
 PASS new webkitDeprecatedPeerConnection("TURN NONE",undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
-PASS new webkitDeprecatedPeerConnection("TURNS NONE",{}) did not throw exception.
+PASS new webkitDeprecatedPeerConnection("TURNS NONE",{}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS new webkitDeprecatedPeerConnection("STUN NONE",42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS new webkitDeprecatedPeerConnection("STUNS NONE",Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
 PASS new webkitDeprecatedPeerConnection("STUNS NONE",-Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.

Modified: trunk/LayoutTests/fast/mediastream/script-tests/argument-types.js (111824 => 111825)


--- trunk/LayoutTests/fast/mediastream/script-tests/argument-types.js	2012-03-23 04:15:47 UTC (rev 111824)
+++ trunk/LayoutTests/fast/mediastream/script-tests/argument-types.js	2012-03-23 04:31:32 UTC (rev 111825)
@@ -79,7 +79,7 @@
 test('new webkitDeprecatedPeerConnection("STUN NONE",emptyFunction)', false);
 test('new webkitDeprecatedPeerConnection("STUNS NONE",emptyFunction)', false);
 test('new webkitDeprecatedPeerConnection("TURN NONE",undefined)',  true);
-test('new webkitDeprecatedPeerConnection("TURNS NONE",{})', false);
+test('new webkitDeprecatedPeerConnection("TURNS NONE",{})', true);
 test('new webkitDeprecatedPeerConnection("STUN NONE",42)',  true);
 test('new webkitDeprecatedPeerConnection("STUNS NONE",Infinity)', true);
 test('new webkitDeprecatedPeerConnection("STUNS NONE",-Infinity)', true);

Modified: trunk/Source/WebCore/ChangeLog (111824 => 111825)


--- trunk/Source/WebCore/ChangeLog	2012-03-23 04:15:47 UTC (rev 111824)
+++ trunk/Source/WebCore/ChangeLog	2012-03-23 04:31:32 UTC (rev 111825)
@@ -1,3 +1,22 @@
+2012-03-22  Mao Yujie  <[email protected]>
+
+        Implement strict testing criterion for callback function definition
+        https://bugs.webkit.org/show_bug.cgi?id=80005
+
+        Reviewed by Adam Barth.
+
+        Callback function should be defined as the function type instead of
+        the object type.
+
+        LayoutTest: fast/dom/MediaStream/argument-types.html
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateParametersCheckExpression):
+        (GenerateParametersCheck):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateParametersCheckExpression):
+        (GenerateParametersCheck):
+
 2012-03-22  Gyuyoung Kim  <[email protected]>
 
         Convert hasGrammarMarker to use Internals interface

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (111824 => 111825)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-03-23 04:15:47 UTC (rev 111824)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-03-23 04:31:32 UTC (rev 111825)
@@ -1231,7 +1231,7 @@
             $usedArguments{$parameterIndex} = 1;
         } elsif ($parameter->extendedAttributes->{"Callback"}) {
             # For Callbacks only checks if the value is null or object.
-            push(@andExpression, "(${value}.isNull() || ${value}.isObject())");
+            push(@andExpression, "(${value}.isNull() || ${value}.isFunction())");
             $usedArguments{$parameterIndex} = 1;
         } elsif (IsArrayType($type)) {
             # FIXME: Add proper support for T[], T[]?, sequence<T>
@@ -2500,14 +2500,14 @@
             if ($optional) {
                 push(@$outputArray, "    RefPtr<$argType> $name;\n");
                 push(@$outputArray, "    if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isUndefinedOrNull()) {\n");
-                push(@$outputArray, "        if (!exec->argument($argsIndex).isObject()) {\n");
+                push(@$outputArray, "        if (!exec->argument($argsIndex).isFunction()) {\n");
                 push(@$outputArray, "            setDOMException(exec, TYPE_MISMATCH_ERR);\n");
                 push(@$outputArray, "            return JSValue::encode(jsUndefined());\n");
                 push(@$outputArray, "        }\n");
                 push(@$outputArray, "        $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");
                 push(@$outputArray, "    }\n");
             } else {
-                push(@$outputArray, "    if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isObject()) {\n");
+                push(@$outputArray, "    if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isFunction()) {\n");
                 push(@$outputArray, "        setDOMException(exec, TYPE_MISMATCH_ERR);\n");
                 push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
                 push(@$outputArray, "    }\n");

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (111824 => 111825)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-03-23 04:15:47 UTC (rev 111824)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-03-23 04:31:32 UTC (rev 111825)
@@ -1284,7 +1284,7 @@
             push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject())");
         } elsif ($parameter->extendedAttributes->{"Callback"}) {
             # For Callbacks only checks if the value is null or object.
-            push(@andExpression, "(${value}->IsNull() || ${value}->IsObject())");
+            push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())");
         } elsif (IsArrayType($type)) {
             # FIXME: Add proper support for T[], T[]?, sequence<T>.
             push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())");
@@ -1585,12 +1585,12 @@
             if ($optional) {
                 $parameterCheckString .= "    RefPtr<" . $parameter->type . "> $parameterName;\n";
                 $parameterCheckString .= "    if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n";
-                $parameterCheckString .= "        if (!args[$paramIndex]->IsObject())\n";
+                $parameterCheckString .= "        if (!args[$paramIndex]->IsFunction())\n";
                 $parameterCheckString .= "            return throwError(TYPE_MISMATCH_ERR);\n";
                 $parameterCheckString .= "        $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n";
                 $parameterCheckString .= "    }\n";
             } else {
-                $parameterCheckString .= "    if (args.Length() <= $paramIndex || !args[$paramIndex]->IsObject())\n";
+                $parameterCheckString .= "    if (args.Length() <= $paramIndex || !args[$paramIndex]->IsFunction())\n";
                 $parameterCheckString .= "        return throwError(TYPE_MISMATCH_ERR);\n";
                 $parameterCheckString .= "    RefPtr<" . $parameter->type . "> $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n";
             }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to