|
1 /* vim: set ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 /* Bug 690552 */ |
|
5 |
|
6 function test() |
|
7 { |
|
8 waitForExplicitFinish(); |
|
9 |
|
10 gBrowser.selectedTab = gBrowser.addTab(); |
|
11 gBrowser.selectedBrowser.addEventListener("load", function browserLoad() { |
|
12 gBrowser.selectedBrowser.removeEventListener("load", browserLoad, true); |
|
13 openScratchpad(runTests, {"state":{"text":""}}); |
|
14 }, true); |
|
15 |
|
16 content.location = "data:text/html,<p>test that exceptions are output as " + |
|
17 "comments for 'display' and not sent to the console in Scratchpad"; |
|
18 } |
|
19 |
|
20 function runTests() |
|
21 { |
|
22 let scratchpad = gScratchpadWindow.Scratchpad; |
|
23 |
|
24 let message = "\"Hello World!\"" |
|
25 let openComment = "\n/*\n"; |
|
26 let closeComment = "\n*/"; |
|
27 let error = "throw new Error(\"Ouch!\")"; |
|
28 let syntaxError = "("; |
|
29 |
|
30 let tests = [{ |
|
31 method: "display", |
|
32 code: message, |
|
33 result: message + openComment + "Hello World!" + closeComment, |
|
34 label: "message display output" |
|
35 }, |
|
36 { |
|
37 method: "display", |
|
38 code: error, |
|
39 result: error + openComment + "Exception: Ouch!\n@" + |
|
40 scratchpad.uniqueName + ":1:1" + closeComment, |
|
41 label: "error display output", |
|
42 }, |
|
43 { |
|
44 method: "display", |
|
45 code: syntaxError, |
|
46 result: syntaxError + openComment + "Exception: syntax error\n@" + |
|
47 scratchpad.uniqueName + ":1" + closeComment, |
|
48 label: "syntaxError display output", |
|
49 }, |
|
50 { |
|
51 method: "run", |
|
52 code: message, |
|
53 result: message, |
|
54 label: "message run output", |
|
55 }, |
|
56 { |
|
57 method: "run", |
|
58 code: error, |
|
59 result: error + openComment + "Exception: Ouch!\n@" + |
|
60 scratchpad.uniqueName + ":1:1" + closeComment, |
|
61 label: "error run output", |
|
62 }, |
|
63 { |
|
64 method: "run", |
|
65 code: syntaxError, |
|
66 result: syntaxError + openComment + "Exception: syntax error\n@" + |
|
67 scratchpad.uniqueName + ":1" + closeComment, |
|
68 label: "syntaxError run output", |
|
69 }]; |
|
70 |
|
71 runAsyncTests(scratchpad, tests).then(finish); |
|
72 } |