Changeset 111825 in webkit


Ignore:
Timestamp:
Mar 22, 2012 9:31:32 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Mao Yujie <yujie.mao@intel.com> 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:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r111824 r111825  
     12012-03-22  Mao Yujie  <yujie.mao@intel.com>
     2
     3        Implement strict testing criterion for callback function definition
     4        https://bugs.webkit.org/show_bug.cgi?id=80005
     5
     6        Reviewed by Adam Barth.
     7
     8        Modify some tests to align with their behavior.
     9
     10        * fast/dom/MediaStream/argument-types-expected.txt:
     11        * fast/dom/MediaStream/script-tests/argument-types.js:
     12        * fast/mediastream/peerconnection-argument-types-expected.txt:
     13        * fast/mediastream/script-tests/argument-types.js:
     14
    1152012-03-22  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    216
  • trunk/LayoutTests/fast/dom/MediaStream/argument-types-expected.txt

    r107540 r111825  
    2828PASS navigator.webkitGetUserMedia("video", undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    2929PASS navigator.webkitGetUserMedia("video", null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    30 PASS navigator.webkitGetUserMedia("video", {}) did not throw exception.
    31 PASS navigator.webkitGetUserMedia("video", objectThrowingException) did not throw exception.
     30PASS navigator.webkitGetUserMedia("video", {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     31PASS navigator.webkitGetUserMedia("video", objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    3232PASS navigator.webkitGetUserMedia("video", true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    3333PASS navigator.webkitGetUserMedia("video", 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     
    4242PASS navigator.webkitGetUserMedia("video", emptyFunction, "video") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    4343PASS navigator.webkitGetUserMedia("video", emptyFunction, null) did not throw exception.
    44 PASS navigator.webkitGetUserMedia("video", emptyFunction, {}) did not throw exception.
    45 PASS navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException) did not throw exception.
     44PASS navigator.webkitGetUserMedia("video", emptyFunction, {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     45PASS navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    4646PASS navigator.webkitGetUserMedia("video", emptyFunction, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    4747PASS navigator.webkitGetUserMedia("video", emptyFunction, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
  • trunk/LayoutTests/fast/dom/MediaStream/script-tests/argument-types.js

    r107540 r111825  
    6363test('navigator.webkitGetUserMedia("video", undefined)', true, typeMismatchError);
    6464test('navigator.webkitGetUserMedia("video", null)', true, typeMismatchError);
    65 test('navigator.webkitGetUserMedia("video", {})', false);
    66 test('navigator.webkitGetUserMedia("video", objectThrowingException)', false);
     65test('navigator.webkitGetUserMedia("video", {})', true, typeMismatchError);
     66test('navigator.webkitGetUserMedia("video", objectThrowingException)', true, typeMismatchError);
    6767test('navigator.webkitGetUserMedia("video", true)', true, typeMismatchError);
    6868test('navigator.webkitGetUserMedia("video", 42)', true, typeMismatchError);
     
    7979test('navigator.webkitGetUserMedia("video", emptyFunction, "video")', true, typeMismatchError);
    8080test('navigator.webkitGetUserMedia("video", emptyFunction, null)', false );
    81 test('navigator.webkitGetUserMedia("video", emptyFunction, {})', false);
    82 test('navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException)', false);
     81test('navigator.webkitGetUserMedia("video", emptyFunction, {})', true, typeMismatchError);
     82test('navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException)', true, typeMismatchError);
    8383test('navigator.webkitGetUserMedia("video", emptyFunction, true)', true, typeMismatchError);
    8484test('navigator.webkitGetUserMedia("video", emptyFunction, 42)', true, typeMismatchError);
  • trunk/LayoutTests/fast/mediastream/peerconnection-argument-types-expected.txt

    r110587 r111825  
    4646PASS new webkitDeprecatedPeerConnection("STUNS NONE",emptyFunction) did not throw exception.
    4747PASS new webkitDeprecatedPeerConnection("TURN NONE",undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    48 PASS new webkitDeprecatedPeerConnection("TURNS NONE",{}) did not throw exception.
     48PASS new webkitDeprecatedPeerConnection("TURNS NONE",{}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    4949PASS new webkitDeprecatedPeerConnection("STUN NONE",42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    5050PASS new webkitDeprecatedPeerConnection("STUNS NONE",Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
  • trunk/LayoutTests/fast/mediastream/script-tests/argument-types.js

    r110587 r111825  
    8080test('new webkitDeprecatedPeerConnection("STUNS NONE",emptyFunction)', false);
    8181test('new webkitDeprecatedPeerConnection("TURN NONE",undefined)',  true);
    82 test('new webkitDeprecatedPeerConnection("TURNS NONE",{})', false);
     82test('new webkitDeprecatedPeerConnection("TURNS NONE",{})', true);
    8383test('new webkitDeprecatedPeerConnection("STUN NONE",42)',  true);
    8484test('new webkitDeprecatedPeerConnection("STUNS NONE",Infinity)', true);
  • trunk/Source/WebCore/ChangeLog

    r111824 r111825  
     12012-03-22  Mao Yujie  <yujie.mao@intel.com>
     2
     3        Implement strict testing criterion for callback function definition
     4        https://bugs.webkit.org/show_bug.cgi?id=80005
     5
     6        Reviewed by Adam Barth.
     7
     8        Callback function should be defined as the function type instead of
     9        the object type.
     10
     11        LayoutTest: fast/dom/MediaStream/argument-types.html
     12
     13        * bindings/scripts/CodeGeneratorJS.pm:
     14        (GenerateParametersCheckExpression):
     15        (GenerateParametersCheck):
     16        * bindings/scripts/CodeGeneratorV8.pm:
     17        (GenerateParametersCheckExpression):
     18        (GenerateParametersCheck):
     19
    1202012-03-22  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    221
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r111779 r111825  
    12321232        } elsif ($parameter->extendedAttributes->{"Callback"}) {
    12331233            # For Callbacks only checks if the value is null or object.
    1234             push(@andExpression, "(${value}.isNull() || ${value}.isObject())");
     1234            push(@andExpression, "(${value}.isNull() || ${value}.isFunction())");
    12351235            $usedArguments{$parameterIndex} = 1;
    12361236        } elsif (IsArrayType($type)) {
     
    25012501                push(@$outputArray, "    RefPtr<$argType> $name;\n");
    25022502                push(@$outputArray, "    if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isUndefinedOrNull()) {\n");
    2503                 push(@$outputArray, "        if (!exec->argument($argsIndex).isObject()) {\n");
     2503                push(@$outputArray, "        if (!exec->argument($argsIndex).isFunction()) {\n");
    25042504                push(@$outputArray, "            setDOMException(exec, TYPE_MISMATCH_ERR);\n");
    25052505                push(@$outputArray, "            return JSValue::encode(jsUndefined());\n");
     
    25082508                push(@$outputArray, "    }\n");
    25092509            } else {
    2510                 push(@$outputArray, "    if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isObject()) {\n");
     2510                push(@$outputArray, "    if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isFunction()) {\n");
    25112511                push(@$outputArray, "        setDOMException(exec, TYPE_MISMATCH_ERR);\n");
    25122512                push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r111813 r111825  
    12851285        } elsif ($parameter->extendedAttributes->{"Callback"}) {
    12861286            # For Callbacks only checks if the value is null or object.
    1287             push(@andExpression, "(${value}->IsNull() || ${value}->IsObject())");
     1287            push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())");
    12881288        } elsif (IsArrayType($type)) {
    12891289            # FIXME: Add proper support for T[], T[]?, sequence<T>.
     
    15861586                $parameterCheckString .= "    RefPtr<" . $parameter->type . "> $parameterName;\n";
    15871587                $parameterCheckString .= "    if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n";
    1588                 $parameterCheckString .= "        if (!args[$paramIndex]->IsObject())\n";
     1588                $parameterCheckString .= "        if (!args[$paramIndex]->IsFunction())\n";
    15891589                $parameterCheckString .= "            return throwError(TYPE_MISMATCH_ERR);\n";
    15901590                $parameterCheckString .= "        $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n";
    15911591                $parameterCheckString .= "    }\n";
    15921592            } else {
    1593                 $parameterCheckString .= "    if (args.Length() <= $paramIndex || !args[$paramIndex]->IsObject())\n";
     1593                $parameterCheckString .= "    if (args.Length() <= $paramIndex || !args[$paramIndex]->IsFunction())\n";
    15941594                $parameterCheckString .= "        return throwError(TYPE_MISMATCH_ERR);\n";
    15951595                $parameterCheckString .= "    RefPtr<" . $parameter->type . "> $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n";
Note: See TracChangeset for help on using the changeset viewer.