toolkit/devtools/server/tests/unit/test_functiongrips-01.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 var gDebuggee;
     5 var gClient;
     6 var gThreadClient;
     8 function run_test()
     9 {
    10   initTestDebuggerServer();
    11   gDebuggee = addTestGlobal("test-grips");
    12   gDebuggee.eval(function stopMe(arg1) {
    13     debugger;
    14   }.toString());
    16   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    17   gClient.connect(function() {
    18     attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) {
    19       gThreadClient = aThreadClient;
    20       test_named_function();
    21     });
    22   });
    23   do_test_pending();
    24 }
    26 function test_named_function()
    27 {
    28   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    29     let args = aPacket.frame.arguments;
    31     do_check_eq(args[0].class, "Function");
    32     do_check_eq(args[0].name, "stopMe");
    33     do_check_eq(args[0].displayName, "stopMe");
    35     let objClient = gThreadClient.pauseGrip(args[0]);
    36     objClient.getParameterNames(function(aResponse) {
    37       do_check_eq(aResponse.parameterNames.length, 1);
    38       do_check_eq(aResponse.parameterNames[0], "arg1");
    40       gThreadClient.resume(test_inferred_name_function);
    41     });
    43   });
    45   gDebuggee.eval("stopMe(stopMe)");
    46 }
    48 function test_inferred_name_function() {
    49   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    50     let args = aPacket.frame.arguments;
    52     do_check_eq(args[0].class, "Function");
    53     // No name for an anonymous function, but it should have an inferred name.
    54     do_check_eq(args[0].name, undefined);
    55     do_check_eq(args[0].displayName, "o.m");
    57     let objClient = gThreadClient.pauseGrip(args[0]);
    58     objClient.getParameterNames(function(aResponse) {
    59       do_check_eq(aResponse.parameterNames.length, 3);
    60       do_check_eq(aResponse.parameterNames[0], "foo");
    61       do_check_eq(aResponse.parameterNames[1], "bar");
    62       do_check_eq(aResponse.parameterNames[2], "baz");
    64       gThreadClient.resume(test_anonymous_function);
    65     });
    66   });
    68   gDebuggee.eval("var o = { m: function(foo, bar, baz) { } }; stopMe(o.m)");
    69 }
    71 function test_anonymous_function() {
    72   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    73     let args = aPacket.frame.arguments;
    75     do_check_eq(args[0].class, "Function");
    76     // No name for an anonymous function, and no inferred name, either.
    77     do_check_eq(args[0].name, undefined);
    78     do_check_eq(args[0].displayName, undefined);
    80     let objClient = gThreadClient.pauseGrip(args[0]);
    81     objClient.getParameterNames(function(aResponse) {
    82       do_check_eq(aResponse.parameterNames.length, 3);
    83       do_check_eq(aResponse.parameterNames[0], "foo");
    84       do_check_eq(aResponse.parameterNames[1], "bar");
    85       do_check_eq(aResponse.parameterNames[2], "baz");
    87       gThreadClient.resume(function() {
    88         finishClient(gClient);
    89       });
    90     });
    91   });
    93   gDebuggee.eval("stopMe(function(foo, bar, baz) { })");
    94 }

mercurial