Changeset 60952 in webkit


Ignore:
Timestamp:
Jun 10, 2010 4:23:13 AM (14 years ago)
Author:
andreip@google.com
Message:

2010-06-09 Andrei Popescu <andreip@google.com>

Reviewed by Adam Barth.

CodeGeneratorJS.pm incorrectly increments $paramIndex when a method is declared with [CallWith]
https://bugs.webkit.org/show_bug.cgi?id=40372

Use two variables to keep track of the number of arguments passed from JavaScript vs the number
of arguments passed to the corresponding C++ method. These numbers can be different since
the parameter declared via [CallWith] is generated in the bindings instead of being passed
from JavaScript.

The layout tests added here test both that the parameters are read correctly as well as
tests some basic indexed database functionality. There are also bindings specific
tests added in TestObj.idl.

  • storage/indexeddb/idb-objectstore-request-expected.txt: Added.
  • storage/indexeddb/idb-objectstore-request.html: Added.
  • storage/indexeddb/script-tests/idb-objectstore-request.js: Added. (openSuccess): (createSuccess): (createObjectStore): (doCreateOrOpen): (test):

2010-06-09 Andrei Popescu <andreip@google.com>

Reviewed by Adam Barth.

CodeGeneratorJS.pm incorrectly increments $paramIndex when a method is declared with [CallWith]
https://bugs.webkit.org/show_bug.cgi?id=40372

Use two variables to keep track of the number of arguments passed from JavaScript vs the number
of arguments passed to the corresponding C++ method. These numbers can be different since
the parameter declared via [CallWith] is generated in the bindings instead of being passed
from JavaScript.

Test: storage/indexeddb/idb-objectstore-request.html

  • bindings/scripts/CodeGeneratorJS.pm:
  • bindings/scripts/test/CPP/WebDOMTestObj.cpp: (WebDOMTestObj::withScriptExecutionContext):
  • bindings/scripts/test/CPP/WebDOMTestObj.h:
  • bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndArg): (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg): (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture): (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD):
