toolkit/devtools/server/tests/unit/test_nesting-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 /* -*- Mode: javascript; js-indent-level: 2; -*- */
     2 /* Any copyright is dedicated to the Public Domain.
     3    http://creativecommons.org/publicdomain/zero/1.0/ */
     5 // Test that we can nest event loops when needed in
     6 // ThreadActor.prototype.synchronize.
     8 var gClient;
     9 var gThreadActor;
    11 function run_test() {
    12   initTestDebuggerServer();
    13   let gDebuggee = addTestGlobal("test-nesting");
    14   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    15   gClient.connect(function () {
    16     attachTestTabAndResume(gClient, "test-nesting", function (aResponse, aTabClient, aThreadClient) {
    17       // Reach over the protocol connection and get a reference to the thread actor.
    18       gThreadActor = aThreadClient._transport._serverConnection.getActor(aThreadClient._actor);
    20       test_nesting();
    21     });
    22   });
    23   do_test_pending();
    24 }
    26 function test_nesting() {
    27   const thread = gThreadActor;
    28   const { resolve, reject, promise: p } = promise.defer();
    30   let currentStep = 0;
    32   executeSoon(function () {
    33     // Should be on the first step
    34     do_check_eq(++currentStep, 1);
    35     // We should have one nested event loop from synchronize
    36     do_check_eq(thread._nestedEventLoops.size, 1);
    37     resolve(true);
    38   });
    40   do_check_eq(thread.synchronize(p), true);
    42   // Should be on the second step
    43   do_check_eq(++currentStep, 2);
    44   // There shouldn't be any nested event loops anymore
    45   do_check_eq(thread._nestedEventLoops.size, 0);
    47   finishClient(gClient);
    48 }

mercurial