Title: [189415] trunk
Revision
189415
Author
[email protected]
Date
2015-09-04 19:34:22 -0700 (Fri, 04 Sep 2015)

Log Message

Web Inspector: Test Runtime.saveResult and $n values
https://bugs.webkit.org/show_bug.cgi?id=148837

Patch by Joseph Pecoraro <[email protected]> on 2015-09-04
Reviewed by Timothy Hatcher.

Source/_javascript_Core:

* inspector/InjectedScriptSource.js:
(InjectedScript.prototype._evaluateOn):
We don't need to be in the console object group to put the value
in the saved results list. That strong reference will ensure $n
values are always alive even if other object groups were used
when creating and subsequently released.

Source/WebInspectorUI:

* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackendClass):
Initialize the dump logging function different if we are in tests or not.
When in tests, using console.log as well as dumping system activity to
the system console results in an infinite loop of logging!

(InspectorBackendClass.prototype.dispatch):
(InspectorBackendClass.prototype._sendCommandToBackendWithCallback):
Use the logging function we figured out earlier.

LayoutTests:

* inspector/runtime/parse.html: Remove unncessary debug flag.
* inspector/runtime/saveResult-expected.txt: Added.
* inspector/runtime/saveResult.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (189414 => 189415)


--- trunk/LayoutTests/ChangeLog	2015-09-05 02:30:48 UTC (rev 189414)
+++ trunk/LayoutTests/ChangeLog	2015-09-05 02:34:22 UTC (rev 189415)
@@ -1,3 +1,14 @@
+2015-09-04  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Test Runtime.saveResult and $n values
+        https://bugs.webkit.org/show_bug.cgi?id=148837
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/runtime/parse.html: Remove unncessary debug flag.
+        * inspector/runtime/saveResult-expected.txt: Added.
+        * inspector/runtime/saveResult.html: Added.
+
 2015-09-04  Chris Dumez  <[email protected]>
 
         Unreviewed, land baseline for one of the newly imported w3c tests.

Modified: trunk/LayoutTests/inspector/runtime/parse.html (189414 => 189415)


