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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Check that variables view works as expected in the web console.
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-eval-in-stackframe.html";
let gWebConsole, gJSTerm, gVariablesView;
let hud;
let test = asyncTest(function* () {
yield loadTab(TEST_URI);
hud = yield openConsole();
gWebConsole = hud;
gJSTerm = hud.jsterm;
let msg = yield gJSTerm.execute("fooObj");
ok(msg, "output message found");
ok(msg.textContent.contains('{ testProp: "testValue" }'), "message text check");
let anchor = msg.querySelector("a");
ok(anchor, "object link found");
let fetched = gJSTerm.once("variablesview-fetched");
// executeSoon
EventUtils.synthesizeMouse(anchor, 2, 2, {}, gWebConsole.iframeWindow);
let view = yield fetched;
let results = yield onFooObjFetch(view);
let vView = yield onTestPropFound(results);
let results2 = yield onFooObjFetchAfterUpdate(vView);
let vView2 = yield onUpdatedTestPropFound(results2);
let results3 = yield onFooObjFetchAfterPropRename(vView2);
let vView3 = yield onRenamedTestPropFound(results3);
let results4 = yield onPropUpdateError(vView3);
yield onRenamedTestPropFoundAgain(results4);
let prop = results4[0].matchedProp;
yield testPropDelete(prop);
gWebConsole = gJSTerm = gVariablesView = null;
});
function onFooObjFetch(aVar)
{
gVariablesView = aVar._variablesView;
ok(gVariablesView, "variables view object");
return findVariableViewProperties(aVar, [
{ name: "testProp", value: "testValue" },
], { webconsole: gWebConsole });
}
function onTestPropFound(aResults)
{
let prop = aResults[0].matchedProp;
ok(prop, "matched the |testProp| property in the variables view");
is("testValue", aResults[0].value,
"|fooObj.testProp| value is correct");
// Check that property value updates work and that jsterm functions can be
// used.
return updateVariablesViewProperty({
property: prop,
field: "value",
string: "document.title + window.location + $('p')",
webconsole: gWebConsole
});
}
function onFooObjFetchAfterUpdate(aVar)
{
info("onFooObjFetchAfterUpdate");
let expectedValue = content.document.title + content.location
+ '[object HTMLParagraphElement]';
return findVariableViewProperties(aVar, [
{ name: "testProp", value: expectedValue },
], { webconsole: gWebConsole });
}
function onUpdatedTestPropFound(aResults)
{
let prop = aResults[0].matchedProp;
ok(prop, "matched the updated |testProp| property value");
is(content.wrappedJSObject.fooObj.testProp, aResults[0].value,
"|fooObj.testProp| value has been updated");
// Check that property name updates work.
return updateVariablesViewProperty({
property: prop,
field: "name",
string: "testUpdatedProp",
webconsole: gWebConsole
});
}
function onFooObjFetchAfterPropRename(aVar)
{
info("onFooObjFetchAfterPropRename");
let para = content.wrappedJSObject.document.querySelector("p");
let expectedValue = content.document.title + content.location + para;
// Check that the new value is in the variables view.
return findVariableViewProperties(aVar, [
{ name: "testUpdatedProp", value: expectedValue },
], { webconsole: gWebConsole });
}
function onRenamedTestPropFound(aResults)
{
let prop = aResults[0].matchedProp;
ok(prop, "matched the renamed |testProp| property");
ok(!content.wrappedJSObject.fooObj.testProp,
"|fooObj.testProp| has been deleted");
is(content.wrappedJSObject.fooObj.testUpdatedProp, aResults[0].value,
"|fooObj.testUpdatedProp| is correct");
// Check that property value updates that cause exceptions are reported in
// the web console output.
return updateVariablesViewProperty({
property: prop,
field: "value",
string: "foobarzFailure()",
webconsole: gWebConsole
});
}
function onPropUpdateError(aVar)
{
info("onPropUpdateError");
let para = content.wrappedJSObject.document.querySelector("p");
let expectedValue = content.document.title + content.location + para;
// Make sure the property did not change.
return findVariableViewProperties(aVar, [
{ name: "testUpdatedProp", value: expectedValue },
], { webconsole: gWebConsole });
}
function onRenamedTestPropFoundAgain(aResults)
{
let prop = aResults[0].matchedProp;
ok(prop, "matched the renamed |testProp| property again");
let outputNode = gWebConsole.outputNode;
return waitForMessages({
webconsole: gWebConsole,
messages: [{
name: "exception in property update reported in the web console output",
text: "foobarzFailure",
category: CATEGORY_OUTPUT,
severity: SEVERITY_ERROR,
}],
});
}
function testPropDelete(aProp)
{
gVariablesView.window.focus();
aProp.focus();
executeSoon(() => {
EventUtils.synthesizeKey("VK_DELETE", {}, gVariablesView.window);
});
return waitForSuccess({
name: "property deleted",
timeout: 60000,
validator: () => !("testUpdatedProp" in content.wrappedJSObject.fooObj)
});
}
|