Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: LayoutTests/http/tests/inspector/elements-test.js

Issue 268293003: DevTools: Get rid of WebInspector.panels (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 var initialize_ElementTest = function() { 1 var initialize_ElementTest = function() {
2 2
3 InspectorTest.findNode = function(matchFunction, callback) 3 InspectorTest.findNode = function(matchFunction, callback)
4 { 4 {
5 callback = InspectorTest.safeWrap(callback); 5 callback = InspectorTest.safeWrap(callback);
6 var result = null; 6 var result = null;
7 var pendingRequests = 0; 7 var pendingRequests = 0;
8 function processChildren(node) 8 function processChildren(node)
9 { 9 {
10 try { 10 try {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 } 158 }
159 159
160 InspectorTest.selectNodeAndWaitForStylesWithComputed = function(idValue, callbac k) 160 InspectorTest.selectNodeAndWaitForStylesWithComputed = function(idValue, callbac k)
161 { 161 {
162 callback = InspectorTest.safeWrap(callback); 162 callback = InspectorTest.safeWrap(callback);
163 163
164 function stylesCallback(targetNode) 164 function stylesCallback(targetNode)
165 { 165 {
166 InspectorTest.addSniffer(WebInspector.ComputedStyleSidebarPane.prototype , "onContentReady", callback); 166 InspectorTest.addSniffer(WebInspector.ComputedStyleSidebarPane.prototype , "onContentReady", callback);
167 WebInspector.panels.elements.sidebarPanes.computedStyle.expand(); 167 WebInspector.inspectorView.panel("elements").sidebarPanes.computedStyle. expand();
168 } 168 }
169 169
170 InspectorTest.selectNodeAndWaitForStyles(idValue, stylesCallback); 170 InspectorTest.selectNodeAndWaitForStyles(idValue, stylesCallback);
171 } 171 }
172 172
173 InspectorTest.firstElementsTreeOutline = function() 173 InspectorTest.firstElementsTreeOutline = function()
174 { 174 {
175 return WebInspector.panels.elements._treeOutlines[0]; 175 return WebInspector.inspectorView.panel("elements")._treeOutlines[0];
176 } 176 }
177 177
178 InspectorTest.dumpSelectedElementStyles = function(excludeComputed, excludeMatch ed, omitLonghands, includeSelectorGroupMarks) 178 InspectorTest.dumpSelectedElementStyles = function(excludeComputed, excludeMatch ed, omitLonghands, includeSelectorGroupMarks)
179 { 179 {
180 function extractText(element) 180 function extractText(element)
181 { 181 {
182 var text = element.textContent; 182 var text = element.textContent;
183 if (text) 183 if (text)
184 return text; 184 return text;
185 var anchor = element.querySelector("[data-uncopyable]"); 185 var anchor = element.querySelector("[data-uncopyable]");
(...skipping 10 matching lines...) Expand all
196 var result = ""; 196 var result = "";
197 for (var node = element.firstChild; node; node = node.nextSibling) { 197 for (var node = element.firstChild; node; node = node.nextSibling) {
198 if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains(" selector-matches")) 198 if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains(" selector-matches"))
199 result += "[$" + node.textContent + "$]"; 199 result += "[$" + node.textContent + "$]";
200 else 200 else
201 result += node.textContent; 201 result += node.textContent;
202 } 202 }
203 return result; 203 return result;
204 } 204 }
205 205
206 var styleSections = WebInspector.panels.elements.sidebarPanes.styles.section s; 206 var styleSections = WebInspector.inspectorView.panel("elements").sidebarPane s.styles.sections;
207 for (var pseudoId in styleSections) { 207 for (var pseudoId in styleSections) {
208 var pseudoName = WebInspector.StylesSidebarPane.PseudoIdNames[pseudoId]; 208 var pseudoName = WebInspector.StylesSidebarPane.PseudoIdNames[pseudoId];
209 var sections = styleSections[pseudoId]; 209 var sections = styleSections[pseudoId];
210 for (var i = 0; i < sections.length; ++i) { 210 for (var i = 0; i < sections.length; ++i) {
211 var section = sections[i]; 211 var section = sections[i];
212 if (section.computedStyle && excludeComputed) 212 if (section.computedStyle && excludeComputed)
213 continue; 213 continue;
214 if (section.rule && excludeMatched) 214 if (section.rule && excludeMatched)
215 continue; 215 continue;
216 if (section.element && section.element.classList.contains("user-rule ") && !WebInspector.settings.showUserAgentStyles.get()) 216 if (section.element && section.element.classList.contains("user-rule ") && !WebInspector.settings.showUserAgentStyles.get())
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 InspectorTest.expandAndDumpSelectedElementEventListeners = function(callback) 254 InspectorTest.expandAndDumpSelectedElementEventListeners = function(callback)
255 { 255 {
256 InspectorTest.expandSelectedElementEventListeners(function() { 256 InspectorTest.expandSelectedElementEventListeners(function() {
257 InspectorTest.dumpSelectedElementEventListeners(callback); 257 InspectorTest.dumpSelectedElementEventListeners(callback);
258 }); 258 });
259 } 259 }
260 260
261 InspectorTest.expandSelectedElementEventListeners = function(callback) 261 InspectorTest.expandSelectedElementEventListeners = function(callback)
262 { 262 {
263 var sidebarPane = WebInspector.panels.elements.sidebarPanes.eventListeners; 263 var sidebarPane = WebInspector.inspectorView.panel("elements").sidebarPanes. eventListeners;
264 sidebarPane.expand(); 264 sidebarPane.expand();
265 265
266 InspectorTest.runAfterPendingDispatches(function() { 266 InspectorTest.runAfterPendingDispatches(function() {
267 InspectorTest.expandSelectedElementEventListenersSubsections(callback); 267 InspectorTest.expandSelectedElementEventListenersSubsections(callback);
268 }); 268 });
269 } 269 }
270 270
271 InspectorTest.expandSelectedElementEventListenersSubsections = function(callback ) 271 InspectorTest.expandSelectedElementEventListenersSubsections = function(callback )
272 { 272 {
273 var eventListenerSections = WebInspector.panels.elements.sidebarPanes.eventL isteners.sections; 273 var eventListenerSections = WebInspector.inspectorView.panel("elements").sid ebarPanes.eventListeners.sections;
274 for (var i = 0; i < eventListenerSections.length; ++i) 274 for (var i = 0; i < eventListenerSections.length; ++i)
275 eventListenerSections[i].expand(); 275 eventListenerSections[i].expand();
276 276
277 // Multiple sections may expand. 277 // Multiple sections may expand.
278 InspectorTest.runAfterPendingDispatches(function() { 278 InspectorTest.runAfterPendingDispatches(function() {
279 InspectorTest.expandSelectedElementEventListenersEventBars(callback); 279 InspectorTest.expandSelectedElementEventListenersEventBars(callback);
280 }); 280 });
281 } 281 }
282 282
283 InspectorTest.expandSelectedElementEventListenersEventBars = function(callback) 283 InspectorTest.expandSelectedElementEventListenersEventBars = function(callback)
284 { 284 {
285 var eventListenerSections = WebInspector.panels.elements.sidebarPanes.eventL isteners.sections; 285 var eventListenerSections = WebInspector.inspectorView.panel("elements").sid ebarPanes.eventListeners.sections;
286 for (var i = 0; i < eventListenerSections.length; ++i) { 286 for (var i = 0; i < eventListenerSections.length; ++i) {
287 var eventBarChildren = eventListenerSections[i]._eventBars.children; 287 var eventBarChildren = eventListenerSections[i]._eventBars.children;
288 for (var j = 0; j < eventBarChildren.length; ++j) 288 for (var j = 0; j < eventBarChildren.length; ++j)
289 eventBarChildren[j]._section.expand(); 289 eventBarChildren[j]._section.expand();
290 } 290 }
291 291
292 // Multiple sections may expand. 292 // Multiple sections may expand.
293 InspectorTest.runAfterPendingDispatches(callback); 293 InspectorTest.runAfterPendingDispatches(callback);
294 } 294 }
295 295
296 InspectorTest.dumpSelectedElementEventListeners = function(callback) 296 InspectorTest.dumpSelectedElementEventListeners = function(callback)
297 { 297 {
298 function formatSourceNameProperty(value) 298 function formatSourceNameProperty(value)
299 { 299 {
300 return "[clipped-for-test]/" + value.replace(/(.*?\/)LayoutTests/, "Layo utTests"); 300 return "[clipped-for-test]/" + value.replace(/(.*?\/)LayoutTests/, "Layo utTests");
301 } 301 }
302 302
303 var eventListenerSections = WebInspector.panels.elements.sidebarPanes.eventL isteners.sections; 303 var eventListenerSections = WebInspector.inspectorView.panel("elements").sid ebarPanes.eventListeners.sections;
304 for (var i = 0; i < eventListenerSections.length; ++i) { 304 for (var i = 0; i < eventListenerSections.length; ++i) {
305 var section = eventListenerSections[i]; 305 var section = eventListenerSections[i];
306 var eventType = section._title; 306 var eventType = section._title;
307 InspectorTest.addResult(""); 307 InspectorTest.addResult("");
308 InspectorTest.addResult("======== " + eventType + " ========"); 308 InspectorTest.addResult("======== " + eventType + " ========");
309 var eventBarChildren = section._eventBars.children; 309 var eventBarChildren = section._eventBars.children;
310 for (var j = 0; j < eventBarChildren.length; ++j) { 310 for (var j = 0; j < eventBarChildren.length; ++j) {
311 var objectPropertiesSection = eventBarChildren[j]._section; 311 var objectPropertiesSection = eventBarChildren[j]._section;
312 InspectorTest.dumpObjectPropertySection(objectPropertiesSection, { 312 InspectorTest.dumpObjectPropertySection(objectPropertiesSection, {
313 sourceName: formatSourceNameProperty 313 sourceName: formatSourceNameProperty
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 354
355 var childNodes = section.propertiesTreeOutline.children; 355 var childNodes = section.propertiesTreeOutline.children;
356 for (var i = 0; i < childNodes.length; i++) { 356 for (var i = 0; i < childNodes.length; i++) {
357 dumpTreeElementRecursively(childNodes[i], ""); 357 dumpTreeElementRecursively(childNodes[i], "");
358 } 358 }
359 } 359 }
360 360
361 // FIXME: this returns the first tree item found (may fail for same-named proper ties in a style). 361 // FIXME: this returns the first tree item found (may fail for same-named proper ties in a style).
362 InspectorTest.getElementStylePropertyTreeItem = function(propertyName) 362 InspectorTest.getElementStylePropertyTreeItem = function(propertyName)
363 { 363 {
364 var styleSections = WebInspector.panels.elements.sidebarPanes.styles.section s[0]; 364 var styleSections = WebInspector.inspectorView.panel("elements").sidebarPane s.styles.sections[0];
365 var elementStyleSection = styleSections[1]; 365 var elementStyleSection = styleSections[1];
366 return InspectorTest.getFirstPropertyTreeItemForSection(elementStyleSection, propertyName); 366 return InspectorTest.getFirstPropertyTreeItemForSection(elementStyleSection, propertyName);
367 }; 367 };
368 368
369 // FIXME: this returns the first tree item found (may fail for same-named proper ties in a style). 369 // FIXME: this returns the first tree item found (may fail for same-named proper ties in a style).
370 InspectorTest.getMatchedStylePropertyTreeItem = function(propertyName) 370 InspectorTest.getMatchedStylePropertyTreeItem = function(propertyName)
371 { 371 {
372 var styleSections = WebInspector.panels.elements.sidebarPanes.styles.section s[0]; 372 var styleSections = WebInspector.inspectorView.panel("elements").sidebarPane s.styles.sections[0];
373 for (var i = 1; i < styleSections.length; ++i) { 373 for (var i = 1; i < styleSections.length; ++i) {
374 var treeItem = InspectorTest.getFirstPropertyTreeItemForSection(styleSec tions[i], propertyName); 374 var treeItem = InspectorTest.getFirstPropertyTreeItemForSection(styleSec tions[i], propertyName);
375 if (treeItem) 375 if (treeItem)
376 return treeItem; 376 return treeItem;
377 } 377 }
378 return null; 378 return null;
379 }; 379 };
380 380
381 InspectorTest.getFirstPropertyTreeItemForSection = function(section, propertyNam e) 381 InspectorTest.getFirstPropertyTreeItemForSection = function(section, propertyNam e)
382 { 382 {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 var selectors = []; 721 var selectors = [];
722 for (var i = 0; i < rule.matchingSelectors.length; ++i) 722 for (var i = 0; i < rule.matchingSelectors.length; ++i)
723 selectors.push(rule.selectors[rule.matchingSelectors[i]].value); 723 selectors.push(rule.selectors[rule.matchingSelectors[i]].value);
724 return "[" + selectors.join(", ") + "]"; 724 return "[" + selectors.join(", ") + "]";
725 } 725 }
726 726
727 InspectorTest.addNewRule = function(selector, callback) 727 InspectorTest.addNewRule = function(selector, callback)
728 { 728 {
729 // Click "Add new rule". 729 // Click "Add new rule".
730 document.getElementById("add-style-button-test-id").click(); 730 document.getElementById("add-style-button-test-id").click();
731 var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2 ]; 731 var section = WebInspector.inspectorView.panel("elements").sidebarPanes.styl es.sections[0][2];
732 if (typeof selector === "string") 732 if (typeof selector === "string")
733 section._selectorElement.textContent = selector; 733 section._selectorElement.textContent = selector;
734 section._selectorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter") ); 734 section._selectorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter") );
735 InspectorTest.addSniffer(WebInspector.BlankStylePropertiesSection.prototype, "makeNormal", callback); 735 InspectorTest.addSniffer(WebInspector.BlankStylePropertiesSection.prototype, "makeNormal", callback);
736 } 736 }
737 737
738 InspectorTest.dumpInspectorHighlight = function(node, callback) 738 InspectorTest.dumpInspectorHighlight = function(node, callback)
739 { 739 {
740 node.boxModel(function(boxModel) { 740 node.boxModel(function(boxModel) {
741 var rectNames = ["margin", "border", "padding", "content"]; 741 var rectNames = ["margin", "border", "padding", "content"];
742 for (var i = 0; i < rectNames.length; i++) { 742 for (var i = 0; i < rectNames.length; i++) {
743 var rect = boxModel[rectNames[i]]; 743 var rect = boxModel[rectNames[i]];
744 InspectorTest.addResult(rectNames[i] + " rect is " + (rect[4] - rect [0]) + " x " + (rect[5] - rect[1]) + " at (" + rect[0] + ", " + rect[1] + ")"); 744 InspectorTest.addResult(rectNames[i] + " rect is " + (rect[4] - rect [0]) + " x " + (rect[5] - rect[1]) + " at (" + rect[0] + ", " + rect[1] + ")");
745 } 745 }
746 callback(); 746 callback();
747 }); 747 });
748 } 748 }
749 749
750 InspectorTest.dumpInspectorHighlightShape = function(node, callback) 750 InspectorTest.dumpInspectorHighlightShape = function(node, callback)
751 { 751 {
752 node.boxModel(function(shapes) { 752 node.boxModel(function(shapes) {
753 InspectorTest.addResult(JSON.stringify(shapes.shapeOutside.shape)); 753 InspectorTest.addResult(JSON.stringify(shapes.shapeOutside.shape));
754 callback(); 754 callback();
755 }); 755 });
756 } 756 }
757 757
758 }; 758 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698