toolkit/devtools/server/tests/unit/test_blackboxing-04.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 behavior of blackboxing sources we are currently paused in.
     6  */
     8 var gDebuggee;
     9 var gClient;
    10 var gThreadClient;
    12 function run_test()
    13 {
    14   initTestDebuggerServer();
    15   gDebuggee = addTestGlobal("test-black-box");
    16   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    17   gClient.connect(function() {
    18     attachTestTabAndResume(gClient, "test-black-box", function(aResponse, aTabClient, aThreadClient) {
    19       gThreadClient = aThreadClient;
    20       test_black_box();
    21     });
    22   });
    23   do_test_pending();
    24 }
    26 const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
    27 const SOURCE_URL = "http://example.com/source.js";
    29 function test_black_box()
    30 {
    31   gClient.addOneTimeListener("paused", function () {
    32     gThreadClient.setBreakpoint({
    33       url: BLACK_BOXED_URL,
    34       line: 2
    35     }, function (aResponse) {
    36       do_check_true(!aResponse.error, "Should be able to set breakpoint.");
    37       test_black_box_paused();
    38     });
    39   });
    41   Components.utils.evalInSandbox(
    42     "" + function doStuff(k) { // line 1
    43       debugger;                // line 2
    44       k(100);                  // line 3
    45     },                         // line 4
    46     gDebuggee,
    47     "1.8",
    48     BLACK_BOXED_URL,
    49     1
    50   );
    52   Components.utils.evalInSandbox(
    53     "" + function runTest() { // line 1
    54       doStuff(                // line 2
    55         function (n) {        // line 3
    56           return n;           // line 4
    57         }                     // line 5
    58       );                      // line 6
    59     }                         // line 7
    60     + "\n runTest();",        // line 8
    61     gDebuggee,
    62     "1.8",
    63     SOURCE_URL,
    64     1
    65   );
    66 }
    68 function test_black_box_paused() {
    69   gThreadClient.getSources(function ({error, sources}) {
    70     do_check_true(!error, "Should not get an error: " + error);
    71     let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]);
    73     sourceClient.blackBox(function ({error, pausedInSource}) {
    74       do_check_true(!error, "Should not get an error: " + error);
    75       do_check_true(pausedInSource, "We should be notified that we are currently paused in this source");
    76       finishClient(gClient);
    77     });
    78   });
    79 }

mercurial