Changeset 66712 in webkit


Ignore:
Timestamp:
Sep 2, 2010 10:05:44 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-09-02 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: add page reload test to dom-breakpoints.html
https://bugs.webkit.org/show_bug.cgi?id=44837

  • inspector/dom-breakpoints-expected.txt:
  • inspector/dom-breakpoints.html:

2010-09-02 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: persist DOM breakpoints between page reloads
https://bugs.webkit.org/show_bug.cgi?id=44837

  • inspector/front-end/BreakpointsSidebarPane.js: (WebInspector.DOMBreakpointItem):
  • inspector/front-end/DOMAgent.js: (WebInspector.DOMNode.prototype.path): (WebInspector.DOMNode.prototype.setBreakpoint): (WebInspector.DOMNode.prototype.hasBreakpoint): (WebInspector.DOMNode.prototype.removeBreakpoint): (WebInspector.DOMNode.prototype.removeBreakpoints): (WebInspector.DOMAgent.prototype._setDocument): (WebInspector.DOMAgent.prototype._childNodeRemoved): (WebInspector.DOMAgent.prototype._removeBreakpoints): (WebInspector.DOMBreakpointManager): (WebInspector.DOMBreakpointManager.prototype.setBreakpoint): (WebInspector.DOMBreakpointManager.prototype.removeBreakpointsForNode): (WebInspector.DOMBreakpointManager.prototype._breakpointRemoved): (WebInspector.DOMBreakpointManager.prototype.restoreBreakpoints.restoreBreakpointsForNode): (WebInspector.DOMBreakpointManager.prototype.restoreBreakpoints): (WebInspector.DOMBreakpoint): (WebInspector.DOMBreakpoint.prototype.get nodeId): (WebInspector.DOMBreakpoint.prototype.get type): (WebInspector.DOMBreakpoint.prototype.set enabled): (WebInspector.DOMBreakpoint.prototype.remove):
  • inspector/front-end/ElementsPanel.js: (WebInspector.ElementsPanel.prototype.reset): (WebInspector.ElementsPanel.prototype.setDocument):
  • inspector/front-end/ElementsTreeOutline.js: (WebInspector.ElementsTreeElement.prototype._populateTagContextMenu):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype._showPopup.showObjectPopup):
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r66708 r66712  
     12010-09-02  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: add page reload test to dom-breakpoints.html
     6        https://bugs.webkit.org/show_bug.cgi?id=44837
     7
     8        * inspector/dom-breakpoints-expected.txt:
     9        * inspector/dom-breakpoints.html:
     10
    1112010-09-02  François Sausset  <sausset@gmail.com>
    212
  • trunk/LayoutTests/inspector/dom-breakpoints-expected.txt

    r66596 r66712  
    22
    33Debugger was enabled.
    4 Found dom node d0.
     4Test that 'Subtree Modified' breakpoint is hit when appending child.
    55Set subtree modified DOM breakpoint on d0.
     6Append d1 to d0.
    67Script execution paused.
    78line: 11, function: appendElement
    89Script execution resumed.
    9 Found dom node d1.
     10Test that 'Attribute Modified' breakpoint is hit when modifying attribute.
    1011Set attribute modified DOM breakpoint on d1.
     12Modify d1 className.
    1113Script execution paused.
    1214line: 17, function: modifyAttribute
    1315Script execution resumed.
    14 Found dom node d1.
     16Test that 'Node Removed' breakpoint is hit when removing a node.
    1517Set node removed DOM breakpoint on d1.
     18Remove d1.
    1619Script execution paused.
    1720line: 23, function: removeElement
    1821Script execution resumed.
     22Test that DOM breakpoints are persisted between page reloads.
     23Set subtree modified DOM breakpoint on d0.
     24Page reloaded.
     25Append d1 to d0.
     26Script execution paused.
     27line: 11, function: appendElement
     28Script execution resumed.
    1929Debugger was disabled.
    2030
  • trunk/LayoutTests/inspector/dom-breakpoints.html

    r66596 r66712  
    2828    InspectorTest.startDebuggerTest(step1);
    2929
     30    var d0, d1;
     31
    3032    function step1()
    3133    {
     
    3537    function step2(node)
    3638    {
    37         InspectorTest.addResult("Found dom node d0.");
    38         WebInspector.domBreakpointManager.setBreakpoint(node, WebInspector.DOMBreakpoint.Types.SubtreeModified);
     39        d0 = node;
     40        InspectorTest.addResult("Test that 'Subtree Modified' breakpoint is hit when appending child.");
     41        d0.setBreakpoint(WebInspector.DOMBreakpoint.Types.SubtreeModified);
    3942        InspectorTest.addResult("Set subtree modified DOM breakpoint on d0.");
    4043        InspectorTest.evaluateInConsole("appendElement('d0', 'd1')");
    41         InspectorTest.waitUntilPaused(step3.bind(null, node));
     44        InspectorTest.addResult("Append d1 to d0.");
     45        InspectorTest.waitUntilPaused(step3);
    4246    }
    4347
    44     function step3(node, callFrames)
     48    function step3(callFrames)
    4549    {
    4650        InspectorTest.addResult("line: " + callFrames[0].line + ", function: " + callFrames[0].functionName);
    47         WebInspector.domBreakpointManager.removeBreakpointsForNode(node);
     51        d0.removeBreakpoint(WebInspector.DOMBreakpoint.Types.SubtreeModified);
    4852        InspectorTest.resumeExecution(findDOMNodeById.bind(null, "d1", step4));
    4953    }
     
    5155    function step4(node)
    5256    {
    53         InspectorTest.addResult("Found dom node d1.");
    54         WebInspector.domBreakpointManager.setBreakpoint(node, WebInspector.DOMBreakpoint.Types.AttributeModified);
     57        d1 = node;
     58        InspectorTest.addResult("Test that 'Attribute Modified' breakpoint is hit when modifying attribute.");
     59        d1.setBreakpoint(WebInspector.DOMBreakpoint.Types.AttributeModified);
    5560        InspectorTest.addResult("Set attribute modified DOM breakpoint on d1.");
    5661        InspectorTest.evaluateInConsole("modifyAttribute('d1', 'className', 'foo')");
    57         InspectorTest.waitUntilPaused(step5.bind(null, node));
     62        InspectorTest.addResult("Modify d1 className.");
     63        InspectorTest.waitUntilPaused(step5);
    5864    }
    5965
    60     function step5(node, callFrames)
     66    function step5(callFrames)
    6167    {
    6268        InspectorTest.addResult("line: " + callFrames[0].line + ", function: " + callFrames[0].functionName);
    63         WebInspector.domBreakpointManager.removeBreakpointsForNode(node);
    64         InspectorTest.resumeExecution(findDOMNodeById.bind(null, "d1", step6));
     69        d1.removeBreakpoint(WebInspector.DOMBreakpoint.Types.AttributeModified);
     70        InspectorTest.resumeExecution(step6);
    6571    }
    6672
    67     function step6(node)
     73    function step6()
    6874    {
    69         InspectorTest.addResult("Found dom node d1.");
    70         WebInspector.domBreakpointManager.setBreakpoint(node, WebInspector.DOMBreakpoint.Types.NodeRemoved);
     75        InspectorTest.addResult("Test that 'Node Removed' breakpoint is hit when removing a node.");
     76        d1.setBreakpoint(WebInspector.DOMBreakpoint.Types.NodeRemoved);
    7177        InspectorTest.addResult("Set node removed DOM breakpoint on d1.");
    7278        InspectorTest.evaluateInConsole("removeElement('d1')");
    73         InspectorTest.waitUntilPaused(step7.bind(null, node));
     79        InspectorTest.addResult("Remove d1.");
     80        InspectorTest.waitUntilPaused(step7);
    7481    }
    7582
    76     function step7(node, callFrames)
     83    function step7(callFrames)
    7784    {
    7885        InspectorTest.addResult("line: " + callFrames[0].line + ", function: " + callFrames[0].functionName);
    79         WebInspector.domBreakpointManager.removeBreakpointsForNode(node);
     86        InspectorTest.resumeExecution(step8);
     87    }
     88
     89    function step8()
     90    {
     91        InspectorTest.addResult("Test that DOM breakpoints are persisted between page reloads.");
     92        d0.setBreakpoint(WebInspector.DOMBreakpoint.Types.SubtreeModified);
     93        InspectorTest.addResult("Set subtree modified DOM breakpoint on d0.");
     94        InspectorTest.reloadPage(step9);
     95    }
     96
     97    function step9()
     98    {
     99        InspectorTest.evaluateInConsole("appendElement('d0', 'd1')");
     100        InspectorTest.addResult("Append d1 to d0.");
     101        InspectorTest.waitUntilPaused(step10);
     102    }
     103
     104    function step10(callFrames)
     105    {
     106        InspectorTest.addResult("line: " + callFrames[0].line + ", function: " + callFrames[0].functionName);
    80107        InspectorTest.completeDebuggerTest();
    81108    }
  • trunk/WebCore/ChangeLog

    r66711 r66712  
     12010-09-02  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: persist DOM breakpoints between page reloads
     6        https://bugs.webkit.org/show_bug.cgi?id=44837
     7
     8        * inspector/front-end/BreakpointsSidebarPane.js:
     9        (WebInspector.DOMBreakpointItem):
     10        * inspector/front-end/DOMAgent.js:
     11        (WebInspector.DOMNode.prototype.path):
     12        (WebInspector.DOMNode.prototype.setBreakpoint):
     13        (WebInspector.DOMNode.prototype.hasBreakpoint):
     14        (WebInspector.DOMNode.prototype.removeBreakpoint):
     15        (WebInspector.DOMNode.prototype.removeBreakpoints):
     16        (WebInspector.DOMAgent.prototype._setDocument):
     17        (WebInspector.DOMAgent.prototype._childNodeRemoved):
     18        (WebInspector.DOMAgent.prototype._removeBreakpoints):
     19        (WebInspector.DOMBreakpointManager):
     20        (WebInspector.DOMBreakpointManager.prototype.setBreakpoint):
     21        (WebInspector.DOMBreakpointManager.prototype.removeBreakpointsForNode):
     22        (WebInspector.DOMBreakpointManager.prototype._breakpointRemoved):
     23        (WebInspector.DOMBreakpointManager.prototype.restoreBreakpoints.restoreBreakpointsForNode):
     24        (WebInspector.DOMBreakpointManager.prototype.restoreBreakpoints):
     25        (WebInspector.DOMBreakpoint):
     26        (WebInspector.DOMBreakpoint.prototype.get nodeId):
     27        (WebInspector.DOMBreakpoint.prototype.get type):
     28        (WebInspector.DOMBreakpoint.prototype.set enabled):
     29        (WebInspector.DOMBreakpoint.prototype.remove):
     30        * inspector/front-end/ElementsPanel.js:
     31        (WebInspector.ElementsPanel.prototype.reset):
     32        (WebInspector.ElementsPanel.prototype.setDocument):
     33        * inspector/front-end/ElementsTreeOutline.js:
     34        (WebInspector.ElementsTreeElement.prototype._populateTagContextMenu):
     35        * inspector/front-end/SourceFrame.js:
     36        (WebInspector.SourceFrame.prototype._showPopup.showObjectPopup):
     37
    1382010-09-02  Eric Seidel  <eric@webkit.org>
    239
  • trunk/WebCore/inspector/front-end/BreakpointsSidebarPane.js

    r66213 r66712  
    189189    WebInspector.BreakpointItem.call(this, breakpoint);
    190190
    191     var link = WebInspector.panels.elements.linkifyNodeReference(this._breakpoint.node);
     191    var node = WebInspector.domAgent.nodeForId(this._breakpoint.nodeId);
     192    var link = WebInspector.panels.elements.linkifyNodeReference(node);
    192193    this._element.appendChild(link);
    193194
  • trunk/WebCore/inspector/front-end/DOMAgent.js

    r66282 r66712  
    144144    },
    145145
     146    path: function()
     147    {
     148        var path = [];
     149        var node = this;
     150        while (node && "index" in node && node.nodeName.length) {
     151            path.push([node.index, node.nodeName]);
     152            node = node.parentNode;
     153        }
     154        path.reverse();
     155        return path.join(",");
     156    },
     157
     158    setBreakpoint: function(type)
     159    {
     160        return WebInspector.domBreakpointManager.setBreakpoint(this.id, type, true, this.path());
     161    },
     162
     163    hasBreakpoint: function(type)
     164    {
     165        return !!WebInspector.domBreakpointManager.findBreakpoint(this.id, type);
     166    },
     167
     168    removeBreakpoint: function(type)
     169    {
     170        var breakpoint = WebInspector.domBreakpointManager.findBreakpoint(this.id, type);
     171        if (breakpoint)
     172            breakpoint.remove();
     173    },
     174
     175    removeBreakpoints: function()
     176    {
     177        WebInspector.domBreakpointManager.removeBreakpointsForNode(this.id);
     178    },
     179
    146180    _setAttributesPayload: function(attrs)
    147181    {
     
    363397            this._idToDOMNode[payload.id] = this.document;
    364398            this._bindNodes(this.document.children);
     399            WebInspector.domBreakpointManager.restoreBreakpoints();
    365400        } else
    366401            this.document = null;
     
    419454        this.document._fireDomEvent("DOMNodeRemoved", event);
    420455        delete this._idToDOMNode[nodeId];
    421     }
     456        this._removeBreakpoints(node);
     457    },
     458
     459    _removeBreakpoints: function(node)
     460    {
     461        node.removeBreakpoints();
     462        if (!node.children)
     463            return;
     464        for (var i = 0; i < node.children.length; ++i)
     465            this._removeBreakpoints(node.children[i]);
     466     }
    422467}
    423468
     
    680725{
    681726    this._breakpoints = {};
     727    this._pathCache = {};
    682728}
    683729
    684730WebInspector.DOMBreakpointManager.prototype = {
    685     setBreakpoint: function(node, type)
    686     {
    687         if (!(node.id in this._breakpoints))
    688             this._breakpoints[node.id] = {};
    689         else if (type in this._breakpoints[node.id])
    690             return;
    691 
    692         var breakpoint = new WebInspector.DOMBreakpoint(node, type);
    693         this._breakpoints[node.id][type] = breakpoint;
     731    setBreakpoint: function(nodeId, type, enabled, path)
     732    {
     733        if (!(nodeId in this._breakpoints))
     734            this._breakpoints[nodeId] = {};
     735        else if (type in this._breakpoints[nodeId])
     736            return;
     737
     738        var breakpoint = new WebInspector.DOMBreakpoint(nodeId, type, enabled);
     739        this._breakpoints[nodeId][type] = breakpoint;
    694740        breakpoint.addEventListener("removed", this._breakpointRemoved, this);
     741
     742        if (!(nodeId in this._pathCache))
     743            this._pathCache[nodeId] = path;
    695744
    696745        this.dispatchEventToListeners("dom-breakpoint-added", breakpoint);
     
    704753    },
    705754
    706     removeBreakpointsForNode: function(node)
    707     {
    708         var nodeBreakpoints = this._breakpoints[node.id];
     755    removeBreakpointsForNode: function(nodeId)
     756    {
     757        var nodeBreakpoints = this._breakpoints[nodeId];
    709758        for (var type in nodeBreakpoints)
    710759            nodeBreakpoints[type].remove();
     
    715764        var breakpoint = event.target;
    716765
    717         var nodeBreakpoints = this._breakpoints[breakpoint.node.id];
     766        var nodeBreakpoints = this._breakpoints[breakpoint.nodeId];
    718767        delete nodeBreakpoints[breakpoint.type];
    719768        for (var type in nodeBreakpoints)
    720769            return;
    721         delete this._breakpoints[breakpoint.node.id];
     770
     771        delete this._breakpoints[breakpoint.nodeId];
     772        delete this._pathCache[breakpoint.nodeId];
     773    },
     774
     775    restoreBreakpoints: function()
     776    {
     777        var breakpoints = this._breakpoints;
     778        this._breakpoints = {};
     779        var pathCache = this._pathCache;
     780        this._pathCache = {};
     781
     782        for (var oldNodeId in breakpoints) {
     783            var path = pathCache[oldNodeId];
     784            InspectorBackend.pushNodeByPathToFrontend(path, restoreBreakpointsForNode.bind(this, breakpoints[oldNodeId], path));
     785        }
     786
     787        function restoreBreakpointsForNode(nodeBreakpoints, path, nodeId)
     788        {
     789            if (!nodeId)
     790                return;
     791            for (var type in nodeBreakpoints) {
     792                var breakpoint = nodeBreakpoints[type];
     793                this.setBreakpoint(nodeId, breakpoint.type, breakpoint.enabled, path);
     794            }
     795        }
    722796    }
    723797}
     
    725799WebInspector.DOMBreakpointManager.prototype.__proto__ = WebInspector.Object.prototype;
    726800
    727 WebInspector.DOMBreakpoint = function(node, type)
    728 {
    729     this.node = node;
    730     this.type = type;
    731     this._enabled = true;
    732 
    733     InspectorBackend.setDOMBreakpoint(this.node.id, this.type);
     801WebInspector.DOMBreakpoint = function(nodeId, type, enabled)
     802{
     803    this._nodeId = nodeId;
     804    this._type = type;
     805    this._enabled = enabled;
     806
     807    if (this.enabled)
     808        InspectorBackend.setDOMBreakpoint(this.nodeId, this.type);
    734809}
    735810
     
    763838
    764839WebInspector.DOMBreakpoint.prototype = {
     840    get nodeId()
     841    {
     842        return this._nodeId;
     843    },
     844
     845    get type()
     846    {
     847        return this._type;
     848    },
     849
    765850    get enabled()
    766851    {
     
    774859
    775860        this._enabled = enabled;
    776         if (this._enabled)
    777             InspectorBackend.setDOMBreakpoint(this.node.id, this.type);
     861        if (this.enabled)
     862            InspectorBackend.setDOMBreakpoint(this.nodeId, this.type);
    778863        else
    779             InspectorBackend.removeDOMBreakpoint(this.node.id, this.type);
     864            InspectorBackend.removeDOMBreakpoint(this.nodeId, this.type);
    780865
    781866        this.dispatchEventToListeners("enable-changed");
     
    784869    remove: function()
    785870    {
    786         if (this._enabled)
    787             InspectorBackend.removeDOMBreakpoint(this.node.id, this.type);
     871        if (this.enabled)
     872            InspectorBackend.removeDOMBreakpoint(this.nodeId, this.type);
    788873        this.dispatchEventToListeners("removed");
    789874    }
  • trunk/WebCore/inspector/front-end/ElementsPanel.js

    r66601 r66712  
    160160    reset: function()
    161161    {
    162         if (this.focusedDOMNode) {
    163             this._selectedPathOnReset = [];
    164             var node = this.focusedDOMNode;
    165             while ("index" in node && node.nodeName && node.nodeName.length) {
    166                 this._selectedPathOnReset.push(node.nodeName);
    167                 this._selectedPathOnReset.push(node.index);
    168                 node = node.parentNode;
    169             }
    170             this._selectedPathOnReset.reverse();
    171         }
     162        if (this.focusedDOMNode)
     163            this._selectedPathOnReset = this.focusedDOMNode.path();
    172164
    173165        this.rootDOMNode = null;
     
    226218
    227219        if (this._selectedPathOnReset)
    228             InspectorBackend.pushNodeByPathToFrontend(this._selectedPathOnReset.join(","), selectLastSelectedNode.bind(this));
     220            InspectorBackend.pushNodeByPathToFrontend(this._selectedPathOnReset, selectLastSelectedNode.bind(this));
    229221        else
    230222            selectNode.call(this);
  • trunk/WebCore/inspector/front-end/ElementsTreeOutline.js

    r66282 r66712  
    766766            // Add debbuging-related actions
    767767            contextMenu.appendSeparator();
    768             for (var type in WebInspector.DOMBreakpoint.Types) {
    769                 var typeId = WebInspector.DOMBreakpoint.Types[type];
    770                 var label = WebInspector.DOMBreakpoint.contextMenuLabelForType(typeId);
    771                 var breakpoint = WebInspector.domBreakpointManager.findBreakpoint(this.representedObject.id, typeId);
    772                 if (!breakpoint)
    773                     var handler = WebInspector.domBreakpointManager.setBreakpoint.bind(WebInspector.domBreakpointManager, this.representedObject, typeId);
     768
     769            var node = this.representedObject;
     770            for (var key in WebInspector.DOMBreakpoint.Types) {
     771                var type = WebInspector.DOMBreakpoint.Types[key];
     772                var label = WebInspector.DOMBreakpoint.contextMenuLabelForType(type);
     773                var hasBreakpoint = node.hasBreakpoint(type);
     774                if (!hasBreakpoint)
     775                    var handler = node.setBreakpoint.bind(node, type);
    774776                else
    775                     var handler = breakpoint.remove.bind(breakpoint);
    776                 contextMenu.appendCheckboxItem(label, handler, !!breakpoint);
     777                    var handler = node.removeBreakpoint.bind(node, type);
     778                contextMenu.appendCheckboxItem(label, handler, hasBreakpoint);
    777779            }
    778780        }
  • trunk/WebCore/inspector/front-end/SourceFrame.js

    r65939 r66712  
    599599            if (result.type !== "object" && result.type !== "node" && result.type !== "array") {
    600600                popupContentElement = document.createElement("span");
    601                 popupContentElement.className = "monospace";
     601                popupContentElement.className = "monospace console-formatted-" + result.type;
    602602                popupContentElement.style.whiteSpace = "pre";
    603603                popupContentElement.textContent = result.description;
     604                if (result.type === "string")
     605                    popupContentElement.textContent = "\"" + popupContentElement.textContent + "\"";
    604606                this._popup = new WebInspector.Popover(popupContentElement);
    605607                this._popup.show(element);
Note: See TracChangeset for help on using the changeset viewer.