Title: [207784] trunk
Revision
207784
Author
commit-qu...@webkit.org
Date
2016-10-24 15:09:29 -0700 (Mon, 24 Oct 2016)

Log Message

Web Inspector: Scope chain shouldn't show empty Closure sections
https://bugs.webkit.org/show_bug.cgi?id=152348

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

Source/_javascript_Core:

* 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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207783 => 207784)


--- trunk/LayoutTests/ChangeLog	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/LayoutTests/ChangeLog	2016-10-24 22:09:29 UTC (rev 207784)
@@ -1,5 +1,16 @@
 2016-10-24  Devin Rousso  <dcrousso+web...@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+web...@gmail.com>
+
         Web Inspector: Improve Quick Open sorting algorithm
         https://bugs.webkit.org/show_bug.cgi?id=163705
 

Modified: trunk/LayoutTests/inspector/model/scope-chain-node-expected.txt (207783 => 207784)


--- trunk/LayoutTests/inspector/model/scope-chain-node-expected.txt	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/LayoutTests/inspector/model/scope-chain-node-expected.txt	2016-10-24 22:09:29 UTC (rev 207784)
@@ -55,9 +55,11 @@
 -- Running test case: WebInspector.ScopeChainNode.FunctionNameInFunctionExpression
 SCOPE CHAIN:
     Closure
+      (empty)
     FunctionName
       - functionName: function functionName() {
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
@@ -65,9 +67,11 @@
 -- Running test case: WebInspector.ScopeChainNode.FunctionNameInClassMethod
 SCOPE CHAIN:
     Closure
+      (empty)
     Block
       - MyClass: class MyClass
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
@@ -101,6 +105,7 @@
     Closure
       - a: 1
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
@@ -107,11 +112,13 @@
 PASS: Pause #17 - Contains a Block scope.
 SCOPE CHAIN:
     Closure
+      (empty)
     Block
       - MyClass: class MyClass
     Closure
       - a: 1
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global
@@ -118,11 +125,13 @@
 PASS: Pause #18 - Contains a Block scope.
 SCOPE CHAIN:
     Closure
+      (empty)
     Block
       - MyClassWithStaticMethod: class MyClassWithStaticMethod
     Closure
       - a: 1
     Closure
+      (empty)
     GlobalLexicalEnvironment
       - lexicalGlobalVariable: 2
     Global

Modified: trunk/LayoutTests/inspector/model/scope-chain-node.html (207783 => 207784)


--- trunk/LayoutTests/inspector/model/scope-chain-node.html	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/LayoutTests/inspector/model/scope-chain-node.html	2016-10-24 22:09:29 UTC (rev 207784)
@@ -45,10 +45,17 @@
             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;
         });

Modified: trunk/Source/_javascript_Core/ChangeLog (207783 => 207784)


--- trunk/Source/_javascript_Core/ChangeLog	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-10-24 22:09:29 UTC (rev 207784)
@@ -1,3 +1,18 @@
+2016-10-24  Devin Rousso  <dcrousso+web...@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_mil...@apple.com>
 
         Wasm should support floating point operations.

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (207783 => 207784)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2016-10-24 22:09:29 UTC (rev 207784)
@@ -68,6 +68,13 @@
     return typeof obj === "symbol";
 }
 
+function isEmptyObject(object)
+{
+    for (let key in object)
+        return false;
+    return true;
+}
+
 var InjectedScript = function()
 {
     this._lastBoundObjectId = 1;
@@ -1335,7 +1342,7 @@
 
 InjectedScript.CallFrameProxy._createScopeJson = function(object, {name, type, location}, groupId)
 {
-    var scope = {
+    let scope = {
         object: injectedScript._wrapObject(object, groupId),
         type: InjectedScript.CallFrameProxy._scopeTypeNames[type],
     };
@@ -1342,9 +1349,13 @@
 
     if (name)
         scope.name = name;
+
     if (location)
         scope.location = location;
 
+    if (isEmptyObject(object))
+        scope.empty = true;
+
     return scope;
 }
 

Modified: trunk/Source/_javascript_Core/inspector/protocol/Debugger.json (207783 => 207784)


--- trunk/Source/_javascript_Core/inspector/protocol/Debugger.json	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/Source/_javascript_Core/inspector/protocol/Debugger.json	2016-10-24 22:09:29 UTC (rev 207784)
@@ -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."
         },

Modified: trunk/Source/WebInspectorUI/ChangeLog (207783 => 207784)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-10-24 22:09:29 UTC (rev 207784)
@@ -1,5 +1,23 @@
 2016-10-24  Devin Rousso  <dcrousso+web...@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+web...@gmail.com>
+
         Web Inspector: Improve Quick Open sorting algorithm
         https://bugs.webkit.org/show_bug.cgi?id=163705
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (207783 => 207784)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js	2016-10-24 22:09:29 UTC (rev 207784)
@@ -686,8 +686,8 @@
             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)

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ScopeChainNode.js (207783 => 207784)


--- trunk/Source/WebInspectorUI/UserInterface/Models/ScopeChainNode.js	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ScopeChainNode.js	2016-10-24 22:09:29 UTC (rev 207784)
@@ -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 @@
         this._objects = objects || [];
         this._name = name || "";
         this._location = location || null;
+        this._empty = empty || false;
     }
 
     // Public
@@ -47,6 +48,7 @@
     get objects() { return this._objects; }
     get name() { return this._name; }
     get location() { return this._location; }
+    get empty() { return this._empty; }
 
     get hash()
     {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js (207783 => 207784)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js	2016-10-24 21:51:44 UTC (rev 207783)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js	2016-10-24 22:09:29 UTC (rev 207784)
@@ -168,6 +168,10 @@
 
         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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to