|
1 /* vim:set ts=2 sw=2 sts=2 et: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 // Test that long strings can be expanded in the console output. |
|
6 |
|
7 function test() |
|
8 { |
|
9 waitForExplicitFinish(); |
|
10 |
|
11 let tempScope = {}; |
|
12 Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope); |
|
13 let DebuggerServer = tempScope.DebuggerServer; |
|
14 |
|
15 let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a") + |
|
16 "foobar"; |
|
17 let initialString = |
|
18 longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH); |
|
19 |
|
20 addTab("data:text/html;charset=utf8,test for bug 787981 - check that long strings can be expanded in the output."); |
|
21 |
|
22 let hud = null; |
|
23 |
|
24 gBrowser.selectedBrowser.addEventListener("load", function onLoad() { |
|
25 gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); |
|
26 openConsole(null, performTest); |
|
27 }, true); |
|
28 |
|
29 function performTest(aHud) |
|
30 { |
|
31 hud = aHud; |
|
32 hud.jsterm.clearOutput(true); |
|
33 hud.jsterm.execute("console.log('bazbaz', '" + longString +"', 'boom')"); |
|
34 |
|
35 waitForMessages({ |
|
36 webconsole: hud, |
|
37 messages: [{ |
|
38 name: "console.log output", |
|
39 text: ["bazbaz", "boom", initialString], |
|
40 noText: "foobar", |
|
41 longString: true, |
|
42 }], |
|
43 }).then(onConsoleMessage); |
|
44 } |
|
45 |
|
46 function onConsoleMessage([result]) |
|
47 { |
|
48 let clickable = result.longStrings[0]; |
|
49 ok(clickable, "long string ellipsis is shown"); |
|
50 |
|
51 clickable.scrollIntoView(false); |
|
52 |
|
53 EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow); |
|
54 |
|
55 waitForMessages({ |
|
56 webconsole: hud, |
|
57 messages: [{ |
|
58 name: "full string", |
|
59 text: ["bazbaz", "boom", longString], |
|
60 category: CATEGORY_WEBDEV, |
|
61 longString: false, |
|
62 }], |
|
63 }).then(() => { |
|
64 hud.jsterm.clearOutput(true); |
|
65 hud.jsterm.execute("'" + longString +"'", onExecute); |
|
66 }); |
|
67 } |
|
68 |
|
69 function onExecute(msg) |
|
70 { |
|
71 isnot(msg.textContent.indexOf(initialString), -1, |
|
72 "initial string is shown"); |
|
73 is(msg.textContent.indexOf(longString), -1, |
|
74 "full string is not shown"); |
|
75 |
|
76 let clickable = msg.querySelector(".longStringEllipsis"); |
|
77 ok(clickable, "long string ellipsis is shown"); |
|
78 |
|
79 clickable.scrollIntoView(false); |
|
80 |
|
81 EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow); |
|
82 |
|
83 waitForMessages({ |
|
84 webconsole: hud, |
|
85 messages: [{ |
|
86 name: "full string", |
|
87 text: longString, |
|
88 category: CATEGORY_OUTPUT, |
|
89 longString: false, |
|
90 }], |
|
91 }).then(finishTest); |
|
92 } |
|
93 } |