browser/devtools/debugger/test/browser_dbg_variables-view-webidl.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:94d2076cf6ad
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Make sure that the variables view correctly displays WebIDL attributes in DOM
6 * objects.
7 */
8
9 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
10
11 let gTab, gDebuggee, gPanel, gDebugger;
12 let gVariables;
13
14 function test() {
15 // Debug test slaves are a bit slow at this test.
16 requestLongerTimeout(2);
17
18 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
19 gTab = aTab;
20 gDebuggee = aDebuggee;
21 gPanel = aPanel;
22 gDebugger = gPanel.panelWin;
23 gVariables = gDebugger.DebuggerView.Variables;
24
25 waitForSourceAndCaretAndScopes(gPanel, ".html", 24)
26 .then(expandGlobalScope)
27 .then(performTest)
28 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
29 .then(null, aError => {
30 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
31 });
32
33 EventUtils.sendMouseEvent({ type: "click" },
34 gDebuggee.document.querySelector("button"),
35 gDebuggee);
36 });
37 }
38
39 function expandGlobalScope() {
40 let deferred = promise.defer();
41
42 let globalScope = gVariables.getScopeAtIndex(1);
43 is(globalScope.expanded, false,
44 "The global scope should not be expanded by default.");
45
46 gDebugger.once(gDebugger.EVENTS.FETCHED_VARIABLES, deferred.resolve);
47
48 EventUtils.sendMouseEvent({ type: "mousedown" },
49 globalScope.target.querySelector(".name"),
50 gDebugger);
51
52 return deferred.promise;
53 }
54
55 function performTest() {
56 let deferred = promise.defer();
57 let globalScope = gVariables.getScopeAtIndex(1);
58
59 let buttonVar = globalScope.get("button");
60 let buttonAsProtoVar = globalScope.get("buttonAsProto");
61 let documentVar = globalScope.get("document");
62
63 is(buttonVar.target.querySelector(".name").getAttribute("value"), "button",
64 "Should have the right property name for 'button'.");
65 is(buttonVar.target.querySelector(".value").getAttribute("value"), "<button>",
66 "Should have the right property value for 'button'.");
67 ok(buttonVar.target.querySelector(".value").className.contains("token-domnode"),
68 "Should have the right token class for 'button'.");
69
70 is(buttonAsProtoVar.target.querySelector(".name").getAttribute("value"), "buttonAsProto",
71 "Should have the right property name for 'buttonAsProto'.");
72 is(buttonAsProtoVar.target.querySelector(".value").getAttribute("value"), "Object",
73 "Should have the right property value for 'buttonAsProto'.");
74 ok(buttonAsProtoVar.target.querySelector(".value").className.contains("token-other"),
75 "Should have the right token class for 'buttonAsProto'.");
76
77 is(documentVar.target.querySelector(".name").getAttribute("value"), "document",
78 "Should have the right property name for 'document'.");
79 is(documentVar.target.querySelector(".value").getAttribute("value"),
80 "HTMLDocument \u2192 doc_frame-parameters.html",
81 "Should have the right property value for 'document'.");
82 ok(documentVar.target.querySelector(".value").className.contains("token-domnode"),
83 "Should have the right token class for 'document'.");
84
85 is(buttonVar.expanded, false,
86 "The buttonVar should not be expanded at this point.");
87 is(buttonAsProtoVar.expanded, false,
88 "The buttonAsProtoVar should not be expanded at this point.");
89 is(documentVar.expanded, false,
90 "The documentVar should not be expanded at this point.");
91
92 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES, 3).then(() => {
93 is(buttonVar.get("type").target.querySelector(".name").getAttribute("value"), "type",
94 "Should have the right property name for 'type'.");
95 is(buttonVar.get("type").target.querySelector(".value").getAttribute("value"), "\"submit\"",
96 "Should have the right property value for 'type'.");
97 ok(buttonVar.get("type").target.querySelector(".value").className.contains("token-string"),
98 "Should have the right token class for 'type'.");
99
100 is(buttonVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes",
101 "Should have the right property name for 'childNodes'.");
102 is(buttonVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[1]",
103 "Should have the right property value for 'childNodes'.");
104 ok(buttonVar.get("childNodes").target.querySelector(".value").className.contains("token-other"),
105 "Should have the right token class for 'childNodes'.");
106
107 is(buttonVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick",
108 "Should have the right property name for 'onclick'.");
109 is(buttonVar.get("onclick").target.querySelector(".value").getAttribute("value"), "onclick(event)",
110 "Should have the right property value for 'onclick'.");
111 ok(buttonVar.get("onclick").target.querySelector(".value").className.contains("token-other"),
112 "Should have the right token class for 'onclick'.");
113
114 is(documentVar.get("title").target.querySelector(".name").getAttribute("value"), "title",
115 "Should have the right property name for 'title'.");
116 is(documentVar.get("title").target.querySelector(".value").getAttribute("value"), "\"Debugger test page\"",
117 "Should have the right property value for 'title'.");
118 ok(documentVar.get("title").target.querySelector(".value").className.contains("token-string"),
119 "Should have the right token class for 'title'.");
120
121 is(documentVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes",
122 "Should have the right property name for 'childNodes'.");
123 is(documentVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[3]",
124 "Should have the right property value for 'childNodes'.");
125 ok(documentVar.get("childNodes").target.querySelector(".value").className.contains("token-other"),
126 "Should have the right token class for 'childNodes'.");
127
128 is(documentVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick",
129 "Should have the right property name for 'onclick'.");
130 is(documentVar.get("onclick").target.querySelector(".value").getAttribute("value"), "null",
131 "Should have the right property value for 'onclick'.");
132 ok(documentVar.get("onclick").target.querySelector(".value").className.contains("token-null"),
133 "Should have the right token class for 'onclick'.");
134
135 let buttonProtoVar = buttonVar.get("__proto__");
136 let buttonAsProtoProtoVar = buttonAsProtoVar.get("__proto__");
137 let documentProtoVar = documentVar.get("__proto__");
138
139 is(buttonProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
140 "Should have the right property name for '__proto__'.");
141 is(buttonProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLButtonElementPrototype",
142 "Should have the right property value for '__proto__'.");
143 ok(buttonProtoVar.target.querySelector(".value").className.contains("token-other"),
144 "Should have the right token class for '__proto__'.");
145
146 is(buttonAsProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
147 "Should have the right property name for '__proto__'.");
148 is(buttonAsProtoProtoVar.target.querySelector(".value").getAttribute("value"), "<button>",
149 "Should have the right property value for '__proto__'.");
150 ok(buttonAsProtoProtoVar.target.querySelector(".value").className.contains("token-domnode"),
151 "Should have the right token class for '__proto__'.");
152
153 is(documentProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
154 "Should have the right property name for '__proto__'.");
155 is(documentProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLDocumentPrototype",
156 "Should have the right property value for '__proto__'.");
157 ok(documentProtoVar.target.querySelector(".value").className.contains("token-other"),
158 "Should have the right token class for '__proto__'.");
159
160 is(buttonProtoVar.expanded, false,
161 "The buttonProtoVar should not be expanded at this point.");
162 is(buttonAsProtoProtoVar.expanded, false,
163 "The buttonAsProtoProtoVar should not be expanded at this point.");
164 is(documentProtoVar.expanded, false,
165 "The documentProtoVar should not be expanded at this point.");
166
167 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES, 3).then(() => {
168 is(buttonAsProtoProtoVar.get("type").target.querySelector(".name").getAttribute("value"), "type",
169 "Should have the right property name for 'type'.");
170 is(buttonAsProtoProtoVar.get("type").target.querySelector(".value").getAttribute("value"), "\"submit\"",
171 "Should have the right property value for 'type'.");
172 ok(buttonAsProtoProtoVar.get("type").target.querySelector(".value").className.contains("token-string"),
173 "Should have the right token class for 'type'.");
174
175 is(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes",
176 "Should have the right property name for 'childNodes'.");
177 is(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[1]",
178 "Should have the right property value for 'childNodes'.");
179 ok(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".value").className.contains("token-other"),
180 "Should have the right token class for 'childNodes'.");
181
182 is(buttonAsProtoProtoVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick",
183 "Should have the right property name for 'onclick'.");
184 is(buttonAsProtoProtoVar.get("onclick").target.querySelector(".value").getAttribute("value"), "onclick(event)",
185 "Should have the right property value for 'onclick'.");
186 ok(buttonAsProtoProtoVar.get("onclick").target.querySelector(".value").className.contains("token-other"),
187 "Should have the right token class for 'onclick'.");
188
189 let buttonProtoProtoVar = buttonProtoVar.get("__proto__");
190 let buttonAsProtoProtoProtoVar = buttonAsProtoProtoVar.get("__proto__");
191 let documentProtoProtoVar = documentProtoVar.get("__proto__");
192
193 is(buttonProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
194 "Should have the right property name for '__proto__'.");
195 is(buttonProtoProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLElementPrototype",
196 "Should have the right property value for '__proto__'.");
197 ok(buttonProtoProtoVar.target.querySelector(".value").className.contains("token-other"),
198 "Should have the right token class for '__proto__'.");
199
200 is(buttonAsProtoProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
201 "Should have the right property name for '__proto__'.");
202 is(buttonAsProtoProtoProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLButtonElementPrototype",
203 "Should have the right property value for '__proto__'.");
204 ok(buttonAsProtoProtoProtoVar.target.querySelector(".value").className.contains("token-other"),
205 "Should have the right token class for '__proto__'.");
206
207 is(documentProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
208 "Should have the right property name for '__proto__'.");
209 is(documentProtoProtoVar.target.querySelector(".value").getAttribute("value"), "DocumentPrototype",
210 "Should have the right property value for '__proto__'.");
211 ok(documentProtoProtoVar.target.querySelector(".value").className.contains("token-other"),
212 "Should have the right token class for '__proto__'.")
213
214 is(buttonAsProtoProtoProtoVar.expanded, false,
215 "The buttonAsProtoProtoProtoVar should not be expanded at this point.");
216 is(buttonAsProtoProtoProtoVar.expanded, false,
217 "The buttonAsProtoProtoProtoVar should not be expanded at this point.");
218 is(documentProtoProtoVar.expanded, false,
219 "The documentProtoProtoVar should not be expanded at this point.");
220
221 deferred.resolve();
222 });
223
224 // Similarly, expand the 'button.__proto__', 'buttonAsProto.__proto__' and
225 // 'document.__proto__' variables view nodes.
226 buttonProtoVar.expand();
227 buttonAsProtoProtoVar.expand();
228 documentProtoVar.expand();
229
230 is(buttonProtoVar.expanded, true,
231 "The buttonProtoVar should be immediately marked as expanded.");
232 is(buttonAsProtoProtoVar.expanded, true,
233 "The buttonAsProtoProtoVar should be immediately marked as expanded.");
234 is(documentProtoVar.expanded, true,
235 "The documentProtoVar should be immediately marked as expanded.");
236 });
237
238 // Expand the 'button', 'buttonAsProto' and 'document' variables view nodes.
239 // This causes their properties to be retrieved and displayed.
240 buttonVar.expand();
241 buttonAsProtoVar.expand();
242 documentVar.expand();
243
244 is(buttonVar.expanded, true,
245 "The buttonVar should be immediately marked as expanded.");
246 is(buttonAsProtoVar.expanded, true,
247 "The buttonAsProtoVar should be immediately marked as expanded.");
248 is(documentVar.expanded, true,
249 "The documentVar should be immediately marked as expanded.");
250
251 return deferred.promise;
252 }
253
254 registerCleanupFunction(function() {
255 gTab = null;
256 gDebuggee = null;
257 gPanel = null;
258 gDebugger = null;
259 gVariables = null;
260 });

mercurial