b0af8fcf77fcb0f39f4f22d1ed8bb3491445e63a
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / audits / audits-test.js
1 function initialize_AuditTests()
2 {
3
4 InspectorTest.collectAuditResults = function()
5 {
6     WebInspector.panels.audits.showResults(WebInspector.panels.audits.auditResultsTreeElement.children[0].results);
7     var liElements = WebInspector.panels.audits.visibleView.element.getElementsByTagName("li");
8     for (var j = 0; j < liElements.length; ++j) {
9         if (liElements[j].treeElement)
10             liElements[j].treeElement.expand();
11     }
12     InspectorTest.collectTextContent(WebInspector.panels.audits.visibleView.element, "");
13 }
14
15 InspectorTest.launchAllAudits = function(shouldReload, callback)
16 {
17     var launcherView = WebInspector.panels.audits._launcherView;
18     launcherView._selectAllClicked(true);
19     launcherView._auditPresentStateElement.checked = !shouldReload;
20     launcherView._launchButtonClicked();
21     InspectorTest.runAfterPendingDispatches(callback);
22 }
23
24 InspectorTest.collectTextContent = function(element, indent)
25 {
26     var nodeOutput = "";
27     var child = element.firstChild;
28
29     while (child) {
30         if (child.nodeType === Node.TEXT_NODE) {
31             nodeOutput += child.nodeValue.replace("\u200B", "");
32         } else if (child.nodeType === Node.ELEMENT_NODE) {
33             if (nodeOutput !== "") {
34                 InspectorTest.addResult(indent + nodeOutput);
35                 nodeOutput = "";
36             }
37             if (!child.firstChild && child.className.indexOf("severity") == 0)
38                 nodeOutput = "[" + child.className + "] ";
39             else
40                 InspectorTest.collectTextContent(child, indent + " ");
41         }
42         child = child.nextSibling;
43     }
44     if (nodeOutput !== "")
45         InspectorTest.addResult(indent + nodeOutput);
46 }
47
48 }