toolkit/devtools/server/tests/unit/test_objectgrips-10.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 // Test that closures can be inspected.
    10 function run_test()
    11 {
    12   initTestDebuggerServer();
    13   gDebuggee = addTestGlobal("test-closures");
    15   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    16   gClient.connect(function() {
    17     attachTestTabAndResume(gClient, "test-closures", function(aResponse, aTabClient, aThreadClient) {
    18       gThreadClient = aThreadClient;
    19       test_object_grip();
    20     });
    21   });
    22   do_test_pending();
    23 }
    25 function test_object_grip()
    26 {
    27   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    28     let person = aPacket.frame.environment.bindings.variables.person;
    30     do_check_eq(person.value.class, "Object");
    32     let personClient = gThreadClient.pauseGrip(person.value);
    33     personClient.getPrototypeAndProperties(aResponse => {
    34       do_check_eq(aResponse.ownProperties.getName.value.class, "Function");
    36       do_check_eq(aResponse.ownProperties.getAge.value.class, "Function");
    38       do_check_eq(aResponse.ownProperties.getFoo.value.class, "Function");
    40       let getNameClient = gThreadClient.pauseGrip(aResponse.ownProperties.getName.value);
    41       let getAgeClient = gThreadClient.pauseGrip(aResponse.ownProperties.getAge.value);
    42       let getFooClient = gThreadClient.pauseGrip(aResponse.ownProperties.getFoo.value);
    43       getNameClient.getScope(aResponse => {
    44         do_check_eq(aResponse.scope.bindings.arguments[0].name.value, "Bob");
    46         getAgeClient.getScope(aResponse => {
    47           do_check_eq(aResponse.scope.bindings.arguments[1].age.value, 58);
    49           getFooClient.getScope(aResponse => {
    50             do_check_eq(aResponse.scope.bindings.variables.foo.value, 10);
    52             gThreadClient.resume(() => finishClient(gClient));
    53           });
    54         });
    55       });
    56     });
    58   });
    60   gDebuggee.eval("(" + function() {
    61     var PersonFactory = function(name, age) {
    62         var foo = 10;
    63         return {
    64           getName: function() { return name; },
    65           getAge: function() { return age; },
    66           getFoo: function() { foo = Date.now(); return foo; }
    67         };
    68     };
    69     var person = new PersonFactory("Bob", 58);
    70     debugger;
    71   } + ")()");
    72 }

mercurial