Location:
trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r60944 r60952  
     12010-06-09  Andrei Popescu  <andreip@google.com>
     2
     3        Reviewed by Adam Barth.
     4
     5        CodeGeneratorJS.pm incorrectly increments $paramIndex when a method is declared with [CallWith]
     6        https://bugs.webkit.org/show_bug.cgi?id=40372
     7
     8        Use two variables to keep track of the number of arguments passed from JavaScript vs the number
     9        of arguments passed to the corresponding C++ method. These numbers can be different since
     10        the parameter declared via [CallWith] is generated in the bindings instead of being passed
     11        from JavaScript.
     12       
     13        The layout tests added here test both that the parameters are read correctly as well as
     14        tests some basic indexed database functionality. There are also bindings specific
     15        tests added in TestObj.idl.
     16
     17        * storage/indexeddb/idb-objectstore-request-expected.txt: Added.
     18        * storage/indexeddb/idb-objectstore-request.html: Added.
     19        * storage/indexeddb/script-tests/idb-objectstore-request.js: Added.
     20        (openSuccess):
     21        (createSuccess):
     22        (createObjectStore):
     23        (doCreateOrOpen):
     24        (test):
     25
    1262010-06-10  Adam Barth  <abarth@webkit.org>
    227
  • trunk/WebCore/ChangeLog

    r60951 r60952  
     12010-06-09  Andrei Popescu  <andreip@google.com>
     2
     3        Reviewed by Adam Barth.
     4
     5        CodeGeneratorJS.pm incorrectly increments $paramIndex when a method is declared with [CallWith]
     6        https://bugs.webkit.org/show_bug.cgi?id=40372
     7
     8        Use two variables to keep track of the number of arguments passed from JavaScript vs the number
     9        of arguments passed to the corresponding C++ method. These numbers can be different since
     10        the parameter declared via [CallWith] is generated in the bindings instead of being passed
     11        from JavaScript.
     12
     13        Test: storage/indexeddb/idb-objectstore-request.html
     14
     15        * bindings/scripts/CodeGeneratorJS.pm:
     16        * bindings/scripts/test/CPP/WebDOMTestObj.cpp:
     17        (WebDOMTestObj::withScriptExecutionContext):
     18        * bindings/scripts/test/CPP/WebDOMTestObj.h:
     19        * bindings/scripts/test/JS/JSTestObj.cpp:
     20        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndArg):
     21        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg):
     22        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture):
     23        (WebCore::jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD):
     24
    1252010-06-09  MORITA Hajime  <morrita@google.com>
    226
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r60789 r60952  
    18701870                    push(@implContent, GenerateEventListenerCall($className, "remove"));
    18711871                } else {
     1872                    my $argsIndex = 0;
    18721873                    my $paramIndex = 0;
    18731874                    my $functionString = ($podType ? "podImp." : "imp->") . $functionImplementationName . "(";
     
    19081909                                $hasOptionalArguments = 1;
    19091910                            }
    1910                             push(@implContent, "    if (argsCount < " . ($paramIndex + 1) . ") {\n");
     1911                            push(@implContent, "    if (argsCount < " . ($argsIndex + 1) . ") {\n");
    19111912                            GenerateImplementationFunctionCall($function, $functionString, $paramIndex, "    " x 2, $podType, $implClassName);
    19121913                            push(@implContent, "    }\n\n");
     
    19171918                        if ($parameter->type eq "XPathNSResolver") {
    19181919                            push(@implContent, "    RefPtr<XPathNSResolver> customResolver;\n");
    1919                             push(@implContent, "    XPathNSResolver* resolver = toXPathNSResolver(exec->argument($paramIndex));\n");
     1920                            push(@implContent, "    XPathNSResolver* resolver = toXPathNSResolver(exec->argument($argsIndex));\n");
    19201921                            push(@implContent, "    if (!resolver) {\n");
    1921                             push(@implContent, "        customResolver = JSCustomXPathNSResolver::create(exec, exec->argument($paramIndex));\n");
     1922                            push(@implContent, "        customResolver = JSCustomXPathNSResolver::create(exec, exec->argument($argsIndex));\n");
    19221923                            push(@implContent, "        if (exec->hadException())\n");
    19231924                            push(@implContent, "            return JSValue::encode(jsUndefined());\n");
     
    19251926                            push(@implContent, "    }\n");
    19261927                        } else {
    1927                             push(@implContent, "    " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "exec->argument($paramIndex)") . ";\n");
     1928                            push(@implContent, "    " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "exec->argument($argsIndex)") . ";\n");
    19281929
    19291930                            # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception.
     
    19461947                            $functionString .= $name;
    19471948                        }
     1949                        $argsIndex++;
    19481950                        $paramIndex++;
    19491951                    }
  • trunk/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp

    r60784 r60952  
    399399}
    400400
     401void WebDOMTestObj::withScriptExecutionContext()
     402{
     403    if (!impl())
     404        return;
     405
     406    impl()->withScriptExecutionContext();
     407}
     408
    401409void WebDOMTestObj::methodWithOptionalArg(int opt)
    402410{
  • trunk/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h

    r60784 r60952  
    8888    void withScriptStateVoidException();
    8989    WebDOMTestObj withScriptStateObjException();
     90    void withScriptExecutionContext();
    9091    void methodWithOptionalArg(int opt);
    9192    void methodWithNonOptionalArgAndOptionalArg(int nonOpt, int opt);
  • trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r60789 r60952  
    633633    if (!dynamicFrame)
    634634        return JSValue::encode(jsUndefined());
    635     int intArg = exec->argument(1).toInt32(exec);
     635    int intArg = exec->argument(0).toInt32(exec);
    636636
    637637    imp->withDynamicFrameAndArg(dynamicFrame, intArg);
     
    649649    if (!dynamicFrame)
    650650        return JSValue::encode(jsUndefined());
    651     int intArg = exec->argument(1).toInt32(exec);
     651    int intArg = exec->argument(0).toInt32(exec);
    652652
    653653    int argsCount = exec->argumentCount();
    654     if (argsCount < 3) {
     654    if (argsCount < 2) {
    655655        imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg);
    656656        return JSValue::encode(jsUndefined());
    657657    }
    658658
    659     int optionalArg = exec->argument(2).toInt32(exec);
     659    int optionalArg = exec->argument(1).toInt32(exec);
    660660
    661661    imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg);
     
    673673    if (!dynamicFrame)
    674674        return JSValue::encode(jsUndefined());
    675     int intArg = exec->argument(1).toInt32(exec);
     675    int intArg = exec->argument(0).toInt32(exec);
    676676
    677677    imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec));
     
    689689    if (!dynamicFrame)
    690690        return JSValue::encode(jsUndefined());
    691     int intArg = exec->argument(1).toInt32(exec);
     691    int intArg = exec->argument(0).toInt32(exec);
    692692
    693693    int argsCount = exec->argumentCount();
    694     if (argsCount < 3) {
     694    if (argsCount < 2) {
    695695        imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg);
    696696        return JSValue::encode(jsUndefined());
    697697    }
    698698
    699     int optionalArg = exec->argument(2).toInt32(exec);
     699    int optionalArg = exec->argument(1).toInt32(exec);
    700700
    701701    imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec));
Note: See TracChangeset for help on using the changeset viewer.