tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_basics.html (2056B)


      1 <!DOCTYPE HTML>
      2 <html lang="en">
      3 <head>
      4  <meta charset="utf8">
      5  <title>Basic Web Console Actor tests</title>
      6  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      7  <script type="text/javascript" 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>
     13 
     14 <script class="testbody" type="text/javascript">
     15 "use strict";
     16 
     17 SimpleTest.waitForExplicitFinish();
     18 
     19 async function startTest()
     20 {
     21  removeEventListener("load", startTest);
     22 
     23  let {state, response} = await attachConsoleToTab(["PageError"]);
     24  is(response.startedListeners.length, 1, "startedListeners.length");
     25  is(response.startedListeners[0], "PageError", "startedListeners: PageError");
     26 
     27  await closeDebugger(state);
     28  top.console_ = top.console;
     29  top.console = { lolz: "foo" };
     30  ({state, response} = await attachConsoleToTab(["PageError", "ConsoleAPI", "foo"]));
     31 
     32  const startedListeners = response.startedListeners;
     33  is(startedListeners.length, 2, "startedListeners.length");
     34  isnot(startedListeners.indexOf("PageError"), -1, "startedListeners: PageError");
     35  isnot(startedListeners.indexOf("ConsoleAPI"), -1,
     36        "startedListeners: ConsoleAPI");
     37  is(startedListeners.indexOf("foo"), -1, "startedListeners: no foo");
     38 
     39  top.console = top.console_;
     40  response = await state.webConsoleFront.stopListeners(["ConsoleAPI", "foo"]);
     41 
     42  is(response.stoppedListeners.length, 1, "stoppedListeners.length");
     43  is(response.stoppedListeners[0], "ConsoleAPI", "stoppedListeners: ConsoleAPI");
     44  await closeDebugger(state);
     45  ({state, response} = await attachConsoleToTab(["ConsoleAPI"]));
     46 
     47  is(response.startedListeners.length, 1, "startedListeners.length");
     48  is(response.startedListeners[0], "ConsoleAPI", "startedListeners: ConsoleAPI");
     49 
     50  top.console = top.console_;
     51  delete top.console_;
     52 
     53  closeDebugger(state, function() {
     54    SimpleTest.finish();
     55  });
     56 }
     57 
     58 addEventListener("load", startTest);
     59 </script>
     60 </body>
     61 </html>