Web Inspector: add TestPage.debug() to inspect evaluations being sent to Inspector...
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Dec 2017 00:06:43 +0000 (00:06 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Dec 2017 00:06:43 +0000 (00:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181005

Reviewed by Joseph Pecoraro.

When TestPage.debug() is called, dump out all code that is sent to be evaluated in
the inspector page. This is useful for debugging initialization and InspectorTest.awaitEvent.

* http/tests/inspector/resources/inspector-test.js:
(runTest):
(TestPage.debug):
(TestPage.evaluateInWebInspector):
(TestPage.dispatchEventToFrontend):

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

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

index 8ea6838..f952849 100644 (file)
@@ -1,3 +1,19 @@
+2017-12-19  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: add TestPage.debug() to inspect evaluations being sent to Inspector page
+        https://bugs.webkit.org/show_bug.cgi?id=181005
+
+        Reviewed by Joseph Pecoraro.
+
+        When TestPage.debug() is called, dump out all code that is sent to be evaluated in
+        the inspector page. This is useful for debugging initialization and InspectorTest.awaitEvent.
+
+        * http/tests/inspector/resources/inspector-test.js:
+        (runTest):
+        (TestPage.debug):
+        (TestPage.evaluateInWebInspector):
+        (TestPage.dispatchEventToFrontend):
+
 2017-12-19  Youenn Fablet  <youenn@apple.com>
 
         Layout Test imported/w3c/web-platform-tests/service-workers/service-worker/getregistrations.https.html is flaky
index 4b682cd..5965120 100644 (file)
@@ -97,8 +97,8 @@ function runTest()
     let initializationCodeString = `(${runInitializationMethodsInFrontend.toString()})([${TestPage._initializers}]);`;
     let testFunctionCodeString = `(${runTestMethodInFrontend.toString()})(${testFunction.toString()});`;
 
-    testRunner.evaluateInWebInspector(initializationCodeString);
-    testRunner.evaluateInWebInspector(testFunctionCodeString);
+    TestPage.evaluateInWebInspector(initializationCodeString);
+    TestPage.evaluateInWebInspector(testFunctionCodeString);
 }
 
 function runTestHTTPS()
@@ -139,6 +139,20 @@ TestPage.debugLog = function(message)
     window.alert(message);
 }
 
+// Use this to dump evaluations that are sent from the TestPage to the InspectorTest page.
+TestPage.debug = function()
+{
+    this.dumpInspectorPageEvaluations = true;
+}
+
+TestPage.evaluateInWebInspector = function(code)
+{
+    if (this.dumpInspectorPageEvaluations)
+        this.debugLog(code);
+
+    testRunner.evaluateInWebInspector(code);
+}
+
 // Add and clear test output from the results window.
 TestPage.addResult = function(text)
 {
@@ -162,7 +176,7 @@ TestPage.log = TestPage.addResult;
 TestPage.dispatchEventToFrontend = function(eventName, data)
 {
     let dispatchEventCodeString = `InspectorTest.dispatchEventToListeners(${JSON.stringify(eventName)}, ${JSON.stringify(data)});`;
-    testRunner.evaluateInWebInspector(dispatchEventCodeString);
+    this.evaluateInWebInspector(dispatchEventCodeString);
 };
 
 TestPage.allowUncaughtExceptions = false;