toolkit/devtools/server/tests/unit/test_eventlooplag_actor.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  * Test the eventLoopLag actor.
     6  */
     8 "use strict";
    10 function run_test()
    11 {
    12   let {EventLoopLagFront} = devtools.require("devtools/server/actors/eventlooplag");
    14   DebuggerServer.init(function () { return true; });
    15   DebuggerServer.addBrowserActors();
    17   // As seen in EventTracer.cpp
    18   let threshold = 20;
    19   let interval = 10;
    22   let front;
    23   let client = new DebuggerClient(DebuggerServer.connectPipe());
    25   // Start tracking event loop lags.
    26   client.connect(function () {
    27     client.listTabs(function(resp) {
    28       front = new EventLoopLagFront(client, resp);
    29       front.start().then(success => {
    30         do_check_true(success);
    31         front.once("event-loop-lag", gotLagEvent);
    32         do_execute_soon(lag);
    33       });
    34     });
    35   });
    37   // Force a lag
    38   function lag() {
    39     let start = new Date();
    40     let duration = threshold + interval + 1;
    41     while (true) {
    42       if (((new Date()) - start) > duration) {
    43         break;
    44       }
    45     }
    46   }
    48   // Got a lag event. The test will time out if the actor
    49   // fails to detect the lag.
    50   function gotLagEvent(time) {
    51     do_print("lag: " + time);
    52     do_check_true(time >= threshold);
    53     front.stop().then(() => {
    54       finishClient(client);
    55     });
    56   }
    58   do_test_pending();
    59 }

mercurial