2011-01-26 Martin Robinson <mrobinson@igalia.com>
[WebKit-https.git] / LayoutTests / inspector / audits-panel-functional.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <style>
5 .unused {
6     color: green;
7 }
8 </style>
9 <script src="../http/tests/inspector/inspector-test.js"></script>
10 <script src="audits-tests.js"></script>
11
12 <!-- These scripts are needed to result in a violation of the max JS resource count from the same domain -->
13 <script src="resources/audits-script1.js"></script>
14 <link rel="stylesheet" href="resources/audits-style1.css" type="text/css">
15 <script src="resources/audits-script2.js"></script>
16 <script>
17
18 function doit()
19 {
20     function callback(result)
21     {
22         if (result === "refreshing")
23             return;
24         var output = document.getElementById("outputPre");
25         output.textContent = result;
26         notifyDone();
27     }
28     evaluateInWebInspector("frontend_runAudits", callback);
29 }
30
31
32 // Frontend functions.
33
34 function frontend_runAudits(testController)
35 {
36     if (!WebInspector.panels.network._pageWasReloaded) {
37         WebInspector.panels.network._pageWasReloaded = true;
38         WebInspector.panels.network._reset();
39         InspectorBackend.reloadPage();
40         return "refreshing";
41     }
42
43     testController.waitUntilDone();
44     WebInspector.AuditRuleResult.resourceDomain = function() {
45         return "[domain]";
46     };
47     try {
48         const launcherView = WebInspector.panels.audits._launcherView;
49         launcherView._selectAllClicked(true);
50         launcherView._auditPresentStateElement.checked = true;
51         launcherView._launchButtonClicked();
52
53         testController.runAfterPendingDispatches(function() {
54             // Audits are done, check results.
55             var output = frontend_collectAuditResults();
56             // Avoid influencing tests that require resource tracking to be disabled.
57             testController.notifyDone(output.join("\n"));
58         });
59     } catch(e) {
60         testController.notifyDone("Exception: " + e.toString());
61     }
62 }
63
64 </script>
65 </head>
66
67 <body onload="onload()">
68 Tests audit rules.
69
70 <style>
71 .violation { color: red; }
72 </style>
73 <link rel="stylesheet" href="resources/audits-style1.css" type="text/css">
74 <img src="foo1.jpg">
75 <img src="foo2.jpg" width=100>
76 <img src="foo3.jpg" style="position: absolute">
77
78 <pre id="outputPre">
79 </pre>
80
81 </body>
82 </html>