Web Inspector: add TestPage.debug() to inspect evaluations being sent to Inspector...
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 20:38:05 +0000 (20:38 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 20:38:05 +0000 (20:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181005

Rubber-stamped 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):

* http/tests/inspector/network/har/har-page-expected.txt:
Rebaseline, as this depends on the size of inspector-test.js. Removing this
fragile test expectation behavior is tracked by https://bugs.webkit.org/show_bug.cgi?id=181300.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/har/har-page-expected.txt
LayoutTests/http/tests/inspector/resources/inspector-test.js

index 8f35211..3cd4c44 100644 (file)
@@ -1,3 +1,24 @@
+2018-01-04  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
+
+        Rubber-stamped 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):
+
+        * http/tests/inspector/network/har/har-page-expected.txt:
+        Rebaseline, as this depends on the size of inspector-test.js. Removing this
+        fragile test expectation behavior is tracked by https://bugs.webkit.org/show_bug.cgi?id=181300.
+
+
 2018-01-04  Zalan Bujtas  <zalan@apple.com>
 
         WebContent process crashes while loading https://www.classicspecs.com
index 4225b3c..4e164ea 100644 (file)
@@ -87,7 +87,7 @@ HAR Page Test.
             "size": 0,
             "compression": 0,
             "mimeType": "application/x-javascript",
-            "text": "<filtered text (6707)>"
+            "text": "<filtered text (7039)>"
           },
           "redirectURL": "",
           "headersSize": "<filtered>",
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;