Changeset 66712 in webkit
- Timestamp:
- Sep 2, 2010 10:05:44 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r66708 r66712 1 2010-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 1 11 2010-09-02 François Sausset <sausset@gmail.com> 2 12 -
trunk/LayoutTests/inspector/dom-breakpoints-expected.txt
r66596 r66712 2 2 3 3 Debugger was enabled. 4 Found dom node d0.4 Test that 'Subtree Modified' breakpoint is hit when appending child. 5 5 Set subtree modified DOM breakpoint on d0. 6 Append d1 to d0. 6 7 Script execution paused. 7 8 line: 11, function: appendElement 8 9 Script execution resumed. 9 Found dom node d1.10 Test that 'Attribute Modified' breakpoint is hit when modifying attribute. 10 11 Set attribute modified DOM breakpoint on d1. 12 Modify d1 className. 11 13 Script execution paused. 12 14 line: 17, function: modifyAttribute 13 15 Script execution resumed. 14 Found dom node d1.16 Test that 'Node Removed' breakpoint is hit when removing a node. 15 17 Set node removed DOM breakpoint on d1. 18 Remove d1. 16 19 Script execution paused. 17 20 line: 23, function: removeElement 18 21 Script execution resumed. 22 Test that DOM breakpoints are persisted between page reloads. 23 Set subtree modified DOM breakpoint on d0. 24 Page reloaded. 25 Append d1 to d0. 26 Script execution paused. 27 line: 11, function: appendElement 28 Script execution resumed. 19 29 Debugger was disabled. 20 30 -
trunk/LayoutTests/inspector/dom-breakpoints.html
r66596 r66712 28 28 InspectorTest.startDebuggerTest(step1); 29 29 30 var d0, d1; 31 30 32 function step1() 31 33 { … … 35 37 function step2(node) 36 38 { 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); 39 42 InspectorTest.addResult("Set subtree modified DOM breakpoint on d0."); 40 43 InspectorTest.evaluateInConsole("appendElement('d0', 'd1')"); 41 InspectorTest.waitUntilPaused(step3.bind(null, node)); 44 InspectorTest.addResult("Append d1 to d0."); 45 InspectorTest.waitUntilPaused(step3); 42 46 } 43 47 44 function step3( node,callFrames)48 function step3(callFrames) 45 49 { 46 50 InspectorTest.addResult("line: " + callFrames[0].line + ", function: " + callFrames[0].functionName); 47 WebInspector.domBreakpointManager.removeBreakpointsForNode(node);51 d0.removeBreakpoint(WebInspector.DOMBreakpoint.Types.SubtreeModified); 48 52 InspectorTest.resumeExecution(findDOMNodeById.bind(null, "d1", step4)); 49 53 } … … 51 55 function step4(node) 52 56 { 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); 55 60 InspectorTest.addResult("Set attribute modified DOM breakpoint on d1."); 56 61 InspectorTest.evaluateInConsole("modifyAttribute('d1', 'className', 'foo')"); 57 InspectorTest.waitUntilPaused(step5.bind(null, node)); 62 InspectorTest.addResult("Modify d1 className."); 63 InspectorTest.waitUntilPaused(step5); 58 64 } 59 65 60 function step5( node,callFrames)66 function step5(callFrames) 61 67 { 62 68 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); 65 71 } 66 72 67 function step6( node)73 function step6() 68 74 { 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); 71 77 InspectorTest.addResult("Set node removed DOM breakpoint on d1."); 72 78 InspectorTest.evaluateInConsole("removeElement('d1')"); 73 InspectorTest.waitUntilPaused(step7.bind(null, node)); 79 InspectorTest.addResult("Remove d1."); 80 InspectorTest.waitUntilPaused(step7); 74 81 } 75 82 76 function step7( node,callFrames)83 function step7(callFrames) 77 84 { 78 85 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); 80 107 InspectorTest.completeDebuggerTest(); 81 108 } -
trunk/WebCore/ChangeLog
r66711 r66712 1 2010-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 1 38 2010-09-02 Eric Seidel <eric@webkit.org> 2 39 -
trunk/WebCore/inspector/front-end/BreakpointsSidebarPane.js
r66213 r66712 189 189 WebInspector.BreakpointItem.call(this, breakpoint); 190 190 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); 192 193 this._element.appendChild(link); 193 194 -
trunk/WebCore/inspector/front-end/DOMAgent.js
r66282 r66712 144 144 }, 145 145 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 146 180 _setAttributesPayload: function(attrs) 147 181 { … … 363 397 this._idToDOMNode[payload.id] = this.document; 364 398 this._bindNodes(this.document.children); 399 WebInspector.domBreakpointManager.restoreBreakpoints(); 365 400 } else 366 401 this.document = null; … … 419 454 this.document._fireDomEvent("DOMNodeRemoved", event); 420 455 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 } 422 467 } 423 468 … … 680 725 { 681 726 this._breakpoints = {}; 727 this._pathCache = {}; 682 728 } 683 729 684 730 WebInspector.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; 694 740 breakpoint.addEventListener("removed", this._breakpointRemoved, this); 741 742 if (!(nodeId in this._pathCache)) 743 this._pathCache[nodeId] = path; 695 744 696 745 this.dispatchEventToListeners("dom-breakpoint-added", breakpoint); … … 704 753 }, 705 754 706 removeBreakpointsForNode: function(node )707 { 708 var nodeBreakpoints = this._breakpoints[node .id];755 removeBreakpointsForNode: function(nodeId) 756 { 757 var nodeBreakpoints = this._breakpoints[nodeId]; 709 758 for (var type in nodeBreakpoints) 710 759 nodeBreakpoints[type].remove(); … … 715 764 var breakpoint = event.target; 716 765 717 var nodeBreakpoints = this._breakpoints[breakpoint.node .id];766 var nodeBreakpoints = this._breakpoints[breakpoint.nodeId]; 718 767 delete nodeBreakpoints[breakpoint.type]; 719 768 for (var type in nodeBreakpoints) 720 769 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 } 722 796 } 723 797 } … … 725 799 WebInspector.DOMBreakpointManager.prototype.__proto__ = WebInspector.Object.prototype; 726 800 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); 801 WebInspector.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); 734 809 } 735 810 … … 763 838 764 839 WebInspector.DOMBreakpoint.prototype = { 840 get nodeId() 841 { 842 return this._nodeId; 843 }, 844 845 get type() 846 { 847 return this._type; 848 }, 849 765 850 get enabled() 766 851 { … … 774 859 775 860 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); 778 863 else 779 InspectorBackend.removeDOMBreakpoint(this.node .id, this.type);864 InspectorBackend.removeDOMBreakpoint(this.nodeId, this.type); 780 865 781 866 this.dispatchEventToListeners("enable-changed"); … … 784 869 remove: function() 785 870 { 786 if (this. _enabled)787 InspectorBackend.removeDOMBreakpoint(this.node .id, this.type);871 if (this.enabled) 872 InspectorBackend.removeDOMBreakpoint(this.nodeId, this.type); 788 873 this.dispatchEventToListeners("removed"); 789 874 } -
trunk/WebCore/inspector/front-end/ElementsPanel.js
r66601 r66712 160 160 reset: function() 161 161 { 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(); 172 164 173 165 this.rootDOMNode = null; … … 226 218 227 219 if (this._selectedPathOnReset) 228 InspectorBackend.pushNodeByPathToFrontend(this._selectedPathOnReset .join(","), selectLastSelectedNode.bind(this));220 InspectorBackend.pushNodeByPathToFrontend(this._selectedPathOnReset, selectLastSelectedNode.bind(this)); 229 221 else 230 222 selectNode.call(this); -
trunk/WebCore/inspector/front-end/ElementsTreeOutline.js
r66282 r66712 766 766 // Add debbuging-related actions 767 767 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); 774 776 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); 777 779 } 778 780 } -
trunk/WebCore/inspector/front-end/SourceFrame.js
r65939 r66712 599 599 if (result.type !== "object" && result.type !== "node" && result.type !== "array") { 600 600 popupContentElement = document.createElement("span"); 601 popupContentElement.className = "monospace ";601 popupContentElement.className = "monospace console-formatted-" + result.type; 602 602 popupContentElement.style.whiteSpace = "pre"; 603 603 popupContentElement.textContent = result.description; 604 if (result.type === "string") 605 popupContentElement.textContent = "\"" + popupContentElement.textContent + "\""; 604 606 this._popup = new WebInspector.Popover(popupContentElement); 605 607 this._popup.show(element);
Note: See TracChangeset
for help on using the changeset viewer.