Changeset 207784 in webkit


Ignore:
Timestamp:
Oct 24, 2016 3:09:29 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Devin Rousso <Devin Rousso> 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.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207782 r207784  
     12016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
     2
     3        Web Inspector: Scope chain shouldn't show empty Closure sections
     4        https://bugs.webkit.org/show_bug.cgi?id=152348
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * inspector/model/scope-chain-node-expected.txt:
     9        * inspector/model/scope-chain-node.html:
     10        Added "empty" indicators to scopes without any property descriptors.
     11
    1122016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
    213
  • trunk/LayoutTests/inspector/model/scope-chain-node-expected.txt

    r198332 r207784  
    5656SCOPE CHAIN:
    5757    Closure
     58      (empty)
    5859    FunctionName
    5960      - functionName: function functionName() {
    6061    Closure
     62      (empty)
    6163    GlobalLexicalEnvironment
    6264      - lexicalGlobalVariable: 2
     
    6668SCOPE CHAIN:
    6769    Closure
     70      (empty)
    6871    Block
    6972      - MyClass: class MyClass
    7073    Closure
     74      (empty)
    7175    GlobalLexicalEnvironment
    7276      - lexicalGlobalVariable: 2
     
    102106      - a: 1
    103107    Closure
     108      (empty)
    104109    GlobalLexicalEnvironment
    105110      - lexicalGlobalVariable: 2
     
    108113SCOPE CHAIN:
    109114    Closure
     115      (empty)
    110116    Block
    111117      - MyClass: class MyClass
     
    113119      - a: 1
    114120    Closure
     121      (empty)
    115122    GlobalLexicalEnvironment
    116123      - lexicalGlobalVariable: 2
     
    119126SCOPE CHAIN:
    120127    Closure
     128      (empty)
    121129    Block
    122130      - MyClassWithStaticMethod: class MyClassWithStaticMethod
     
    124132      - a: 1
    125133    Closure
     134      (empty)
    126135    GlobalLexicalEnvironment
    127136      - lexicalGlobalVariable: 2
  • trunk/LayoutTests/inspector/model/scope-chain-node.html

    r206152 r207784  
    4646            for (let {scope, propertyDescriptors} of results) {
    4747                InspectorTest.log(`    ${scopeTypeToString(scope.type)}`);
    48                 if (scope.type !== WebInspector.ScopeChainNode.Type.Global) {
    49                     for (let descriptor of propertyDescriptors)
    50                         InspectorTest.log(`      - ${descriptor.name}: ${firstLine(descriptor.value.description)}`);
     48                if (scope.type === WebInspector.ScopeChainNode.Type.Global)
     49                    continue;
     50
     51                if (!propertyDescriptors.length) {
     52                    InspectorTest.assert(scope.empty, "Scope should be empty if there are no property descriptors.");
     53                    InspectorTest.log("      (empty)");
     54                    continue;
    5155                }
     56
     57                for (let descriptor of propertyDescriptors)
     58                    InspectorTest.log(`      - ${descriptor.name}: ${firstLine(descriptor.value.description)}`);
    5259            }
    5360            return results;
  • trunk/Source/JavaScriptCore/ChangeLog

    r207781 r207784  
     12016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
     2
     3        Web Inspector: Scope chain shouldn't show empty Closure sections
     4        https://bugs.webkit.org/show_bug.cgi?id=152348
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * inspector/InjectedScriptSource.js:
     9        (isEmptyObject):
     10        (InjectedScript.CallFrameProxy._createScopeJson):
     11        If the scope object has no properties, set empty to true.
     12
     13        * inspector/protocol/Debugger.json:
     14        Added empty property to Scope type.
     15
    1162016-10-24  Keith Miller  <keith_miller@apple.com>
    217
  • trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js

    r207229 r207784  
    6969}
    7070
     71function isEmptyObject(object)
     72{
     73    for (let key in object)
     74        return false;
     75    return true;
     76}
     77
    7178var InjectedScript = function()
    7279{
     
    13361343InjectedScript.CallFrameProxy._createScopeJson = function(object, {name, type, location}, groupId)
    13371344{
    1338     var scope = {
     1345    let scope = {
    13391346        object: injectedScript._wrapObject(object, groupId),
    13401347        type: InjectedScript.CallFrameProxy._scopeTypeNames[type],
     
    13431350    if (name)
    13441351        scope.name = name;
     1352
    13451353    if (location)
    13461354        scope.location = location;
     1355
     1356    if (isEmptyObject(object))
     1357        scope.empty = true;
    13471358
    13481359    return scope;
  • trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json

    r207444 r207784  
    8585                { "name": "type", "type": "string", "enum": ["global", "with", "closure", "catch", "functionName", "globalLexicalEnvironment", "nestedLexical"], "description": "Scope type." },
    8686                { "name": "name", "type": "string", "optional": true, "description": "Name associated with the scope." },
    87                 { "name": "location", "$ref": "Location", "optional": true, "description": "Location if available of the scope definition." }
     87                { "name": "location", "$ref": "Location", "optional": true, "description": "Location if available of the scope definition." },
     88                { "name": "empty", "type": "boolean", "optional": true, "description": "Whether the scope has any variables." }
    8889            ],
    8990            "description": "Scope description."
  • trunk/Source/WebInspectorUI/ChangeLog

    r207782 r207784  
     12016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
     2
     3        Web Inspector: Scope chain shouldn't show empty Closure sections
     4        https://bugs.webkit.org/show_bug.cgi?id=152348
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Controllers/DebuggerManager.js:
     9        (WebInspector.DebuggerManager.prototype._scopeChainNodeFromPayload):
     10        * UserInterface/Models/ScopeChainNode.js:
     11        (WebInspector.ScopeChainNode):
     12        (WebInspector.ScopeChainNode.prototype.get empty):
     13        Added support for new empty property.
     14
     15        * UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
     16        (WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
     17        Only create and display a DetailsSection if the scope is not empty (via empty).
     18
    1192016-10-24  Devin Rousso  <dcrousso+webkit@gmail.com>
    220
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js

    r207444 r207784  
    687687        }
    688688
    689         var object = WebInspector.RemoteObject.fromPayload(payload.object);
    690         return new WebInspector.ScopeChainNode(type, [object], payload.name, payload.location);
     689        let object = WebInspector.RemoteObject.fromPayload(payload.object);
     690        return new WebInspector.ScopeChainNode(type, [object], payload.name, payload.location, payload.empty);
    691691    }
    692692
  • trunk/Source/WebInspectorUI/UserInterface/Models/ScopeChainNode.js

    r202717 r207784  
    2626WebInspector.ScopeChainNode = class ScopeChainNode extends WebInspector.Object
    2727{
    28     constructor(type, objects, name, location)
     28    constructor(type, objects, name, location, empty)
    2929    {
    3030        super();
     
    4040        this._name = name || "";
    4141        this._location = location || null;
     42        this._empty = empty || false;
    4243    }
    4344
     
    4849    get name() { return this._name; }
    4950    get location() { return this._location; }
     51    get empty() { return this._empty; }
    5052
    5153    get hash()
  • trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js

    r204513 r207784  
    169169        let scopeChain = callFrame.mergedScopeChain();
    170170        for (let scope of scopeChain) {
     171            // Don't show sections for empty scopes unless it is the local scope, since it has "this".
     172            if (scope.empty && scope.type !== WebInspector.ScopeChainNode.Type.Local)
     173                continue;
     174
    171175            let title = null;
    172176            let extraPropertyDescriptor = null;
Note: See TracChangeset for help on using the changeset viewer.