toolkit/devtools/webconsole/test/test_basics.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/webconsole/test/test_basics.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html lang="en">
     1.6 +<head>
     1.7 +  <meta charset="utf8">
     1.8 +  <title>Basic Web Console Actor tests</title>
     1.9 +  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.10 +  <script type="text/javascript;version=1.8" src="common.js"></script>
    1.11 +  <!-- Any copyright is dedicated to the Public Domain.
    1.12 +     - http://creativecommons.org/publicdomain/zero/1.0/ -->
    1.13 +</head>
    1.14 +<body>
    1.15 +<p>Basic Web Console Actor tests</p>
    1.16 +
    1.17 +<script class="testbody" type="text/javascript;version=1.8">
    1.18 +SimpleTest.waitForExplicitFinish();
    1.19 +
    1.20 +function startTest()
    1.21 +{
    1.22 +  removeEventListener("load", startTest);
    1.23 +
    1.24 +  attachConsole(["PageError"], onStartPageError);
    1.25 +}
    1.26 +
    1.27 +function onStartPageError(aState, aResponse)
    1.28 +{
    1.29 +  is(aResponse.startedListeners.length, 1, "startedListeners.length");
    1.30 +  is(aResponse.startedListeners[0], "PageError", "startedListeners: PageError");
    1.31 +  ok(aResponse.nativeConsoleAPI, "nativeConsoleAPI");
    1.32 +
    1.33 +  closeDebugger(aState, function() {
    1.34 +    top.console_ = top.console;
    1.35 +    top.console = { lolz: "foo" };
    1.36 +    attachConsole(["PageError", "ConsoleAPI", "foo"],
    1.37 +                  onStartPageErrorAndConsoleAPI, true);
    1.38 +  });
    1.39 +}
    1.40 +
    1.41 +function onStartPageErrorAndConsoleAPI(aState, aResponse)
    1.42 +{
    1.43 +  let startedListeners = aResponse.startedListeners;
    1.44 +  is(startedListeners.length, 2, "startedListeners.length");
    1.45 +  isnot(startedListeners.indexOf("PageError"), -1, "startedListeners: PageError");
    1.46 +  isnot(startedListeners.indexOf("ConsoleAPI"), -1,
    1.47 +        "startedListeners: ConsoleAPI");
    1.48 +  is(startedListeners.indexOf("foo"), -1, "startedListeners: no foo");
    1.49 +  ok(!aResponse.nativeConsoleAPI, "!nativeConsoleAPI");
    1.50 +
    1.51 +  aState.client.stopListeners(["ConsoleAPI", "foo"],
    1.52 +                              onStopConsoleAPI.bind(null, aState));
    1.53 +}
    1.54 +
    1.55 +function onStopConsoleAPI(aState, aResponse)
    1.56 +{
    1.57 +  is(aResponse.stoppedListeners.length, 1, "stoppedListeners.length");
    1.58 +  is(aResponse.stoppedListeners[0], "ConsoleAPI", "stoppedListeners: ConsoleAPI");
    1.59 +
    1.60 +  closeDebugger(aState, function() {
    1.61 +    attachConsole(["ConsoleAPI"], onStartConsoleAPI);
    1.62 +  });
    1.63 +}
    1.64 +
    1.65 +function onStartConsoleAPI(aState, aResponse)
    1.66 +{
    1.67 +  is(aResponse.startedListeners.length, 1, "startedListeners.length");
    1.68 +  is(aResponse.startedListeners[0], "ConsoleAPI", "startedListeners: ConsoleAPI");
    1.69 +  ok(aResponse.nativeConsoleAPI, "nativeConsoleAPI");
    1.70 +
    1.71 +  top.console = top.console_;
    1.72 +  delete top.console_;
    1.73 +
    1.74 +  closeDebugger(aState, function() {
    1.75 +    SimpleTest.finish();
    1.76 +  });
    1.77 +}
    1.78 +
    1.79 +addEventListener("load", startTest);
    1.80 +</script>
    1.81 +</body>
    1.82 +</html>

mercurial