3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/extensions-test.js"></script>
5 <script src=
"../audits/audits-test.js"></script>
6 <script src=
"extensions-audits-tests.js"></script>
8 <script type=
"text/javascript">
10 function extension_testAudits(nextTest
)
12 var pendingOutput
= [];
14 function onStartAuditCategory(results
)
16 pendingOutput
.push("category.onAuditStarted fired");
17 results
.addResult("Passed rule", "this rule always passes ok", results
.Severity
.Info
);
18 results
.addResult("Failed rule (42)", "this rule always fails", results
.Severity
.Severe
);
20 var node
= results
.createResult("Subtree");
21 node
.addChild("Some url: ", results
.createURL("http://www.webkit.org", "WebKit"), " more text ", results
.createURL("http://www.google.com"));
22 var nestedNode
= node
.addChild("... and a snippet");
23 nestedNode
.expanded
= true;
24 nestedNode
.addChild(results
.createSnippet("function rand()\n{\n return 4;\n}"));
25 nestedNode
.addChild(results
.createResourceLink("file:///path/to/error.html", 10));
26 nestedNode
.addChild(results
.createObject("({a: 42, b: 'foo'})", "object details"));
27 nestedNode
.addChild(results
.createNode("document.getElementById('test-element')"));
29 webInspector
.inspectedWindow
.eval("location.href", function(inspectedPageURL
) {
30 nestedNode
.addChild(results
.createResourceLink(inspectedPageURL
, 20));
32 evaluateOnFrontend("InspectorTest.dumpAuditProgress(); reply();", function() {
33 results
.addResult("Rule with details subtree (1)", "This rule has a lot of details", results
.Severity
.Warning
, node
);
34 results
.updateProgress(10, 20);
35 evaluateOnFrontend("InspectorTest.dumpAuditProgress(); reply();", results
.done
.bind(results
));
39 function onStartAuditFailedCategory()
41 pendingOutput
.push("failedCategory.onAuditStarted fired, throwing exception");
44 function onStartAuditDisabledCategory(results
)
46 pendingOutput
.push("FAIL: disabledCategory.onAuditStarted fired");
49 var category
= webInspector
.audits
.addCategory("Extension audits");
50 category
.onAuditStarted
.addListener(onStartAuditCategory
);
52 var failedCategory
= webInspector
.audits
.addCategory("Extension audits that fail", 2);
53 failedCategory
.onAuditStarted
.addListener(onStartAuditFailedCategory
);
55 var disabledCategory
= webInspector
.audits
.addCategory("Disabled extension audits", 2);
56 disabledCategory
.onAuditStarted
.addListener(onStartAuditDisabledCategory
);
60 pendingOutput
.sort().forEach(output
);
63 extension_runAudits(auditsDone
);
68 <body onload=
"runTest()">
69 <p>Tests audits support in WebInspector Extensions API
</p>
70 <span id=
"test-element"><b></b></span>