2011-02-07 Pavel Feldman <pfeldman@chromium.org>
[WebKit-https.git] / LayoutTests / inspector / audits-panel-functional.html
index 17f5c61..807bef6 100644 (file)
@@ -6,67 +6,44 @@
     color: green;
 }
 </style>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="audits-tests.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script src="audits-tests2.js"></script>
 
 <!-- These scripts are needed to result in a violation of the max JS resource count from the same domain -->
 <script src="resources/audits-script1.js"></script>
 <link rel="stylesheet" href="resources/audits-style1.css" type="text/css">
 <script src="resources/audits-script2.js"></script>
 <script>
-
-function doit()
+var test = function()
 {
-    function callback(result)
-    {
-        if (result === "refreshing")
-            return;
-        var output = document.getElementById("outputPre");
-        output.textContent = result;
-        notifyDone();
-    }
-    evaluateInWebInspector("frontend_runAudits", callback);
-}
+    InspectorTest.reloadPage(step1);
 
+    function step1()
+    {
+        WebInspector.AuditRuleResult.resourceDomain = function() {
+            return "[domain]";
+        };
 
-// Frontend functions.
-
-function frontend_runAudits(testController)
-{
-    if (!WebInspector.panels.network._pageWasReloaded) {
-        WebInspector.panels.network._pageWasReloaded = true;
-        WebInspector.panels.network._reset();
-        InspectorBackend.reloadPage();
-        return "refreshing";
-    }
-
-    testController.waitUntilDone();
-    WebInspector.AuditRuleResult.resourceDomain = function() {
-        return "[domain]";
-    };
-    try {
-        const launcherView = WebInspector.panels.audits._launcherView;
+        var launcherView = WebInspector.panels.audits._launcherView;
         launcherView._selectAllClicked(true);
         launcherView._auditPresentStateElement.checked = true;
         launcherView._launchButtonClicked();
 
-        testController.runAfterPendingDispatches(function() {
-            // Audits are done, check results.
-            var output = frontend_collectAuditResults();
-            // Avoid influencing tests that require resource tracking to be disabled.
-            testController.notifyDone(output.join("\n"));
-        });
-    } catch(e) {
-        testController.notifyDone("Exception: " + e.toString());
+        InspectorTest.runAfterPendingDispatches(step2);
+    }    
+
+    function step2()
+    {
+        InspectorTest.collectAuditResults();
+        InspectorTest.completeTest();
     }
 }
-
+</script>
 </script>
 </head>
 
-<body onload="onload()">
+<body onload="runTest()">
 Tests audit rules.
-
 <style>
 .violation { color: red; }
 </style>
@@ -75,8 +52,5 @@ Tests audit rules.
 <img src="foo2.jpg" width=100>
 <img src="foo3.jpg" style="position: absolute">
 
-<pre id="outputPre">
-</pre>
-
 </body>
 </html>