toolkit/devtools/webconsole/test/test_consoleapi.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>Test for the Console API</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>Test for the Console API</p>
    14 <script class="testbody" type="text/javascript;version=1.8">
    15 SimpleTest.waitForExplicitFinish();
    17 let expectedConsoleCalls = [];
    19 function doConsoleCalls(aState)
    20 {
    21   let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 2)).join("a");
    23   top.console.log("foobarBaz-log", undefined);
    24   top.console.info("foobarBaz-info", null);
    25   top.console.warn("foobarBaz-warn", top.document.documentElement);
    26   top.console.debug(null);
    27   top.console.trace();
    28   top.console.dir(top.document, top.location);
    29   top.console.log("foo", longString);
    31   expectedConsoleCalls = [
    32     {
    33       level: "log",
    34       filename: /test_consoleapi/,
    35       functionName: "doConsoleCalls",
    36       timeStamp: /^\d+$/,
    37       arguments: ["foobarBaz-log", { type: "undefined" }],
    38     },
    39     {
    40       level: "info",
    41       filename: /test_consoleapi/,
    42       functionName: "doConsoleCalls",
    43       timeStamp: /^\d+$/,
    44       arguments: ["foobarBaz-info", { type: "null" }],
    45     },
    46     {
    47       level: "warn",
    48       filename: /test_consoleapi/,
    49       functionName: "doConsoleCalls",
    50       timeStamp: /^\d+$/,
    51       arguments: ["foobarBaz-warn", { type: "object", actor: /[a-z]/ }],
    52     },
    53     {
    54       level: "debug",
    55       filename: /test_consoleapi/,
    56       functionName: "doConsoleCalls",
    57       timeStamp: /^\d+$/,
    58       arguments: [{ type: "null" }],
    59     },
    60     {
    61       level: "trace",
    62       filename: /test_consoleapi/,
    63       functionName: "doConsoleCalls",
    64       timeStamp: /^\d+$/,
    65       stacktrace: [
    66         {
    67           filename: /test_consoleapi/,
    68           functionName: "doConsoleCalls",
    69         },
    70         {
    71           filename: /test_consoleapi/,
    72           functionName: "onAttach",
    73         },
    74       ],
    75     },
    76     {
    77       level: "dir",
    78       filename: /test_consoleapi/,
    79       functionName: "doConsoleCalls",
    80       timeStamp: /^\d+$/,
    81       arguments: [
    82         {
    83           type: "object",
    84           actor: /[a-z]/,
    85           class: "XULDocument",
    86         },
    87         {
    88           type: "object",
    89           actor: /[a-z]/,
    90           class: "Location",
    91         }
    92       ],
    93     },
    94     {
    95       level: "log",
    96       filename: /test_consoleapi/,
    97       functionName: "doConsoleCalls",
    98       timeStamp: /^\d+$/,
    99       arguments: [
   100         "foo",
   101         {
   102           type: "longString",
   103           initial: longString.substring(0,
   104             DebuggerServer.LONG_STRING_INITIAL_LENGTH),
   105           length: longString.length,
   106           actor: /[a-z]/,
   107         },
   108       ],
   109     },
   110   ];
   111 }
   113 function startTest()
   114 {
   115   removeEventListener("load", startTest);
   117   attachConsole(["ConsoleAPI"], onAttach, true);
   118 }
   120 function onAttach(aState, aResponse)
   121 {
   122   onConsoleAPICall = onConsoleAPICall.bind(null, aState);
   123   aState.dbgClient.addListener("consoleAPICall", onConsoleAPICall);
   124   doConsoleCalls(aState.actor);
   125 }
   127 let consoleCalls = [];
   129 function onConsoleAPICall(aState, aType, aPacket)
   130 {
   131   info("received message level: " + aPacket.message.level);
   132   is(aPacket.from, aState.actor, "console API call actor");
   134   consoleCalls.push(aPacket.message);
   135   if (consoleCalls.length != expectedConsoleCalls.length) {
   136     return;
   137   }
   139   aState.dbgClient.removeListener("consoleAPICall", onConsoleAPICall);
   141   expectedConsoleCalls.forEach(function(aMessage, aIndex) {
   142     info("checking received console call #" + aIndex);
   143     checkConsoleAPICall(consoleCalls[aIndex], expectedConsoleCalls[aIndex]);
   144   });
   147   consoleCalls = [];
   149   closeDebugger(aState, function() {
   150     SimpleTest.finish();
   151   });
   152 }
   154 addEventListener("load", startTest);
   155 </script>
   156 </body>
   157 </html>

mercurial