Web Inspector: Refactor InspectorTest to create output interface
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 18:25:39 +0000 (18:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 18:25:39 +0000 (18:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106231

Patch by John J. Barton <johnjbarton@chromium.org> on 2013-01-10
Reviewed by Pavel Feldman.

Refactor InspectorTest to extract InspectorTest.Output, the API
used between InspectorTest and the test output reciever (the
test-script page by default).

* http/tests/inspector/inspector-test.js:
(initialize_InspectorTest.InspectorTest.Output.testComplete):
(initialize_InspectorTest.InspectorTest.Output.addResult):
(initialize_InspectorTest.InspectorTest.Output.clearResults):
(initialize_InspectorTest.InspectorTest.completeTest):
(initialize_InspectorTest.InspectorTest.addResult):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/inspector-test.js

index 76b0c8f..68e06f2 100644 (file)
@@ -1,3 +1,21 @@
+2013-01-10  John J. Barton  <johnjbarton@chromium.org>
+
+        Web Inspector: Refactor InspectorTest to create output interface
+        https://bugs.webkit.org/show_bug.cgi?id=106231
+
+        Reviewed by Pavel Feldman.
+
+        Refactor InspectorTest to extract InspectorTest.Output, the API 
+        used between InspectorTest and the test output reciever (the 
+        test-script page by default).
+
+        * http/tests/inspector/inspector-test.js:
+        (initialize_InspectorTest.InspectorTest.Output.testComplete):
+        (initialize_InspectorTest.InspectorTest.Output.addResult):
+        (initialize_InspectorTest.InspectorTest.Output.clearResults):
+        (initialize_InspectorTest.InspectorTest.completeTest):
+        (initialize_InspectorTest.InspectorTest.addResult):
+
 2013-01-10  Max Vujovic  <mvujovic@adobe.com>
 
         [CSS Filters] RenderLayerCompositor::addToOverlapMap should take into account the filters outsets (ie. blur and drop-shadow)
index 6987b92..39f513c 100644 (file)
@@ -12,6 +12,23 @@ console.log = consoleOutputHook.bind(InspectorTest, "log");
 console.error = consoleOutputHook.bind(InspectorTest, "error");
 console.info = consoleOutputHook.bind(InspectorTest, "info");
 
+InspectorTest.Output = {   // override in window.initialize_yourName
+    testComplete: function() 
+    {
+        RuntimeAgent.evaluate("didEvaluateForTestInFrontend(" + InspectorTest.completeTestCallId + ", \"\")", "test");
+    },
+
+    addResult: function(text) 
+    {
+        InspectorTest.evaluateInPage("output(unescape('" + escape(text) + "'))");
+    },
+    
+    clearResults: function() 
+    {
+        InspectorTest.evaluateInPage("clearOutput()");
+    }
+};
+
 InspectorTest.completeTest = function()
 {
     function testDispatchQueueIsEmpty() {
@@ -20,7 +37,7 @@ InspectorTest.completeTest = function()
             setTimeout(testDispatchQueueIsEmpty, 10);
             return;
         }
-        RuntimeAgent.evaluate("didEvaluateForTestInFrontend(" + InspectorTest.completeTestCallId + ", \"\")", "test");
+        InspectorTest.Output.testComplete();
     }
     testDispatchQueueIsEmpty();
 }
@@ -73,23 +90,13 @@ InspectorTest.addResult = function(text)
 {
     results.push(text);
     if (resultsSynchronized)
-        addResultToPage(text);
+        InspectorTest.Output.addResult(text);
     else {
-        clearResults();
+        InspectorTest.Output.clearResults();
         for (var i = 0; i < results.length; ++i)
-            addResultToPage(results[i]);
+            InspectorTest.Output.addResult(results[i]);
         resultsSynchronized = true;
     }
-
-    function clearResults()
-    {
-        InspectorTest.evaluateInPage("clearOutput()");
-    }
-
-    function addResultToPage(text)
-    {
-        InspectorTest.evaluateInPage("output(unescape('" + escape(text) + "'))");
-    }
 }
 
 InspectorTest.addResults = function(textArray)