toolkit/devtools/webconsole/test/test_basics.html

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 <!DOCTYPE HTML>
     2 <html lang="en">
     3 <head>
     4   <meta charset="utf8">
     5   <title>Basic Web Console Actor tests</title>
     6   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     7   <script type="text/javascript;version=1.8" src="common.js"></script>
     8   <!-- Any copyright is dedicated to the Public Domain.
     9      - http://creativecommons.org/publicdomain/zero/1.0/ -->
    10 </head>
    11 <body>
    12 <p>Basic Web Console Actor tests</p>
    14 <script class="testbody" type="text/javascript;version=1.8">
    15 SimpleTest.waitForExplicitFinish();
    17 function startTest()
    18 {
    19   removeEventListener("load", startTest);
    21   attachConsole(["PageError"], onStartPageError);
    22 }
    24 function onStartPageError(aState, aResponse)
    25 {
    26   is(aResponse.startedListeners.length, 1, "startedListeners.length");
    27   is(aResponse.startedListeners[0], "PageError", "startedListeners: PageError");
    28   ok(aResponse.nativeConsoleAPI, "nativeConsoleAPI");
    30   closeDebugger(aState, function() {
    31     top.console_ = top.console;
    32     top.console = { lolz: "foo" };
    33     attachConsole(["PageError", "ConsoleAPI", "foo"],
    34                   onStartPageErrorAndConsoleAPI, true);
    35   });
    36 }
    38 function onStartPageErrorAndConsoleAPI(aState, aResponse)
    39 {
    40   let startedListeners = aResponse.startedListeners;
    41   is(startedListeners.length, 2, "startedListeners.length");
    42   isnot(startedListeners.indexOf("PageError"), -1, "startedListeners: PageError");
    43   isnot(startedListeners.indexOf("ConsoleAPI"), -1,
    44         "startedListeners: ConsoleAPI");
    45   is(startedListeners.indexOf("foo"), -1, "startedListeners: no foo");
    46   ok(!aResponse.nativeConsoleAPI, "!nativeConsoleAPI");
    48   aState.client.stopListeners(["ConsoleAPI", "foo"],
    49                               onStopConsoleAPI.bind(null, aState));
    50 }
    52 function onStopConsoleAPI(aState, aResponse)
    53 {
    54   is(aResponse.stoppedListeners.length, 1, "stoppedListeners.length");
    55   is(aResponse.stoppedListeners[0], "ConsoleAPI", "stoppedListeners: ConsoleAPI");
    57   closeDebugger(aState, function() {
    58     attachConsole(["ConsoleAPI"], onStartConsoleAPI);
    59   });
    60 }
    62 function onStartConsoleAPI(aState, aResponse)
    63 {
    64   is(aResponse.startedListeners.length, 1, "startedListeners.length");
    65   is(aResponse.startedListeners[0], "ConsoleAPI", "startedListeners: ConsoleAPI");
    66   ok(aResponse.nativeConsoleAPI, "nativeConsoleAPI");
    68   top.console = top.console_;
    69   delete top.console_;
    71   closeDebugger(aState, function() {
    72     SimpleTest.finish();
    73   });
    74 }
    76 addEventListener("load", startTest);
    77 </script>
    78 </body>
    79 </html>

mercurial