1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/* vim:set ts=2 sw=2 sts=2 et: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that long strings can be expanded in the console output.
function test()
{
waitForExplicitFinish();
let tempScope = {};
Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope);
let DebuggerServer = tempScope.DebuggerServer;
let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a") +
"foobar";
let initialString =
longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
addTab("data:text/html;charset=utf8,test for bug 787981 - check that long strings can be expanded in the output.");
let hud = null;
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
openConsole(null, performTest);
}, true);
function performTest(aHud)
{
hud = aHud;
hud.jsterm.clearOutput(true);
hud.jsterm.execute("console.log('bazbaz', '" + longString +"', 'boom')");
waitForSuccess(waitForConsoleLog);
}
let waitForConsoleLog = {
name: "console.log output shown",
validatorFn: function()
{
return hud.outputNode.querySelector(".webconsole-msg-console");
},
successFn: function()
{
let msg = hud.outputNode.querySelector(".webconsole-msg-console");
is(msg.textContent.indexOf("foobar"), -1,
"foobar is not shown");
isnot(msg.textContent.indexOf("bazbaz"), -1,
"bazbaz is shown");
isnot(msg.textContent.indexOf("boom"), -1,
"boom is shown");
isnot(msg.textContent.indexOf(initialString), -1,
"initial string is shown");
let clickable = msg.querySelector(".longStringEllipsis");
ok(clickable, "long string ellipsis is shown");
scrollToVisible(clickable);
executeSoon(function() {
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
waitForSuccess(waitForFullString);
});
},
failureFn: finishTest,
};
let waitForFullString = {
name: "full string shown",
validatorFn: function()
{
let msg = hud.outputNode.querySelector(".webconsole-msg-log");
return msg.textContent.indexOf(longString) > -1;
},
successFn: function()
{
let msg = hud.outputNode.querySelector(".webconsole-msg-log");
isnot(msg.textContent.indexOf("bazbaz"), -1,
"bazbaz is shown");
isnot(msg.textContent.indexOf("boom"), -1,
"boom is shown");
let clickable = msg.querySelector(".longStringEllipsis");
ok(!clickable, "long string ellipsis is not shown");
executeSoon(function() {
hud.jsterm.clearOutput(true);
hud.jsterm.execute("'" + longString +"'");
waitForSuccess(waitForExecute);
});
},
failureFn: finishTest,
};
let waitForExecute = {
name: "execute() output shown",
validatorFn: function()
{
return hud.outputNode.querySelector(".webconsole-msg-output");
},
successFn: function()
{
let msg = hud.outputNode.querySelector(".webconsole-msg-output");
isnot(msg.textContent.indexOf(initialString), -1,
"initial string is shown");
is(msg.textContent.indexOf(longString), -1,
"full string is not shown");
let clickable = msg.querySelector(".longStringEllipsis");
ok(clickable, "long string ellipsis is shown");
scrollToVisible(clickable);
executeSoon(function() {
EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow);
waitForSuccess(waitForFullStringAfterExecute);
});
},
failureFn: finishTest,
};
let waitForFullStringAfterExecute = {
name: "full string shown again",
validatorFn: function()
{
let msg = hud.outputNode.querySelector(".webconsole-msg-output");
return msg.textContent.indexOf(longString) > -1;
},
successFn: function()
{
let msg = hud.outputNode.querySelector(".webconsole-msg-output");
let clickable = msg.querySelector(".longStringEllipsis");
ok(!clickable, "long string ellipsis is not shown");
executeSoon(finishTest);
},
failureFn: finishTest,
};
function scrollToVisible(aNode)
{
let richListBoxNode = aNode.parentNode;
while (richListBoxNode.tagName != "richlistbox") {
richListBoxNode = richListBoxNode.parentNode;
}
let boxObject = richListBoxNode.scrollBoxObject;
let nsIScrollBoxObject = boxObject.QueryInterface(Ci.nsIScrollBoxObject);
nsIScrollBoxObject.ensureElementIsVisible(aNode);
}
}
|