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 workspace; | 9 var workspace; |
10 var uiSourceCodes = {}; | 10 var uiSourceCodes = {}; |
11 var mockTarget = { | 11 var mockTarget = { |
12 | 12 |
13 id: function() | 13 id: function() |
14 { | 14 { |
15 return 1; | 15 return 1; |
16 } | 16 } |
17 }; | 17 }; |
18 var targetManager = { | 18 var targetManager = new WebInspector.TargetManager(); |
19 targets: function () { return [mockTarget]}, | 19 targetManager._targets.push(mockTarget); |
20 observeTargets: function() {} | |
21 } | |
22 | 20 |
23 var defaultMapping = { | 21 var defaultMapping = { |
24 rawLocationToUILocation: function(rawLocation) | 22 rawLocationToUILocation: function(rawLocation) |
25 { | 23 { |
26 return uiSourceCodes[rawLocation.scriptId].uiLocation(rawLocation.li
neNumber, 0); | 24 return uiSourceCodes[rawLocation.scriptId].uiLocation(rawLocation.li
neNumber, 0); |
27 }, | 25 }, |
28 | 26 |
29 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | 27 uiLocationToRawLocation: function(uiSourceCode, lineNumber) |
30 { | 28 { |
31 if (!uiSourceCodes[uiSourceCode.url]) | 29 if (!uiSourceCodes[uiSourceCode.url]) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 return false; | 76 return false; |
79 } | 77 } |
80 }; | 78 }; |
81 | 79 |
82 return mapping; | 80 return mapping; |
83 } | 81 } |
84 | 82 |
85 function DebuggerModelMock(sourceMapping) | 83 function DebuggerModelMock(sourceMapping) |
86 { | 84 { |
87 mockTarget.debuggerModel = this; | 85 mockTarget.debuggerModel = this; |
| 86 this._breakpointListenerById = new StringMap(); |
88 this._scripts = {}; | 87 this._scripts = {}; |
89 this._sourceMapping = sourceMapping; | 88 this._sourceMapping = sourceMapping; |
90 this._breakpoints = {}; | 89 this._breakpoints = {}; |
91 } | 90 } |
92 | 91 |
93 DebuggerModelMock.prototype = { | 92 DebuggerModelMock.prototype = { |
94 target: function() | 93 target: function() |
95 { | 94 { |
96 return mockTarget; | 95 return mockTarget; |
97 }, | 96 }, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 { | 201 { |
203 for (var scriptId in this._scripts) | 202 for (var scriptId in this._scripts) |
204 this._scripts[scriptId].pushSourceMapping(sourceMapping); | 203 this._scripts[scriptId].pushSourceMapping(sourceMapping); |
205 }, | 204 }, |
206 | 205 |
207 disableSourceMapping: function(sourceMapping) | 206 disableSourceMapping: function(sourceMapping) |
208 { | 207 { |
209 sourceMapping._disabled = true; | 208 sourceMapping._disabled = true; |
210 for (var scriptId in this._scripts) | 209 for (var scriptId in this._scripts) |
211 this._scripts[scriptId].updateLocations(); | 210 this._scripts[scriptId].updateLocations(); |
| 211 }, |
| 212 |
| 213 registerBreakpointListenerForId: function(breakpointId, listener) |
| 214 { |
| 215 this._breakpointListenerById.put(breakpointId, listener); |
| 216 }, |
| 217 |
| 218 unregisterBreakpointListenerForId: function(breakpointId) |
| 219 { |
| 220 this._breakpointListenerById.remove(breakpointId); |
| 221 }, |
| 222 |
| 223 _breakpointResolved: function(breakpointId, location) |
| 224 { |
| 225 var breakpointListener = this._breakpointListenerById.get(breakpoint
Id); |
| 226 if (breakpointListener) |
| 227 breakpointListener.breakpointResolved(location) |
212 } | 228 } |
213 } | 229 } |
214 DebuggerModelMock.prototype.__proto__ = WebInspector.Object.prototype; | 230 DebuggerModelMock.prototype.__proto__ = WebInspector.Object.prototype; |
215 | 231 |
216 var dummySetting = { | |
217 get: function() { return []; }, | |
218 set: function(breakpoints) { } | |
219 }; | |
220 | |
221 function resetWorkspace(breakpointManager) | 232 function resetWorkspace(breakpointManager) |
222 { | 233 { |
223 InspectorTest.addResult(" Resetting workspace."); | 234 InspectorTest.addResult(" Resetting workspace."); |
224 breakpointManager._networkWorkspaceBinding.reset(); | 235 breakpointManager._networkWorkspaceBinding.reset(); |
225 breakpointManager._debuggerProjectDelegate.reset(); | 236 breakpointManager._debuggerProjectDelegate.reset(); |
226 } | 237 } |
227 | 238 |
228 function breakpointAdded(event) | 239 function breakpointAdded(event) |
229 { | 240 { |
230 var breakpoint = event.data.breakpoint; | 241 var breakpoint = event.data.breakpoint; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 persistentBreakpoints = persistentBreakpoints || []; | 298 persistentBreakpoints = persistentBreakpoints || []; |
288 var setting = { | 299 var setting = { |
289 get: function() { return persistentBreakpoints; }, | 300 get: function() { return persistentBreakpoints; }, |
290 set: function(breakpoints) { persistentBreakpoints = breakpoints; } | 301 set: function(breakpoints) { persistentBreakpoints = breakpoints; } |
291 }; | 302 }; |
292 | 303 |
293 var sourceMapping = sourceMapping || defaultMapping; | 304 var sourceMapping = sourceMapping || defaultMapping; |
294 var debuggerModel = new DebuggerModelMock(sourceMapping); | 305 var debuggerModel = new DebuggerModelMock(sourceMapping); |
295 workspace = new WebInspector.Workspace(); | 306 workspace = new WebInspector.Workspace(); |
296 var breakpointManager = new WebInspector.BreakpointManager(setting, work
space, targetManager); | 307 var breakpointManager = new WebInspector.BreakpointManager(setting, work
space, targetManager); |
297 mockTarget.debuggerModel = debuggerModel; | |
298 breakpointManager.targetAdded(mockTarget); | |
299 breakpointManager._networkWorkspaceBinding = new WebInspector.NetworkWor
kspaceBinding(workspace); | 308 breakpointManager._networkWorkspaceBinding = new WebInspector.NetworkWor
kspaceBinding(workspace); |
300 breakpointManager._debuggerProjectDelegate = new WebInspector.DebuggerPr
ojectDelegate(workspace, "debugger:", WebInspector.projectTypes.Debugger); | 309 breakpointManager._debuggerProjectDelegate = new WebInspector.DebuggerPr
ojectDelegate(workspace, "debugger:", WebInspector.projectTypes.Debugger); |
301 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events
.BreakpointAdded, breakpointAdded); | 310 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events
.BreakpointAdded, breakpointAdded); |
302 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events
.BreakpointRemoved, breakpointRemoved); | 311 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events
.BreakpointRemoved, breakpointRemoved); |
303 InspectorTest.addResult(" Created breakpoints manager"); | 312 InspectorTest.addResult(" Created breakpoints manager"); |
304 dumpBreakpointStorage(breakpointManager); | 313 dumpBreakpointStorage(breakpointManager); |
305 return breakpointManager; | 314 return breakpointManager; |
306 } | 315 } |
307 | 316 |
308 function setBreakpoint(breakpointManager, uiSourceCode, lineNumber, columnNu
mber, condition, enabled) | 317 function setBreakpoint(breakpointManager, uiSourceCode, lineNumber, columnNu
mber, condition, enabled) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 360 } |
352 if (lastUISourceCode) | 361 if (lastUISourceCode) |
353 dumpLocations(lastUISourceCode, locations); | 362 dumpLocations(lastUISourceCode, locations); |
354 } | 363 } |
355 | 364 |
356 function resetBreakpointManager(breakpointManager, next) | 365 function resetBreakpointManager(breakpointManager, next) |
357 { | 366 { |
358 dumpBreakpointStorage(breakpointManager); | 367 dumpBreakpointStorage(breakpointManager); |
359 InspectorTest.addResult(" Resetting breakpoint manager"); | 368 InspectorTest.addResult(" Resetting breakpoint manager"); |
360 breakpointManager.removeAllBreakpoints(); | 369 breakpointManager.removeAllBreakpoints(); |
361 breakpointManager.removeProvisionalBreakpointsForTest(mockTarget); | 370 breakpointManager.removeProvisionalBreakpointsForTest(); |
362 uiSourceCodes = {}; | 371 uiSourceCodes = {}; |
363 next(); | 372 next(); |
364 } | 373 } |
365 | 374 |
366 InspectorTest.runTestSuite([ | 375 InspectorTest.runTestSuite([ |
367 function testSetBreakpoint(next) | 376 function testSetBreakpoint(next) |
368 { | 377 { |
369 var breakpointManager = createBreakpointManager(); | 378 var breakpointManager = createBreakpointManager(); |
370 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | 379 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); |
371 setBreakpoint(breakpointManager, uiSourceCode, 30, 0, "", true); | 380 setBreakpoint(breakpointManager, uiSourceCode, 30, 0, "", true); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 } | 599 } |
591 | 600 |
592 function step3() | 601 function step3() |
593 { | 602 { |
594 dumpBreakpointLocations(breakpointManager); | 603 dumpBreakpointLocations(breakpointManager); |
595 InspectorTest.addResult("\n Navigating back to A."); | 604 InspectorTest.addResult("\n Navigating back to A."); |
596 mockTarget.debuggerModel.reset(); | 605 mockTarget.debuggerModel.reset(); |
597 resetWorkspace(breakpointManager); | 606 resetWorkspace(breakpointManager); |
598 InspectorTest.addResult(" Resolving provisional breakpoint."); | 607 InspectorTest.addResult(" Resolving provisional breakpoint."); |
599 addTemporaryUISourceCode(breakpointManager, "a.js"); | 608 addTemporaryUISourceCode(breakpointManager, "a.js"); |
600 var eventData = { breakpointId: "a.js:10", location: new WebInsp
ector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)}; | 609 mockTarget.debuggerModel._breakpointResolved("a.js:10", new WebI
nspector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)); |
601 mockTarget.debuggerModel.dispatchEventToListeners(WebInspector.D
ebuggerModel.Events.BreakpointResolved, eventData); | |
602 addUISourceCode(breakpointManager, "a.js"); | 610 addUISourceCode(breakpointManager, "a.js"); |
603 window.setBreakpointCallback = step4.bind(this); | 611 window.setBreakpointCallback = step4.bind(this); |
604 } | 612 } |
605 | 613 |
606 function step4() | 614 function step4() |
607 { | 615 { |
608 dumpBreakpointLocations(breakpointManager); | 616 dumpBreakpointLocations(breakpointManager); |
609 resetBreakpointManager(breakpointManager, step5); | 617 resetBreakpointManager(breakpointManager, step5); |
610 } | 618 } |
611 | 619 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); | 667 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); |
660 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | 668 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); |
661 window.setBreakpointCallback = step2.bind(this); | 669 window.setBreakpointCallback = step2.bind(this); |
662 | 670 |
663 function step2() | 671 function step2() |
664 { | 672 { |
665 dumpBreakpointLocations(breakpointManager); | 673 dumpBreakpointLocations(breakpointManager); |
666 mockTarget.debuggerModel.reset(); | 674 mockTarget.debuggerModel.reset(); |
667 resetWorkspace(breakpointManager); | 675 resetWorkspace(breakpointManager); |
668 InspectorTest.addResult(" Resolving provisional breakpoint."); | 676 InspectorTest.addResult(" Resolving provisional breakpoint."); |
669 addTemporaryUISourceCode(breakpointManager, "a.js") | 677 addTemporaryUISourceCode(breakpointManager, "a.js"); |
670 var eventData = { breakpointId: "a.js:10", location: new WebInsp
ector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)}; | 678 mockTarget.debuggerModel._breakpointResolved("a.js:10", new WebI
nspector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)); |
671 mockTarget.debuggerModel.dispatchEventToListeners(WebInspector.D
ebuggerModel.Events.BreakpointResolved, eventData); | |
672 var breakpoints = breakpointManager.allBreakpoints(); | 679 var breakpoints = breakpointManager.allBreakpoints(); |
673 InspectorTest.assertEquals(breakpoints.length, 1, "Exactly one p
rovisional breakpoint should be registered in breakpoint manager."); | 680 InspectorTest.assertEquals(breakpoints.length, 1, "Exactly one p
rovisional breakpoint should be registered in breakpoint manager."); |
674 dumpBreakpointLocations(breakpointManager); | 681 dumpBreakpointLocations(breakpointManager); |
675 resetBreakpointManager(breakpointManager, step3); | 682 resetBreakpointManager(breakpointManager, step3); |
676 } | 683 } |
677 | 684 |
678 function step3() | 685 function step3() |
679 { | 686 { |
680 dumpBreakpointLocations(breakpointManager); | 687 dumpBreakpointLocations(breakpointManager); |
681 next(); | 688 next(); |
(...skipping 22 matching lines...) Expand all Loading... |
704 | 711 |
705 function step2() | 712 function step2() |
706 { | 713 { |
707 dumpBreakpointLocations(breakpointManager); | 714 dumpBreakpointLocations(breakpointManager); |
708 InspectorTest.addResult("\n Reloading:"); | 715 InspectorTest.addResult("\n Reloading:"); |
709 mockTarget.debuggerModel.reset(); | 716 mockTarget.debuggerModel.reset(); |
710 resetWorkspace(breakpointManager); | 717 resetWorkspace(breakpointManager); |
711 | 718 |
712 InspectorTest.addResult("\n Adding files:"); | 719 InspectorTest.addResult("\n Adding files:"); |
713 addTemporaryUISourceCode(breakpointManager, "a.js"); | 720 addTemporaryUISourceCode(breakpointManager, "a.js"); |
714 var eventData = { breakpointId: "a.js:10", location: new WebInsp
ector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)}; | 721 mockTarget.debuggerModel._breakpointResolved("a.js:10", new WebI
nspector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)); |
715 mockTarget.debuggerModel.dispatchEventToListeners(WebInspector.D
ebuggerModel.Events.BreakpointResolved, eventData); | |
716 uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); | 722 uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); |
717 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true,
true); | 723 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true,
true); |
718 | 724 |
719 InspectorTest.addResult("\n Toggling source mapping."); | 725 InspectorTest.addResult("\n Toggling source mapping."); |
720 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceC
odeB); | 726 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceC
odeB); |
721 mockTarget.debuggerModel.pushSourceMapping(sourceMapping); | 727 mockTarget.debuggerModel.pushSourceMapping(sourceMapping); |
722 window.setBreakpointCallback = provisionalBreakpointSetAfterRelo
ad.bind(this); | 728 window.setBreakpointCallback = provisionalBreakpointSetAfterRelo
ad.bind(this); |
723 uiSourceCodeB.setSourceMappingForTarget(mockTarget, sourceMappin
g); | 729 uiSourceCodeB.setSourceMappingForTarget(mockTarget, sourceMappin
g); |
724 } | 730 } |
725 | 731 |
(...skipping 29 matching lines...) Expand all Loading... |
755 { | 761 { |
756 dumpBreakpointLocations(breakpointManager); | 762 dumpBreakpointLocations(breakpointManager); |
757 InspectorTest.addResult("\n Reloading:"); | 763 InspectorTest.addResult("\n Reloading:"); |
758 mockTarget.debuggerModel.reset(); | 764 mockTarget.debuggerModel.reset(); |
759 resetWorkspace(breakpointManager); | 765 resetWorkspace(breakpointManager); |
760 | 766 |
761 InspectorTest.addResult("\n Adding file with script:"); | 767 InspectorTest.addResult("\n Adding file with script:"); |
762 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | 768 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); |
763 | 769 |
764 InspectorTest.addResult("\n Emulating breakpoint resolved event
:"); | 770 InspectorTest.addResult("\n Emulating breakpoint resolved event
:"); |
765 var eventData = { breakpointId: "a.js:10", location: new WebInsp
ector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)}; | 771 mockTarget.debuggerModel._breakpointResolved("a.js:10", new WebI
nspector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)); |
766 mockTarget.debuggerModel.dispatchEventToListeners(WebInspector.D
ebuggerModel.Events.BreakpointResolved, eventData); | |
767 | 772 |
768 InspectorTest.addResult("\n Waiting for breakpoint to be set in
debugger again:"); | 773 InspectorTest.addResult("\n Waiting for breakpoint to be set in
debugger again:"); |
769 window.setBreakpointCallback = step3.bind(this); | 774 window.setBreakpointCallback = step3.bind(this); |
770 } | 775 } |
771 | 776 |
772 function step3() | 777 function step3() |
773 { | 778 { |
774 dumpBreakpointLocations(breakpointManager); | 779 dumpBreakpointLocations(breakpointManager); |
775 resetBreakpointManager(breakpointManager, step4); | 780 resetBreakpointManager(breakpointManager, step4); |
776 } | 781 } |
777 | 782 |
778 function step4() | 783 function step4() |
779 { | 784 { |
780 dumpBreakpointLocations(breakpointManager); | 785 dumpBreakpointLocations(breakpointManager); |
781 next(); | 786 next(); |
782 } | 787 } |
783 }, | 788 }, |
784 ]); | 789 ]); |
785 }; | 790 }; |
786 | 791 |
787 </script> | 792 </script> |
788 | 793 |
789 </head> | 794 </head> |
790 | 795 |
791 <body onload="runTest()"> | 796 <body onload="runTest()"> |
792 <p>Tests BreakpointManager class.</p> | 797 <p>Tests BreakpointManager class.</p> |
793 | 798 |
794 </body> | 799 </body> |
795 </html> | 800 </html> |
OLD | NEW |