1 function initialize_AuditTests()
4 InspectorTest
.preloadPanel("audits");
6 InspectorTest
.collectAuditResults = function(callback
)
8 WebInspector
.panels
.audits
.showResults(WebInspector
.panels
.audits
.auditResultsTreeElement
.firstChild().results
);
9 var trees
= WebInspector
.panels
.audits
.visibleView
.element
.querySelectorAll(".audit-result-tree");
10 for (var i
= 0; i
< trees
.length
; ++i
) {
11 var liElements
= trees
[i
].shadowRoot
.querySelectorAll("li");
12 for (var j
= 0; j
< liElements
.length
; ++j
) {
13 if (liElements
[j
].treeElement
)
14 liElements
[j
].treeElement
.expand();
17 InspectorTest
.runAfterPendingDispatches(function() {
18 InspectorTest
.collectTextContent(WebInspector
.panels
.audits
.visibleView
.element
, "");
23 InspectorTest
.launchAllAudits = function(shouldReload
, callback
)
25 InspectorTest
.addSniffer(WebInspector
.AuditController
.prototype, "_auditFinishedCallback", callback
);
26 var launcherView
= WebInspector
.panels
.audits
._launcherView
;
27 launcherView
._selectAllClicked(true);
28 launcherView
._auditPresentStateElement
.checked
= !shouldReload
;
29 launcherView
._launchButtonClicked();
32 InspectorTest
.collectTextContent = function(element
, indent
)
35 var child
= element
.shadowRoot
|| element
.firstChild
;
37 var nonTextTags
= { "STYLE": 1, "SCRIPT": 1 };
39 if (child
.nodeName
=== "CONTENT") {
40 InspectorTest
.collectTextContent(child
.getDistributedNodes()[0], indent
);
41 } else if (child
.nodeType
=== Node
.TEXT_NODE
) {
42 if (!nonTextTags
[child
.parentElement
.nodeName
])
43 nodeOutput
+= child
.nodeValue
.replace("\u200B", "");
44 } else if (child
.nodeType
=== Node
.ELEMENT_NODE
|| child
.nodeType
=== Node
.DOCUMENT_FRAGMENT_NODE
) {
45 if (nodeOutput
!== "") {
46 InspectorTest
.addResult(indent
+ nodeOutput
);
49 if (!child
.firstChild
&& child
.className
.indexOf("severity") == 0)
50 nodeOutput
= "[" + child
.className
+ "] ";
52 InspectorTest
.collectTextContent(child
, indent
+ " ");
54 child
= child
.nextSibling
;
56 if (nodeOutput
!== "")
57 InspectorTest
.addResult(indent
+ nodeOutput
);