Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 // Test the webconsole output for various types of objects.
8 const TEST_URI = "data:text/html;charset=utf8,test for console output - 01";
10 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
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;
17 let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a");
18 let initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
20 let inputTests = [
21 // 0
22 {
23 input: "'hello \\nfrom \\rthe \\\"string world!'",
24 output: "\"hello \nfrom \rthe \"string world!\"",
25 },
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 },
34 // 2
35 {
36 input: "'" + longString + "'",
37 output: '"' + initialString + "\"[\u2026]",
38 printOutput: initialString,
39 },
41 // 3
42 {
43 input: "''",
44 output: '""',
45 printOutput: '""',
46 },
48 // 4
49 {
50 input: "0",
51 output: "0",
52 },
54 // 5
55 {
56 input: "'0'",
57 output: '"0"',
58 },
60 // 6
61 {
62 input: "42",
63 output: "42",
64 },
66 // 7
67 {
68 input: "'42'",
69 output: '"42"',
70 },
72 // 8
73 {
74 input: "/foobar/",
75 output: "/foobar/",
76 inspectable: true,
77 },
78 ];
80 longString = initialString = null;
82 function test() {
83 registerCleanupFunction(() => {
84 DebuggerServer.LONG_STRING_LENGTH = LONG_STRING_LENGTH;
85 DebuggerServer.LONG_STRING_INITIAL_LENGTH = LONG_STRING_INITIAL_LENGTH;
86 });
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 }
95 function finishUp() {
96 inputTests = null;
97 finishTest();
98 }