toolkit/devtools/webconsole/test/test_throw.html

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:8be83aaed492
1 <!DOCTYPE HTML>
2 <html lang="en">
3 <head>
4 <meta charset="utf8">
5 <title>Web Console throw 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>Web Console throw 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 attachConsole([], onAttach, true);
21 }
22
23 function onAttach(aState, aResponse)
24 {
25 let tests = [];
26
27 let falsyValues = ["-0", "null", "undefined", "Infinity", "-Infinity", "NaN"];
28 falsyValues.forEach(function(value) {
29 tests.push(function() {
30 aState.client.evaluateJS("throw " + value + ";", function(aResponse) {
31 let type = aResponse.exception.type;
32 is(type, value, "exception.type for throw " + value);
33 nextTest();
34 });
35 });
36 });
37
38 let identityTestValues = [false, 0];
39 identityTestValues.forEach(function(value) {
40 tests.push(function() {
41 aState.client.evaluateJS("throw " + value + ";", function(aResponse) {
42 let exception = aResponse.exception;
43 ise(exception, value, "response.exception for throw " + value);
44 nextTest();
45 });
46 });
47 });
48
49 let longString = Array(DebuggerServer.LONG_STRING_LENGTH + 1).join("a"),
50 shortedString = longString.substring(0,
51 DebuggerServer.LONG_STRING_INITIAL_LENGTH
52 );
53 tests.push(function() {
54 aState.client.evaluateJS("throw '" + longString + "';", function(aResponse) {
55 is(aResponse.exception.initial, shortedString,
56 "exception.initial for throw longString"
57 );
58 nextTest();
59 });
60 });
61
62 runTests(tests, endTest.bind(null, aState));
63 }
64
65 function endTest(aState)
66 {
67 closeDebugger(aState, function() {
68 SimpleTest.finish();
69 });
70 }
71
72 addEventListener("load", startTest);
73 </script>
74 </body>
75 </html>

mercurial