|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 */ |
|
5 |
|
6 // Test the webconsole output for various types of objects. |
|
7 |
|
8 const TEST_URI = "data:text/html;charset=utf8,test for console output - 01"; |
|
9 |
|
10 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {}); |
|
11 |
|
12 let LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_LENGTH; |
|
13 let LONG_STRING_INITIAL_LENGTH = DebuggerServer.LONG_STRING_INITIAL_LENGTH; |
|
14 DebuggerServer.LONG_STRING_LENGTH = 100; |
|
15 DebuggerServer.LONG_STRING_INITIAL_LENGTH = 50; |
|
16 |
|
17 let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a"); |
|
18 let initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH); |
|
19 |
|
20 let inputTests = [ |
|
21 // 0 |
|
22 { |
|
23 input: "'hello \\nfrom \\rthe \\\"string world!'", |
|
24 output: "\"hello \nfrom \rthe \"string world!\"", |
|
25 }, |
|
26 |
|
27 // 1 |
|
28 { |
|
29 // unicode test |
|
30 input: "'\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165'", |
|
31 output: "\"\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165\"", |
|
32 }, |
|
33 |
|
34 // 2 |
|
35 { |
|
36 input: "'" + longString + "'", |
|
37 output: '"' + initialString + "\"[\u2026]", |
|
38 printOutput: initialString, |
|
39 }, |
|
40 |
|
41 // 3 |
|
42 { |
|
43 input: "''", |
|
44 output: '""', |
|
45 printOutput: '""', |
|
46 }, |
|
47 |
|
48 // 4 |
|
49 { |
|
50 input: "0", |
|
51 output: "0", |
|
52 }, |
|
53 |
|
54 // 5 |
|
55 { |
|
56 input: "'0'", |
|
57 output: '"0"', |
|
58 }, |
|
59 |
|
60 // 6 |
|
61 { |
|
62 input: "42", |
|
63 output: "42", |
|
64 }, |
|
65 |
|
66 // 7 |
|
67 { |
|
68 input: "'42'", |
|
69 output: '"42"', |
|
70 }, |
|
71 |
|
72 // 8 |
|
73 { |
|
74 input: "/foobar/", |
|
75 output: "/foobar/", |
|
76 inspectable: true, |
|
77 }, |
|
78 ]; |
|
79 |
|
80 longString = initialString = null; |
|
81 |
|
82 function test() { |
|
83 registerCleanupFunction(() => { |
|
84 DebuggerServer.LONG_STRING_LENGTH = LONG_STRING_LENGTH; |
|
85 DebuggerServer.LONG_STRING_INITIAL_LENGTH = LONG_STRING_INITIAL_LENGTH; |
|
86 }); |
|
87 |
|
88 Task.spawn(function*() { |
|
89 let {tab} = yield loadTab(TEST_URI); |
|
90 let hud = yield openConsole(tab); |
|
91 return checkOutputForInputs(hud, inputTests); |
|
92 }).then(finishUp); |
|
93 } |
|
94 |
|
95 function finishUp() { |
|
96 inputTests = null; |
|
97 finishTest(); |
|
98 } |