toolkit/devtools/server/tests/unit/test_threadlifetime-03.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 /**
     5  * Check that thread-lifetime grips last past a resume.
     6  */
     8 var gDebuggee;
     9 var gClient;
    10 var gThreadClient;
    12 function run_test()
    13 {
    14   initTestDebuggerServer();
    15   gDebuggee = addTestGlobal("test-grips");
    16   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    17   gClient.connect(function() {
    18     attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) {
    19       gThreadClient = aThreadClient;
    20       test_thread_lifetime();
    21     });
    22   });
    23   do_test_pending();
    24 }
    26 function test_thread_lifetime()
    27 {
    28   // Get three thread-lifetime grips.
    29   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    30     let grips = [];
    32     let handler = function(aResponse) {
    33       if (aResponse.error) {
    34         do_check_eq(aResponse.error, '');
    35         finishClient(gClient);
    36       }
    37       grips.push(aResponse.from);
    38       if (grips.length == 3) {
    39         test_release_many(grips);
    40       }
    41     };
    42     for (let i = 0; i < 3; i++) {
    43       gClient.request({ to: aPacket.frame.arguments[i].actor, type: "threadGrip" },
    44                       handler);
    45     }
    46   });
    48   gDebuggee.eval("(" + function() {
    49     function stopMe(arg1, arg2, arg3) {
    50       debugger;
    51     };
    52     stopMe({obj: 1}, {obj: 2}, {obj: 3});
    53   } + ")()");
    54 }
    56 function test_release_many(grips)
    57 {
    58   // Release the first two grips, leave the third alive.
    60   let release = [grips[0], grips[1]];
    62   gThreadClient.releaseMany(release, function(aResponse) {
    63     // First two actors should return a noSuchActor error, because
    64     // they're gone now.
    65     gClient.request({ to: grips[0], type: "bogusRequest" }, function(aResponse) {
    66       do_check_eq(aResponse.error, "noSuchActor");
    67       gClient.request({ to: grips[1], type: "bogusRequest" }, function(aResponse) {
    68         do_check_eq(aResponse.error, "noSuchActor");
    70         // Last actor should return unrecognizedPacketType, because it's still
    71         // alive.
    72         gClient.request({ to: grips[2], type: "bogusRequest" }, function(aResponse) {
    73           do_check_eq(aResponse.error, "unrecognizedPacketType");
    74           gThreadClient.resume(function() {
    75             finishClient(gClient);
    76           });
    77         });
    78       });
    79     });
    80   });
    81 }

mercurial