|
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> |
|
13 |
|
14 <script class="testbody" type="text/javascript;version=1.8"> |
|
15 SimpleTest.waitForExplicitFinish(); |
|
16 |
|
17 function startTest() |
|
18 { |
|
19 removeEventListener("load", startTest); |
|
20 |
|
21 attachConsole(["PageError"], onStartPageError); |
|
22 } |
|
23 |
|
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"); |
|
29 |
|
30 closeDebugger(aState, function() { |
|
31 top.console_ = top.console; |
|
32 top.console = { lolz: "foo" }; |
|
33 attachConsole(["PageError", "ConsoleAPI", "foo"], |
|
34 onStartPageErrorAndConsoleAPI, true); |
|
35 }); |
|
36 } |
|
37 |
|
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"); |
|
47 |
|
48 aState.client.stopListeners(["ConsoleAPI", "foo"], |
|
49 onStopConsoleAPI.bind(null, aState)); |
|
50 } |
|
51 |
|
52 function onStopConsoleAPI(aState, aResponse) |
|
53 { |
|
54 is(aResponse.stoppedListeners.length, 1, "stoppedListeners.length"); |
|
55 is(aResponse.stoppedListeners[0], "ConsoleAPI", "stoppedListeners: ConsoleAPI"); |
|
56 |
|
57 closeDebugger(aState, function() { |
|
58 attachConsole(["ConsoleAPI"], onStartConsoleAPI); |
|
59 }); |
|
60 } |
|
61 |
|
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"); |
|
67 |
|
68 top.console = top.console_; |
|
69 delete top.console_; |
|
70 |
|
71 closeDebugger(aState, function() { |
|
72 SimpleTest.finish(); |
|
73 }); |
|
74 } |
|
75 |
|
76 addEventListener("load", startTest); |
|
77 </script> |
|
78 </body> |
|
79 </html> |