--- trunk/LayoutTests/inspector/runtime/parse.html	2015-09-05 02:30:48 UTC (rev 189414)
+++ trunk/LayoutTests/inspector/runtime/parse.html	2015-09-05 02:34:22 UTC (rev 189415)
@@ -5,8 +5,6 @@
 <script>
 function test()
 {
-    InspectorTest.dumpActivityToSystemConsole = true;
-
     function outputErrorSourceRange(range) {
         var str = " ".repeat("Source: ".length);
         str += " ".repeat(range.startOffset);

Added: trunk/LayoutTests/inspector/runtime/saveResult-expected.txt (0 => 189415)


--- trunk/LayoutTests/inspector/runtime/saveResult-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/saveResult-expected.txt	2015-09-05 02:34:22 UTC (rev 189415)
@@ -0,0 +1,36 @@
+Tests for the Runtime.saveResult command ($n values).
+
+
+== Running test suite: Runtime.saveResult
+-- Running test case: SavePrimitiveValue1
+PASS: Value 123 should become $1.
+
+-- Running test case: SavePrimitiveValue2
+PASS: Value true should become $2.
+
+-- Running test case: RepeatPrimitiveValue1
+PASS: Value 123 should have existed as $1.
+
+-- Running test case: $1MatchesValue1
+PASS: $1 value should be 123.
+
+-- Running test case: SaveObject1
+PASS: New Object {"x":100,"y":200} should become $3.
+
+-- Running test case: SaveObject2
+PASS: New Object {"x":100,"y":200} should become $4.
+
+-- Running test case: RepeatSaveObject1
+PASS: Repeat Object should have existed as $3.
+
+-- Running test case: NoContextWithPrimitiveShouldUseMainContext
+PASS: Value 999 should become $5.
+PASS: Value 999 should have existed as $5.
+
+-- Running test case: ClearConsoleShouldResetValues
+PASS: Value 999 should become $1.
+
+-- Running test case: EvaluateWithSaveIndex
+PASS: Evaluated result 990 should become $2.
+PASS: Evaluated result 999 should match previous value $1.
+

Added: trunk/LayoutTests/inspector/runtime/saveResult.html (0 => 189415)


--- trunk/LayoutTests/inspector/runtime/saveResult.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/saveResult.html	2015-09-05 02:34:22 UTC (rev 189415)
@@ -0,0 +1,181 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    function createCallArgumentWithValue(value) {
+        return {value};
+    }
+
+    function createCallArgumentWithRemoteObject(remoteObject) {
+        return {objectId: remoteObject.objectId};
+    }
+
+    function remoteObjectForSimpleObject(simpleObject, callback) {
+        InspectorTest.evaluateInPage("(" + JSON.stringify(simpleObject) + ")", callback);
+    }
+
+    let contextId = WebInspector.frameResourceManager.mainFrame.pageExecutionContext.id;
+    let remoteObject1;
+
+    let suite = InspectorTest.createAsyncSuite("Runtime.saveResult");
+
+    suite.addTestCase({
+        name: "SavePrimitiveValue1",
+        description: "Saving a new value should produce a new $n value.",
+        test: (resolve, reject) => {
+            let value = 123;
+            RuntimeAgent.saveResult(createCallArgumentWithValue(value), contextId, (error, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 1, `Value ${value} should become $1.`);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "SavePrimitiveValue2",
+        description: "Saving a new value should produce a new $n value.",
+        test: (resolve, reject) => {
+            let value = true;
+            RuntimeAgent.saveResult(createCallArgumentWithValue(value), contextId, (error, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 2, `Value ${value} should become $2.`);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "RepeatPrimitiveValue1",
+        description: "Saving a previously saved value should produce the original $n value.",
+        test: (resolve, reject) => {
+            let value = 123;
+            RuntimeAgent.saveResult(createCallArgumentWithValue(value), contextId, (error, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 1, `Value ${value} should have existed as $1.`);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "$1MatchesValue1",
+        description: "Evaluating $1 should get us the value we saved previously.",
+        test: (resolve, reject) => {
+            RuntimeAgent.evaluate.invoke({_expression_: "$1", objectGroup: "test", includeCommandLineAPI: true}, (error, remoteObjectPayload, wasThrown, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+                InspectorTest.assert(remoteObject.hasValue(), "RemoteObject for $1 should be a value, not an object.");
+                InspectorTest.expectThat(remoteObject.value === 123, "$1 value should be 123.");
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "SaveObject1",
+        description: "Saving a new object should produce a new $n value.",
+        test: (resolve, reject) => {
+            let object = {x:100, y:200};
+            remoteObjectForSimpleObject(object, (error, remoteObject) => {
+                remoteObject1 = remoteObject;
+                RuntimeAgent.saveResult(createCallArgumentWithRemoteObject(remoteObject), (error, savedResultIndex) => {
+                    InspectorTest.assert(!error, "Should not be a protocol error.");
+                    InspectorTest.expectThat(savedResultIndex === 3, `New Object ${JSON.stringify(object)} should become $3.`);
+                    resolve();
+                });
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "SaveObject2",
+        description: "Saving a new object should produce a new $n value.",
+        test: (resolve, reject) => {
+            let object = {x:100, y:200};
+            remoteObjectForSimpleObject(object, (error, remoteObject) => {
+                RuntimeAgent.saveResult(createCallArgumentWithRemoteObject(remoteObject), (error, savedResultIndex) => {
+                    InspectorTest.assert(!error, "Should not be a protocol error.");
+                    InspectorTest.expectThat(savedResultIndex === 4, `New Object ${JSON.stringify(object)} should become $4.`);
+                    resolve();
+                });
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "RepeatSaveObject1",
+        description: "Saving a previously saved value should produce the original $n value.",
+        test: (resolve, reject) => {
+            RuntimeAgent.saveResult(createCallArgumentWithRemoteObject(remoteObject1), (error, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 3, `Repeat Object should have existed as $3.`);
+                resolve();
+            });
+        }
+    });
+
+    // ------
+
+    suite.addTestCase({
+        name: "NoContextWithPrimitiveShouldUseMainContext",
+        description: "Saving a primitive should specify the context.",
+        test: (resolve, reject) => {
+            let value = 999;
+            RuntimeAgent.saveResult(createCallArgumentWithValue(value), (error, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 5, `Value ${value} should become $5.`);
+            });
+            RuntimeAgent.saveResult(createCallArgumentWithValue(value), contextId, (error, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 5, `Value ${value} should have existed as $5.`);
+                resolve();
+            });
+        }
+    });
+
+    // ------
+
+    suite.addTestCase({
+        name: "ClearConsoleShouldResetValues",
+        description: "Clearing the console should reset the $n values.",
+        test: (resolve, reject) => {
+            let value = 999;
+            ConsoleAgent.clearMessages();
+            RuntimeAgent.saveResult(createCallArgumentWithValue(value), (error, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 1, `Value ${value} should become $1.`);
+                resolve();
+            });
+        }
+    });
+
+    // ------
+
+    suite.addTestCase({
+        name: "EvaluateWithSaveIndex",
+        description: "Evalute with the saveIndex option should affect $n.",
+        test: (resolve, reject) => {
+            RuntimeAgent.evaluate.invoke({_expression_: "900 + 90", objectGroup: "test", includeCommandLineAPI: true, saveResult: true}, (error, remoteObjectPayload, wasThrown, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 2, "Evaluated result 990 should become $2.");
+            });
+            RuntimeAgent.evaluate.invoke({_expression_: "$2 + 9", objectGroup: "test", includeCommandLineAPI: true, saveResult: true}, (error, remoteObjectPayload, wasThrown, savedResultIndex) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+                InspectorTest.expectThat(savedResultIndex === 1, "Evaluated result 999 should match previous value $1.");
+                resolve();
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for the Runtime.saveResult command ($n values).</p>
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (189414 => 189415)


--- trunk/Source/_javascript_Core/ChangeLog	2015-09-05 02:30:48 UTC (rev 189414)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-09-05 02:34:22 UTC (rev 189415)
@@ -1,3 +1,17 @@
+2015-09-04  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Test Runtime.saveResult and $n values
+        https://bugs.webkit.org/show_bug.cgi?id=148837
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/InjectedScriptSource.js:
+        (InjectedScript.prototype._evaluateOn):
+        We don't need to be in the console object group to put the value
+        in the saved results list. That strong reference will ensure $n
+        values are always alive even if other object groups were used
+        when creating and subsequently released.
+
 2015-09-04  Mark Lam  <[email protected]>
 
         [Follow up] StackOverflow stack unwinding should stop at native frames.

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (189414 => 189415)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-09-05 02:30:48 UTC (rev 189414)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-09-05 02:34:22 UTC (rev 189415)
@@ -487,7 +487,7 @@
             var expressionFunction = evalFunction.call(object, boundExpressionFunctionString);
             var result = expressionFunction.apply(null, parameters);
 
-            if (objectGroup === "console" && saveResult)
+            if (saveResult)
                 this._saveResult(result);
 
             return result;
@@ -507,7 +507,7 @@
 
             var result = evalFunction.call(inspectedGlobalObject, _expression_);
 
-            if (objectGroup === "console" && saveResult)
+            if (saveResult)
                 this._saveResult(result);
 
             return result;

Modified: trunk/Source/WebInspectorUI/ChangeLog (189414 => 189415)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-09-05 02:30:48 UTC (rev 189414)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-09-05 02:34:22 UTC (rev 189415)
@@ -1,5 +1,22 @@
 2015-09-04  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: Test Runtime.saveResult and $n values
+        https://bugs.webkit.org/show_bug.cgi?id=148837
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Protocol/InspectorBackend.js:
+        (InspectorBackendClass):
+        Initialize the dump logging function different if we are in tests or not.
+        When in tests, using console.log as well as dumping system activity to
+        the system console results in an infinite loop of logging!
+
+        (InspectorBackendClass.prototype.dispatch):
+        (InspectorBackendClass.prototype._sendCommandToBackendWithCallback):
+        Use the logging function we figured out earlier.
+
+2015-09-04  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: Clean up and modernize DOMTreeManager
         https://bugs.webkit.org/show_bug.cgi?id=148821
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js (189414 => 189415)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js	2015-09-05 02:30:48 UTC (rev 189414)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js	2015-09-05 02:34:22 UTC (rev 189415)
@@ -43,6 +43,8 @@
         this.dumpInspectorProtocolMessages = false;
         this.warnForLongMessageHandling = false;
         this.longMessageHandlingThreshold = 10; // milliseconds.
+
+        this._log = window.InspectorTest ? InspectorFrontendHost.unbufferedLog.bind(InspectorFrontendHost) : console.log.bind(console);
     }
 
     // Public
@@ -77,7 +79,7 @@
     dispatch(message)
     {
         if (this.dumpInspectorProtocolMessages)
-            console.log("backend: " + ((typeof message === "string") ? message : JSON.stringify(message)));
+            this._log("backend: " + ((typeof message === "string") ? message : JSON.stringify(message)));
 
         var messageObject = (typeof message === "string") ? JSON.parse(message) : message;
 
@@ -173,7 +175,7 @@
     {
         let stringifiedMessage = JSON.stringify(messageObject);
         if (this.dumpInspectorProtocolMessages)
-            console.log("frontend: " + stringifiedMessage);
+            this._log("frontend: " + stringifiedMessage);
 
         InspectorFrontendHost.sendMessageToBackend(stringifiedMessage);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to