toolkit/devtools/server/tests/unit/test_profiler_activation.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 "use strict";
     6 const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
     8 function connectClient(callback) {
     9   let client = new DebuggerClient(DebuggerServer.connectPipe());
    10   client.connect(function () {
    11     client.listTabs(function(response) {
    12       callback(client, response.profilerActor);
    13     });
    14   });
    15 }
    17 function run_test()
    18 {
    19   // Ensure the profiler is not running when the test starts (it could
    20   // happen if the MOZ_PROFILER_STARTUP environment variable is set)
    21   Profiler.StopProfiler();
    23   DebuggerServer.init(function () { return true; });
    24   DebuggerServer.addBrowserActors();
    26   connectClient((client1, actor1) => {
    27     connectClient((client2, actor2) => {
    28       activate_first(client1, actor1, client2, actor2);
    29     });
    30   })
    32   do_test_pending();
    33 }
    35 function activate_first(client1, actor1, client2, actor2) {
    36   // Start the profiler on the first connection....
    37   client1.request({ to: actor1, type: "startProfiler", features: ['js']}, startResponse => {
    38     // Profiler should be active now.
    39     do_check_true(Profiler.IsActive());
    41     // But on the next connection just make sure the actor has been
    42     // instantiated.
    43     client2.request({ to: actor2, type: "getFeatures" }, featureResponse => {
    45       let connectionClosed = DebuggerServer._connectionClosed;
    46       DebuggerServer._connectionClosed = function(conn) {
    47         connectionClosed.call(this, conn);
    49         // Client1 is the only actor that started the profiler,
    50         // it shouldn't be active anymore.
    51         do_check_false(Profiler.IsActive());
    53         DebuggerServer._connectionClosed = function(conn) {
    54           connectionClosed.call(this, conn);
    56           // Now there are no open clients at all, it should *definitely*
    57           // be deactivated by now.
    58           do_check_false(Profiler.IsActive());
    59           do_test_finished();
    60         }
    61         client2.close();
    62       };
    63       client1.close();
    64     });
    65   });
    66 }

mercurial