Web Inspector: Scope chain shouldn't show empty Closure sections
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2016 22:09:29 +0000 (22:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2016 22:09:29 +0000 (22:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152348

Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-10-24
Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

* inspector/InjectedScriptSource.js:
(isEmptyObject):
(InjectedScript.CallFrameProxy._createScopeJson):
If the scope object has no properties, set empty to true.

* inspector/protocol/Debugger.json:
Added empty property to Scope type.

Source/WebInspectorUI:

* UserInterface/Controllers/DebuggerManager.js:
(WebInspector.DebuggerManager.prototype._scopeChainNodeFromPayload):
* UserInterface/Models/ScopeChainNode.js:
(WebInspector.ScopeChainNode):
(WebInspector.ScopeChainNode.prototype.get empty):
Added support for new empty property.

* UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
(WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
Only create and display a DetailsSection if the scope is not empty (via empty).

LayoutTests:

* inspector/model/scope-chain-node-expected.txt:
* inspector/model/scope-chain-node.html:
Added "empty" indicators to scopes without any property descriptors.

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

LayoutTests/ChangeLog
LayoutTests/inspector/model/scope-chain-node-expected.txt
LayoutTests/inspector/model/scope-chain-node.html
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/InjectedScriptSource.js
Source/JavaScriptCore/inspector/protocol/Debugger.json
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
Source/WebInspectorUI/UserInterface/Models/ScopeChainNode.js
Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js

index 9573281..399d36a 100644 (file)
@@ -1,5 +1,16 @@
 2016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
 
+        Web Inspector: Scope chain shouldn't show empty Closure sections
+        https://bugs.webkit.org/show_bug.cgi?id=152348
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/model/scope-chain-node-expected.txt:
+        * inspector/model/scope-chain-node.html:
+        Added "empty" indicators to scopes without any property descriptors.
+
+2016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
+
         Web Inspector: Improve Quick Open sorting algorithm
         https://bugs.webkit.org/show_bug.cgi?id=163705
 
index e95d7dd..14ea9ba 100644 (file)
@@ -55,9 +55,11 @@ SCOPE CHAIN:
 -- Running test case: WebInspector.ScopeChainNode.FunctionNameInFunctionExpression
 SCOPE CHAIN:
     Closure
+      (empty)
     FunctionName
       - functionName: function functionName() {
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
@@ -65,9 +67,11 @@ SCOPE CHAIN:
 -- Running test case: WebInspector.ScopeChainNode.FunctionNameInClassMethod
 SCOPE CHAIN:
     Closure
+      (empty)
     Block
       - MyClass: class MyClass
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
@@ -101,28 +105,33 @@ SCOPE CHAIN:
     Closure
       - a: 1
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
 PASS: Pause #17 - Contains a Block scope.
 SCOPE CHAIN:
     Closure
+      (empty)
     Block
       - MyClass: class MyClass
     Closure
       - a: 1
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
 PASS: Pause #18 - Contains a Block scope.
 SCOPE CHAIN:
     Closure
+      (empty)
     Block
       - MyClassWithStaticMethod: class MyClassWithStaticMethod
     Closure
       - a: 1
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
index 5f6c29a..c671bd8 100644 (file)
@@ -45,10 +45,17 @@ function test()
             InspectorTest.log("SCOPE CHAIN:");
             for (let {scope, propertyDescriptors} of results) {
                 InspectorTest.log(`    ${scopeTypeToString(scope.type)}`);
-                if (scope.type !== WebInspector.ScopeChainNode.Type.Global) {
-                    for (let descriptor of propertyDescriptors)
-                        InspectorTest.log(`      - ${descriptor.name}: ${firstLine(descriptor.value.description)}`);
+                if (scope.type === WebInspector.ScopeChainNode.Type.Global)
+                    continue;
+
+                if (!propertyDescriptors.length) {
+                    InspectorTest.assert(scope.empty, "Scope should be empty if there are no property descriptors.");
+                    InspectorTest.log("      (empty)");
+                    continue;
                 }
+
+                for (let descriptor of propertyDescriptors)
+                    InspectorTest.log(`      - ${descriptor.name}: ${firstLine(descriptor.value.description)}`);
             }
             return results;
         });
index eaa20b6..85c943b 100644 (file)
@@ -1,3 +1,18 @@
+2016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
+
+        Web Inspector: Scope chain shouldn't show empty Closure sections
+        https://bugs.webkit.org/show_bug.cgi?id=152348
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/InjectedScriptSource.js:
+        (isEmptyObject):
+        (InjectedScript.CallFrameProxy._createScopeJson):
+        If the scope object has no properties, set empty to true.
+
+        * inspector/protocol/Debugger.json:
+        Added empty property to Scope type.
+
 2016-10-24  Keith Miller  <keith_miller@apple.com>
 
         Wasm should support floating point operations.
index 6cbac83..c8b05e9 100644 (file)
@@ -68,6 +68,13 @@ function isSymbol(obj)
     return typeof obj === "symbol";
 }
 
+function isEmptyObject(object)
+{
+    for (let key in object)
+        return false;
+    return true;
+}
+
 var InjectedScript = function()
 {
     this._lastBoundObjectId = 1;
@@ -1335,16 +1342,20 @@ InjectedScript.CallFrameProxy._scopeTypeNames = {
 
 InjectedScript.CallFrameProxy._createScopeJson = function(object, {name, type, location}, groupId)
 {
-    var scope = {
+    let scope = {
         object: injectedScript._wrapObject(object, groupId),
         type: InjectedScript.CallFrameProxy._scopeTypeNames[type],
     };
 
     if (name)
         scope.name = name;
+
     if (location)
         scope.location = location;
 
+    if (isEmptyObject(object))
+        scope.empty = true;
+
     return scope;
 }
 
index 4d18114..82e42d6 100644 (file)
@@ -84,7 +84,8 @@
                 { "name": "object", "$ref": "Runtime.RemoteObject", "description": "Object representing the scope. For <code>global</code> and <code>with</code> scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties." },
                 { "name": "type", "type": "string", "enum": ["global", "with", "closure", "catch", "functionName", "globalLexicalEnvironment", "nestedLexical"], "description": "Scope type." },
                 { "name": "name", "type": "string", "optional": true, "description": "Name associated with the scope." },
-                { "name": "location", "$ref": "Location", "optional": true, "description": "Location if available of the scope definition." }
+                { "name": "location", "$ref": "Location", "optional": true, "description": "Location if available of the scope definition." },
+                { "name": "empty", "type": "boolean", "optional": true, "description": "Whether the scope has any variables." }
             ],
             "description": "Scope description."
         },
index 239f695..0665323 100644 (file)
@@ -1,5 +1,23 @@
 2016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
 
+        Web Inspector: Scope chain shouldn't show empty Closure sections
+        https://bugs.webkit.org/show_bug.cgi?id=152348
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Controllers/DebuggerManager.js:
+        (WebInspector.DebuggerManager.prototype._scopeChainNodeFromPayload):
+        * UserInterface/Models/ScopeChainNode.js:
+        (WebInspector.ScopeChainNode):
+        (WebInspector.ScopeChainNode.prototype.get empty):
+        Added support for new empty property.
+
+        * UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
+        (WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
+        Only create and display a DetailsSection if the scope is not empty (via empty).
+
+2016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
+
         Web Inspector: Improve Quick Open sorting algorithm
         https://bugs.webkit.org/show_bug.cgi?id=163705
 
index cdcc0a3..70a7b3e 100644 (file)
@@ -686,8 +686,8 @@ WebInspector.DebuggerManager = class DebuggerManager extends WebInspector.Object
             console.error("Unknown type: " + payload.type);
         }
 
-        var object = WebInspector.RemoteObject.fromPayload(payload.object);
-        return new WebInspector.ScopeChainNode(type, [object], payload.name, payload.location);
+        let object = WebInspector.RemoteObject.fromPayload(payload.object);
+        return new WebInspector.ScopeChainNode(type, [object], payload.name, payload.location, payload.empty);
     }
 
     _pauseReasonFromPayload(payload)
index 1398c1e..8e3811e 100644 (file)
@@ -25,7 +25,7 @@
 
 WebInspector.ScopeChainNode = class ScopeChainNode extends WebInspector.Object
 {
-    constructor(type, objects, name, location)
+    constructor(type, objects, name, location, empty)
     {
         super();
 
@@ -39,6 +39,7 @@ WebInspector.ScopeChainNode = class ScopeChainNode extends WebInspector.Object
         this._objects = objects || [];
         this._name = name || "";
         this._location = location || null;
+        this._empty = empty || false;
     }
 
     // Public
@@ -47,6 +48,7 @@ WebInspector.ScopeChainNode = class ScopeChainNode extends WebInspector.Object
     get objects() { return this._objects; }
     get name() { return this._name; }
     get location() { return this._location; }
+    get empty() { return this._empty; }
 
     get hash()
     {
index c832cc0..fa0cee9 100644 (file)
@@ -168,6 +168,10 @@ WebInspector.ScopeChainDetailsSidebarPanel = class ScopeChainDetailsSidebarPanel
 
         let scopeChain = callFrame.mergedScopeChain();
         for (let scope of scopeChain) {
+            // Don't show sections for empty scopes unless it is the local scope, since it has "this".
+            if (scope.empty && scope.type !== WebInspector.ScopeChainNode.Type.Local)
+                continue;
+
             let title = null;
             let extraPropertyDescriptor = null;
             let collapsedByDefault = false;