| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 4 | 4 |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function test() | 7 function test() |
| 8 { | 8 { |
| 9 var uiSourceCodes = {}; | 9 var uiSourceCodes = {}; |
| 10 var mockTarget = {}; |
| 10 | 11 |
| 11 var defaultMapping = { | 12 var defaultMapping = { |
| 12 rawLocationToUILocation: function(rawLocation) | 13 rawLocationToUILocation: function(rawLocation) |
| 13 { | 14 { |
| 14 return new WebInspector.UILocation(uiSourceCodes[rawLocation.scriptI
d], rawLocation.lineNumber, 0); | 15 return new WebInspector.UILocation(uiSourceCodes[rawLocation.scriptI
d], rawLocation.lineNumber, 0); |
| 15 }, | 16 }, |
| 16 | 17 |
| 17 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | 18 uiLocationToRawLocation: function(uiSourceCode, lineNumber) |
| 18 { | 19 { |
| 19 if (!uiSourceCodes[uiSourceCode.url]) | 20 if (!uiSourceCodes[uiSourceCode.url]) |
| 20 return null; | 21 return null; |
| 21 return new WebInspector.DebuggerModel.Location(uiSourceCode.url, lin
eNumber, 0); | 22 return new WebInspector.DebuggerModel.Location(mockTarget, uiSourceC
ode.url, lineNumber, 0); |
| 22 }, | 23 }, |
| 23 | 24 |
| 24 isIdentity: function() | 25 isIdentity: function() |
| 25 { | 26 { |
| 26 return true; | 27 return true; |
| 27 } | 28 } |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 var shiftingMapping = { | 31 var shiftingMapping = { |
| 31 rawLocationToUILocation: function(rawLocation) | 32 rawLocationToUILocation: function(rawLocation) |
| 32 { | 33 { |
| 33 if (this._disabled) | 34 if (this._disabled) |
| 34 return null; | 35 return null; |
| 35 return new WebInspector.UILocation(uiSourceCodes[rawLocation.scriptI
d], rawLocation.lineNumber + 10, 0); | 36 return new WebInspector.UILocation(uiSourceCodes[rawLocation.scriptI
d], rawLocation.lineNumber + 10, 0); |
| 36 }, | 37 }, |
| 37 | 38 |
| 38 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | 39 uiLocationToRawLocation: function(uiSourceCode, lineNumber) |
| 39 { | 40 { |
| 40 return new WebInspector.DebuggerModel.Location(uiSourceCode.url, lin
eNumber - 10, 0); | 41 return new WebInspector.DebuggerModel.Location(mockTarget, uiSourceC
ode.url, lineNumber - 10, 0); |
| 41 }, | 42 }, |
| 42 | 43 |
| 43 isIdentity: function() | 44 isIdentity: function() |
| 44 { | 45 { |
| 45 return false; | 46 return false; |
| 46 } | 47 } |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 function createSourceMapping(uiSourceCodeA, uiSourceCodeB) | 50 function createSourceMapping(uiSourceCodeA, uiSourceCodeB) |
| 50 { | 51 { |
| 51 var mapping = { | 52 var mapping = { |
| 52 rawLocationToUILocation: function(rawLocation) | 53 rawLocationToUILocation: function(rawLocation) |
| 53 { | 54 { |
| 54 if (this._disabled) | 55 if (this._disabled) |
| 55 return null; | 56 return null; |
| 56 return new WebInspector.UILocation(uiSourceCodeB, rawLocation.li
neNumber + 10, 0); | 57 return new WebInspector.UILocation(uiSourceCodeB, rawLocation.li
neNumber + 10, 0); |
| 57 }, | 58 }, |
| 58 | 59 |
| 59 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | 60 uiLocationToRawLocation: function(uiSourceCode, lineNumber) |
| 60 { | 61 { |
| 61 return new WebInspector.DebuggerModel.Location(uiSourceCodeA.url
, lineNumber - 10, 0); | 62 return new WebInspector.DebuggerModel.Location(mockTarget, uiSou
rceCodeA.url, lineNumber - 10, 0); |
| 62 }, | 63 }, |
| 63 | 64 |
| 64 isIdentity: function() | 65 isIdentity: function() |
| 65 { | 66 { |
| 66 return false; | 67 return false; |
| 67 } | 68 } |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 return mapping; | 71 return mapping; |
| 71 } | 72 } |
| 72 | 73 |
| 73 function DebuggerModelMock(sourceMapping) | 74 function DebuggerModelMock(sourceMapping) |
| 74 { | 75 { |
| 76 mockTarget.debuggerModel = this; |
| 75 this._scripts = {}; | 77 this._scripts = {}; |
| 76 this._sourceMapping = sourceMapping; | 78 this._sourceMapping = sourceMapping; |
| 77 this._breakpoints = {}; | 79 this._breakpoints = {}; |
| 78 } | 80 } |
| 79 | 81 |
| 80 DebuggerModelMock.prototype = { | 82 DebuggerModelMock.prototype = { |
| 83 target: function() |
| 84 { |
| 85 return mockTarget; |
| 86 }, |
| 87 |
| 81 _addScript: function(scriptId, url) | 88 _addScript: function(scriptId, url) |
| 82 { | 89 { |
| 83 this._scripts[scriptId] = new WebInspector.Script(scriptId, url); | 90 this._scripts[scriptId] = new WebInspector.Script(mockTarget, script
Id, url); |
| 84 this._scripts[scriptId].pushSourceMapping(this._sourceMapping); | 91 this._scripts[scriptId].pushSourceMapping(this._sourceMapping); |
| 85 }, | 92 }, |
| 86 | 93 |
| 87 _scriptForURL: function(url) | 94 _scriptForURL: function(url) |
| 88 { | 95 { |
| 89 for (var scriptId in this._scripts) { | 96 for (var scriptId in this._scripts) { |
| 90 var script = this._scripts[scriptId]; | 97 var script = this._scripts[scriptId]; |
| 91 if (script.sourceURL === url) | 98 if (script.sourceURL === url) |
| 92 return script; | 99 return script; |
| 93 } | 100 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 116 var breakpointId = url + ":" + lineNumber; | 123 var breakpointId = url + ":" + lineNumber; |
| 117 if (this._breakpoints[breakpointId]) { | 124 if (this._breakpoints[breakpointId]) { |
| 118 this._scheduleSetBeakpointCallback(callback, null); | 125 this._scheduleSetBeakpointCallback(callback, null); |
| 119 return; | 126 return; |
| 120 } | 127 } |
| 121 this._breakpoints[breakpointId] = true; | 128 this._breakpoints[breakpointId] = true; |
| 122 | 129 |
| 123 var locations = []; | 130 var locations = []; |
| 124 var script = this._scriptForURL(url); | 131 var script = this._scriptForURL(url); |
| 125 if (script) { | 132 if (script) { |
| 126 var location = new WebInspector.DebuggerModel.Location(script.sc
riptId, lineNumber, 0); | 133 var location = new WebInspector.DebuggerModel.Location(mockTarge
t, script.scriptId, lineNumber, 0); |
| 127 locations.push(location); | 134 locations.push(location); |
| 128 } | 135 } |
| 129 | 136 |
| 130 this._scheduleSetBeakpointCallback(callback, breakpointId, locations
); | 137 this._scheduleSetBeakpointCallback(callback, breakpointId, locations
); |
| 131 }, | 138 }, |
| 132 | 139 |
| 133 setBreakpointByScriptLocation: function(location, condition, callback) | 140 setBreakpointByScriptLocation: function(location, condition, callback) |
| 134 { | 141 { |
| 135 InspectorTest.addResult(" debuggerModel.setBreakpoint(" + [locati
on.scriptId, location.lineNumber, condition].join(":") + ")"); | 142 InspectorTest.addResult(" debuggerModel.setBreakpoint(" + [locati
on.scriptId, location.lineNumber, condition].join(":") + ")"); |
| 136 | 143 |
| 137 var breakpointId = location.scriptId + ":" + location.lineNumber; | 144 var breakpointId = location.scriptId + ":" + location.lineNumber; |
| 138 if (this._breakpoints[breakpointId]) { | 145 if (this._breakpoints[breakpointId]) { |
| 139 this._scheduleSetBeakpointCallback(callback, null); | 146 this._scheduleSetBeakpointCallback(callback, null); |
| 140 return; | 147 return; |
| 141 } | 148 } |
| 142 this._breakpoints[breakpointId] = true; | 149 this._breakpoints[breakpointId] = true; |
| 143 | 150 |
| 144 if (location.lineNumber >= 2000) { | 151 if (location.lineNumber >= 2000) { |
| 145 this._scheduleSetBeakpointCallback(callback, breakpointId, []); | 152 this._scheduleSetBeakpointCallback(callback, breakpointId, []); |
| 146 return; | 153 return; |
| 147 } | 154 } |
| 148 if (location.lineNumber >= 1000) { | 155 if (location.lineNumber >= 1000) { |
| 149 var shiftedLocation = {scriptId: location.scriptId, lineNumber:
location.lineNumber + 10, columnNumber: location.columnNumber }; | 156 var shiftedLocation = new WebInspector.DebuggerModel.Location(mo
ckTarget, location.scriptId, location.lineNumber + 10, location.columnNumber); |
| 150 this._scheduleSetBeakpointCallback(callback, breakpointId, [shif
tedLocation]); | 157 this._scheduleSetBeakpointCallback(callback, breakpointId, [shif
tedLocation]); |
| 151 return; | 158 return; |
| 152 } | 159 } |
| 153 | 160 |
| 154 this._scheduleSetBeakpointCallback(callback, breakpointId, [location
]); | 161 this._scheduleSetBeakpointCallback(callback, breakpointId, [WebInspe
ctor.DebuggerModel.Location.fromPayload(mockTarget, location)]); |
| 155 }, | 162 }, |
| 156 | 163 |
| 157 removeBreakpoint: function(breakpointId, callback) | 164 removeBreakpoint: function(breakpointId, callback) |
| 158 { | 165 { |
| 159 InspectorTest.addResult(" debuggerModel.removeBreakpoint(" + brea
kpointId + ")"); | 166 InspectorTest.addResult(" debuggerModel.removeBreakpoint(" + brea
kpointId + ")"); |
| 160 delete this._breakpoints[breakpointId]; | 167 delete this._breakpoints[breakpointId]; |
| 161 if (callback) | 168 if (callback) |
| 162 callback(); | 169 callback(); |
| 163 }, | 170 }, |
| 164 | 171 |
| 165 setBreakpointsActive: function() { }, | 172 setBreakpointsActive: function() { }, |
| 166 | 173 |
| 167 createLiveLocation: function(rawLocation, updateDelegate) | 174 createLiveLocation: function(rawLocation, updateDelegate) |
| 168 { | 175 { |
| 169 return this._scripts[rawLocation.scriptId].createLiveLocation(rawLo
cation, updateDelegate); | 176 return this._scripts[rawLocation.scriptId].createLiveLocation(rawLoc
ation, updateDelegate); |
| 170 }, | 177 }, |
| 171 | 178 |
| 172 scriptForId: function(scriptId) | 179 scriptForId: function(scriptId) |
| 173 { | 180 { |
| 174 return this._scripts[scriptId]; | 181 return this._scripts[scriptId]; |
| 175 }, | 182 }, |
| 176 | 183 |
| 177 reset: function() | 184 reset: function() |
| 178 { | 185 { |
| 179 InspectorTest.addResult(" Resetting debugger."); | 186 InspectorTest.addResult(" Resetting debugger."); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 577 } |
| 571 | 578 |
| 572 function step3() | 579 function step3() |
| 573 { | 580 { |
| 574 dumpBreakpointLocations(breakpointManager); | 581 dumpBreakpointLocations(breakpointManager); |
| 575 InspectorTest.addResult("\n Navigating back to A."); | 582 InspectorTest.addResult("\n Navigating back to A."); |
| 576 breakpointManager._debuggerModel.reset(); | 583 breakpointManager._debuggerModel.reset(); |
| 577 resetWorkspace(breakpointManager); | 584 resetWorkspace(breakpointManager); |
| 578 InspectorTest.addResult(" Resolving provisional breakpoint."); | 585 InspectorTest.addResult(" Resolving provisional breakpoint."); |
| 579 addTemporaryUISourceCode(breakpointManager, "a.js"); | 586 addTemporaryUISourceCode(breakpointManager, "a.js"); |
| 580 var eventData = { breakpointId: "a.js:10", location: { scriptId:
"a.js", lineNumber: 11, columnNumber: 5 }}; | 587 var eventData = { breakpointId: "a.js:10", location: new WebInsp
ector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)}; |
| 581 breakpointManager._debuggerModel.dispatchEventToListeners(WebIns
pector.DebuggerModel.Events.BreakpointResolved, eventData); | 588 breakpointManager._debuggerModel.dispatchEventToListeners(WebIns
pector.DebuggerModel.Events.BreakpointResolved, eventData); |
| 582 addUISourceCode(breakpointManager, "a.js"); | 589 addUISourceCode(breakpointManager, "a.js"); |
| 583 window.setBreakpointCallback = step4.bind(this); | 590 window.setBreakpointCallback = step4.bind(this); |
| 584 } | 591 } |
| 585 | 592 |
| 586 function step4() | 593 function step4() |
| 587 { | 594 { |
| 588 dumpBreakpointLocations(breakpointManager); | 595 dumpBreakpointLocations(breakpointManager); |
| 589 resetBreakpointManager(breakpointManager, step5); | 596 resetBreakpointManager(breakpointManager, step5); |
| 590 } | 597 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | 647 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); |
| 641 window.setBreakpointCallback = step2.bind(this); | 648 window.setBreakpointCallback = step2.bind(this); |
| 642 | 649 |
| 643 function step2() | 650 function step2() |
| 644 { | 651 { |
| 645 dumpBreakpointLocations(breakpointManager); | 652 dumpBreakpointLocations(breakpointManager); |
| 646 breakpointManager._debuggerModel.reset(); | 653 breakpointManager._debuggerModel.reset(); |
| 647 resetWorkspace(breakpointManager); | 654 resetWorkspace(breakpointManager); |
| 648 InspectorTest.addResult(" Resolving provisional breakpoint."); | 655 InspectorTest.addResult(" Resolving provisional breakpoint."); |
| 649 addTemporaryUISourceCode(breakpointManager, "a.js") | 656 addTemporaryUISourceCode(breakpointManager, "a.js") |
| 650 var eventData = { breakpointId: "a.js:10", location: { scriptId:
"a.js", lineNumber: 11, columnNumber: 5 }}; | 657 var eventData = { breakpointId: "a.js:10", location: new WebInsp
ector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)}; |
| 651 breakpointManager._debuggerModel.dispatchEventToListeners(WebIns
pector.DebuggerModel.Events.BreakpointResolved, eventData); | 658 breakpointManager._debuggerModel.dispatchEventToListeners(WebIns
pector.DebuggerModel.Events.BreakpointResolved, eventData); |
| 652 var breakpoints = breakpointManager.allBreakpoints(); | 659 var breakpoints = breakpointManager.allBreakpoints(); |
| 653 InspectorTest.assertEquals(breakpoints.length, 1, "Exactly one p
rovisional breakpoint should be registered in breakpoint manager."); | 660 InspectorTest.assertEquals(breakpoints.length, 1, "Exactly one p
rovisional breakpoint should be registered in breakpoint manager."); |
| 654 dumpBreakpointLocations(breakpointManager); | 661 dumpBreakpointLocations(breakpointManager); |
| 655 resetBreakpointManager(breakpointManager, step3); | 662 resetBreakpointManager(breakpointManager, step3); |
| 656 } | 663 } |
| 657 | 664 |
| 658 function step3() | 665 function step3() |
| 659 { | 666 { |
| 660 dumpBreakpointLocations(breakpointManager); | 667 dumpBreakpointLocations(breakpointManager); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 684 | 691 |
| 685 function step2() | 692 function step2() |
| 686 { | 693 { |
| 687 dumpBreakpointLocations(breakpointManager); | 694 dumpBreakpointLocations(breakpointManager); |
| 688 InspectorTest.addResult("\n Reloading:"); | 695 InspectorTest.addResult("\n Reloading:"); |
| 689 breakpointManager._debuggerModel.reset(); | 696 breakpointManager._debuggerModel.reset(); |
| 690 resetWorkspace(breakpointManager); | 697 resetWorkspace(breakpointManager); |
| 691 | 698 |
| 692 InspectorTest.addResult("\n Adding files:"); | 699 InspectorTest.addResult("\n Adding files:"); |
| 693 addTemporaryUISourceCode(breakpointManager, "a.js"); | 700 addTemporaryUISourceCode(breakpointManager, "a.js"); |
| 694 var eventData = { breakpointId: "a.js:10", location: { scriptId:
"a.js", lineNumber: 10, columnNumber: 5 }}; | 701 var eventData = { breakpointId: "a.js:10", location: new WebInsp
ector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)}; |
| 695 breakpointManager._debuggerModel.dispatchEventToListeners(WebIns
pector.DebuggerModel.Events.BreakpointResolved, eventData); | 702 breakpointManager._debuggerModel.dispatchEventToListeners(WebIns
pector.DebuggerModel.Events.BreakpointResolved, eventData); |
| 696 uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); | 703 uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); |
| 697 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true,
true); | 704 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true,
true); |
| 698 | 705 |
| 699 InspectorTest.addResult("\n Toggling source mapping."); | 706 InspectorTest.addResult("\n Toggling source mapping."); |
| 700 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceC
odeB); | 707 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceC
odeB); |
| 701 breakpointManager._debuggerModel.pushSourceMapping(sourceMapping
); | 708 breakpointManager._debuggerModel.pushSourceMapping(sourceMapping
); |
| 702 window.setBreakpointCallback = provisionalBreakpointSetAfterRelo
ad.bind(this); | 709 window.setBreakpointCallback = provisionalBreakpointSetAfterRelo
ad.bind(this); |
| 703 uiSourceCodeB.setSourceMapping(sourceMapping); | 710 uiSourceCodeB.setSourceMapping(sourceMapping); |
| 704 } | 711 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 735 { | 742 { |
| 736 dumpBreakpointLocations(breakpointManager); | 743 dumpBreakpointLocations(breakpointManager); |
| 737 InspectorTest.addResult("\n Reloading:"); | 744 InspectorTest.addResult("\n Reloading:"); |
| 738 breakpointManager._debuggerModel.reset(); | 745 breakpointManager._debuggerModel.reset(); |
| 739 resetWorkspace(breakpointManager); | 746 resetWorkspace(breakpointManager); |
| 740 | 747 |
| 741 InspectorTest.addResult("\n Adding file with script:"); | 748 InspectorTest.addResult("\n Adding file with script:"); |
| 742 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | 749 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); |
| 743 | 750 |
| 744 InspectorTest.addResult("\n Emulating breakpoint resolved event
:"); | 751 InspectorTest.addResult("\n Emulating breakpoint resolved event
:"); |
| 745 var eventData = { breakpointId: "a.js:10", location: { scriptId:
"a.js", lineNumber: 10, columnNumber: 5 }}; | 752 var eventData = { breakpointId: "a.js:10", location: new WebInsp
ector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)}; |
| 746 breakpointManager._debuggerModel.dispatchEventToListeners(WebIns
pector.DebuggerModel.Events.BreakpointResolved, eventData); | 753 breakpointManager._debuggerModel.dispatchEventToListeners(WebIns
pector.DebuggerModel.Events.BreakpointResolved, eventData); |
| 747 | 754 |
| 748 InspectorTest.addResult("\n Waiting for breakpoint to be set in
debugger again:"); | 755 InspectorTest.addResult("\n Waiting for breakpoint to be set in
debugger again:"); |
| 749 window.setBreakpointCallback = step3.bind(this); | 756 window.setBreakpointCallback = step3.bind(this); |
| 750 } | 757 } |
| 751 | 758 |
| 752 function step3() | 759 function step3() |
| 753 { | 760 { |
| 754 dumpBreakpointLocations(breakpointManager); | 761 dumpBreakpointLocations(breakpointManager); |
| 755 resetBreakpointManager(breakpointManager, step4); | 762 resetBreakpointManager(breakpointManager, step4); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 766 | 773 |
| 767 </script> | 774 </script> |
| 768 | 775 |
| 769 </head> | 776 </head> |
| 770 | 777 |
| 771 <body onload="runTest()"> | 778 <body onload="runTest()"> |
| 772 <p>Tests BreakpointManager class.</p> | 779 <p>Tests BreakpointManager class.</p> |
| 773 | 780 |
| 774 </body> | 781 </body> |
| 775 </html> | 782 </html> |
| OLD | NEW |