toolkit/devtools/server/tests/unit/test_source-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 var gDebuggee;
     6 var gClient;
     7 var gThreadClient;
     9 // This test ensures that we can create SourceActors and SourceClients properly,
    10 // and that they can communicate over the protocol to fetch the source text for
    11 // a given script.
    13 function run_test()
    14 {
    15   initTestDebuggerServer();
    16   gDebuggee = addTestGlobal("test-grips");
    17   Cu.evalInSandbox(
    18     "" + function stopMe(arg1) {
    19       debugger;
    20     },
    21     gDebuggee,
    22     "1.8",
    23     getFileUrl("test_source-01.js")
    24   );
    26   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    27   gClient.connect(function() {
    28     attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) {
    29       gThreadClient = aThreadClient;
    30       test_source();
    31     });
    32   });
    33   do_test_pending();
    34 }
    36 const SOURCE_URL = "http://example.com/foobar.js";
    37 const SOURCE_CONTENT = "stopMe()";
    39 function test_source()
    40 {
    41   DebuggerServer.LONG_STRING_LENGTH = 200;
    43   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    44     gThreadClient.getSources(function (aResponse) {
    45       do_check_true(!!aResponse);
    46       do_check_true(!!aResponse.sources);
    48       let source = aResponse.sources.filter(function (s) {
    49         return s.url === SOURCE_URL;
    50       })[0];
    52       do_check_true(!!source);
    54       let sourceClient = gThreadClient.source(source);
    55       sourceClient.source(function (aResponse) {
    56         do_check_true(!!aResponse);
    57         do_check_true(!aResponse.error);
    58         do_check_true(!!aResponse.contentType);
    59         do_check_true(aResponse.contentType.contains("javascript"));
    61         do_check_true(!!aResponse.source);
    62         do_check_eq(SOURCE_CONTENT,
    63                     aResponse.source);
    65         gThreadClient.resume(function () {
    66           finishClient(gClient);
    67         });
    68       });
    69     });
    70   });
    72   Cu.evalInSandbox(
    73     SOURCE_CONTENT,
    74     gDebuggee,
    75     "1.8",
    76     SOURCE_URL
    77   );
    78 }

mercurial