Title: [219749] trunk
Revision
219749
Author
[email protected]
Date
2017-07-21 15:41:26 -0700 (Fri, 21 Jul 2017)

Log Message

Web Inspector: inspect(aFunction) should jump to function definition
https://bugs.webkit.org/show_bug.cgi?id=149344
<rdar://problem/11563607>

Patch by Joseph Pecoraro <[email protected]> on 2017-07-21
Reviewed by Matt Baker.

Source/WebInspectorUI:

* UserInterface/Protocol/InspectorObserver.js:
(WebInspector.InspectorObserver.prototype.inspect):
If we receive a function remote object jump to its location if available.

LayoutTests:

* inspector/runtime/CommandLineAPI-inspect-expected.txt: Added.
* inspector/runtime/CommandLineAPI-inspect.html: Added.
Add tests for the CommandLineAPI's inspect() and how it triggers the
`Inspector.inspect` event with a RemoteObject and hints.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219748 => 219749)


--- trunk/LayoutTests/ChangeLog	2017-07-21 22:22:26 UTC (rev 219748)
+++ trunk/LayoutTests/ChangeLog	2017-07-21 22:41:26 UTC (rev 219749)
@@ -1,3 +1,16 @@
+2017-07-21  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: inspect(aFunction) should jump to function definition
+        https://bugs.webkit.org/show_bug.cgi?id=149344
+        <rdar://problem/11563607>
+
+        Reviewed by Matt Baker.
+
+        * inspector/runtime/CommandLineAPI-inspect-expected.txt: Added.
+        * inspector/runtime/CommandLineAPI-inspect.html: Added.
+        Add tests for the CommandLineAPI's inspect() and how it triggers the
+        `Inspector.inspect` event with a RemoteObject and hints.
+
 2017-07-21  Matt Lewis  <[email protected]>
 
         Adjusted test expectations.

Added: trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect-expected.txt (0 => 219749)


--- trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect-expected.txt	2017-07-21 22:41:26 UTC (rev 219749)
@@ -0,0 +1,97 @@
+Tests for CommandLineAPI.prototype.inspect with different object types.
+
+
+== Running test suite: CommandLineAPI.prototype.inspect
+-- Running test case: CommandLineAPI.prototype.inspect.RemoteObject.Undefined
+_expression_: inspect()
+{
+  "method": "Inspector.inspect",
+  "params": {
+    "object": {
+      "type": "undefined"
+    },
+    "hints": {}
+  }
+}
+
+-- Running test case: CommandLineAPI.prototype.inspect.RemoteObject.Number
+_expression_: inspect(123.456)
+{
+  "method": "Inspector.inspect",
+  "params": {
+    "object": {
+      "type": "number",
+      "value": 123.456,
+      "description": "123.456"
+    },
+    "hints": {}
+  }
+}
+
+-- Running test case: CommandLineAPI.prototype.inspect.RemoteObject.Object
+_expression_: inspect({a:1, b:2})
+{
+  "method": "Inspector.inspect",
+  "params": {
+    "object": {
+      "type": "object",
+      "objectId": "<filtered>",
+      "className": "Object",
+      "description": "Object"
+    },
+    "hints": {}
+  }
+}
+
+-- Running test case: CommandLineAPI.prototype.inspect.RemoteObject.Function
+_expression_: inspect(function f() {})
+{
+  "method": "Inspector.inspect",
+  "params": {
+    "object": {
+      "type": "function",
+      "objectId": "<filtered>",
+      "className": "Function",
+      "description": "function f() {}"
+    },
+    "hints": {}
+  }
+}
+
+-- Running test case: CommandLineAPI.prototype.inspect.Database
+_expression_: inspect(openDatabase("CommandLineAPITestDB", "", "", 1))
+{
+  "method": "Inspector.inspect",
+  "params": {
+    "object": {
+      "type": "object",
+      "objectId": "<filtered>",
+      "className": "Database",
+      "description": "Database"
+    },
+    "hints": {
+      "databaseId": "1"
+    }
+  }
+}
+
+-- Running test case: CommandLineAPI.prototype.inspect.Storage
+_expression_: inspect(sessionStorage)
+{
+  "method": "Inspector.inspect",
+  "params": {
+    "object": {
+      "type": "object",
+      "objectId": "<filtered>",
+      "className": "Storage",
+      "description": "Storage"
+    },
+    "hints": {
+      "domStorageId": {
+        "securityOrigin": "file://",
+        "isLocalStorage": false
+      }
+    }
+  }
+}
+

Added: trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect.html (0 => 219749)


--- trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/CommandLineAPI-inspect.html	2017-07-21 22:41:26 UTC (rev 219749)
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    function payloadJSONFilter(key, value) {
+        if (key === "objectId")
+            return "<filtered>";
+        return value;
+    }
+
+    function evaluateWithCommandLineAPI(_expression_) {
+        const objectGroup = "test";
+        const includeCommandLineAPI = true;
+        return InspectorProtocol.awaitCommand({
+            method: "Runtime.evaluate",
+            params: {_expression_, objectGroup, includeCommandLineAPI}
+        });
+    }
+
+    let suite = ProtocolTest.createAsyncSuite("CommandLineAPI.prototype.inspect");
+
+    InspectorProtocol.awaitCommand({method: "Inspector.enable", params: {}})
+
+    function addTestCase({name, description, _expression_}) {
+        suite.addTestCase({
+            name, description,
+            test(resolve, reject) {
+                evaluateWithCommandLineAPI(_expression_);
+                ProtocolTest.log("_expression_: " + _expression_);                
+                InspectorProtocol.awaitEvent({event: "Inspector.inspect"}).then((messageObject) => {
+                    ProtocolTest.log(JSON.stringify(messageObject, payloadJSONFilter, 2));
+                    resolve();
+                });
+            }
+        });
+    }
+
+    addTestCase({
+        name: "CommandLineAPI.prototype.inspect.RemoteObject.Undefined",
+        description: "inspect() should produce a remote object for undefined",
+        _expression_: `inspect()`,
+    });
+
+    addTestCase({
+        name: "CommandLineAPI.prototype.inspect.RemoteObject.Number",
+        description: "inspect(value) should produce a remote object for that value",
+        _expression_: `inspect(123.456)`,
+    });
+
+    addTestCase({
+        name: "CommandLineAPI.prototype.inspect.RemoteObject.Object",
+        description: "inspect(value) should produce a remote object for that value",
+        _expression_: `inspect({a:1, b:2})`,
+    });
+
+    addTestCase({
+        name: "CommandLineAPI.prototype.inspect.RemoteObject.Function",
+        description: "inspect(value) should produce a remote object for that value",
+        _expression_: `inspect(function f() {})`,
+    });
+
+    addTestCase({
+        name: "CommandLineAPI.prototype.inspect.Database",
+        description: "inspect(database) should include a hint",
+        _expression_: `inspect(openDatabase("CommandLineAPITestDB", "", "", 1))`,
+    });
+
+    addTestCase({
+        name: "CommandLineAPI.prototype.inspect.Storage",
+        description: "inspect(sessionStorage) should include a hint",
+        _expression_: `inspect(sessionStorage)`,
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for CommandLineAPI.prototype.inspect with different object types.</p>
+</body>
+</html>

Modified: trunk/Source/WebInspectorUI/ChangeLog (219748 => 219749)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-07-21 22:22:26 UTC (rev 219748)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-07-21 22:41:26 UTC (rev 219749)
@@ -1,5 +1,17 @@
 2017-07-21  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: inspect(aFunction) should jump to function definition
+        https://bugs.webkit.org/show_bug.cgi?id=149344
+        <rdar://problem/11563607>
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Protocol/InspectorObserver.js:
+        (WebInspector.InspectorObserver.prototype.inspect):
+        If we receive a function remote object jump to its location if available.
+
+2017-07-21  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: Avoid subclassing WebInspector.Object if we do not need to
         https://bugs.webkit.org/show_bug.cgi?id=174703
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorObserver.js (219748 => 219749)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorObserver.js	2017-07-21 22:22:26 UTC (rev 219748)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorObserver.js	2017-07-21 22:41:26 UTC (rev 219749)
@@ -39,12 +39,25 @@
 
     inspect(payload, hints)
     {
-        var remoteObject = WebInspector.RemoteObject.fromPayload(payload, WebInspector.mainTarget);
+        let remoteObject = WebInspector.RemoteObject.fromPayload(payload, WebInspector.mainTarget);
         if (remoteObject.subtype === "node") {
             WebInspector.domTreeManager.inspectNodeObject(remoteObject);
             return;
         }
 
+        if (remoteObject.type === "function") {
+            remoteObject.findFunctionSourceCodeLocation().then((sourceCodeLocation) => {
+                if (sourceCodeLocation instanceof WebInspector.SourceCodeLocation) {
+                    WebInspector.showSourceCodeLocation(sourceCodeLocation, {
+                        ignoreNetworkTab: true,
+                        ignoreSearchTab: true,
+                    });
+                }
+            });
+            remoteObject.release();
+            return;            
+        }
+
         if (hints.databaseId)
             WebInspector.storageManager.inspectDatabase(hints.databaseId);
         else if (hints.domStorageId)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to