Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: LayoutTests/inspector/sources/debugger/breakpoint-manager.html

Issue 310463003: DevTools: introduce TargetBreakpoints as a presentation of breakpoint and its state within target (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address vsevik's comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/inspector/sources/debugger/breakpoint-manager-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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._breakpointResolvedEventTarget = new WebInspector.Object();
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
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 addBreakpointListener: function(breakpointId, listener, thisObject)
214 {
215 this._breakpointResolvedEventTarget.addEventListener(breakpointId, l istener, thisObject)
216 },
217
218 removeBreakpointListener: function(breakpointId, listener, thisObject)
219 {
220 this._breakpointResolvedEventTarget.removeEventListener(breakpointId , listener, thisObject);
221 },
222
223 _breakpointResolved: function(breakpointId, location)
224 {
225 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpo intId, location);
212 } 226 }
213 } 227 }
214 DebuggerModelMock.prototype.__proto__ = WebInspector.Object.prototype; 228 DebuggerModelMock.prototype.__proto__ = WebInspector.Object.prototype;
215 229
216 var dummySetting = {
217 get: function() { return []; },
218 set: function(breakpoints) { }
219 };
220
221 function resetWorkspace(breakpointManager) 230 function resetWorkspace(breakpointManager)
222 { 231 {
223 InspectorTest.addResult(" Resetting workspace."); 232 InspectorTest.addResult(" Resetting workspace.");
224 breakpointManager._networkWorkspaceBinding.reset(); 233 breakpointManager._networkWorkspaceBinding.reset();
225 breakpointManager._debuggerProjectDelegate.reset(); 234 breakpointManager._debuggerProjectDelegate.reset();
226 } 235 }
227 236
228 function breakpointAdded(event) 237 function breakpointAdded(event)
229 { 238 {
230 var breakpoint = event.data.breakpoint; 239 var breakpoint = event.data.breakpoint;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 persistentBreakpoints = persistentBreakpoints || []; 296 persistentBreakpoints = persistentBreakpoints || [];
288 var setting = { 297 var setting = {
289 get: function() { return persistentBreakpoints; }, 298 get: function() { return persistentBreakpoints; },
290 set: function(breakpoints) { persistentBreakpoints = breakpoints; } 299 set: function(breakpoints) { persistentBreakpoints = breakpoints; }
291 }; 300 };
292 301
293 var sourceMapping = sourceMapping || defaultMapping; 302 var sourceMapping = sourceMapping || defaultMapping;
294 var debuggerModel = new DebuggerModelMock(sourceMapping); 303 var debuggerModel = new DebuggerModelMock(sourceMapping);
295 workspace = new WebInspector.Workspace(); 304 workspace = new WebInspector.Workspace();
296 var breakpointManager = new WebInspector.BreakpointManager(setting, work space, targetManager); 305 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); 306 breakpointManager._networkWorkspaceBinding = new WebInspector.NetworkWor kspaceBinding(workspace);
300 breakpointManager._debuggerProjectDelegate = new WebInspector.DebuggerPr ojectDelegate(workspace, "debugger:", WebInspector.projectTypes.Debugger); 307 breakpointManager._debuggerProjectDelegate = new WebInspector.DebuggerPr ojectDelegate(workspace, "debugger:", WebInspector.projectTypes.Debugger);
301 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events .BreakpointAdded, breakpointAdded); 308 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events .BreakpointAdded, breakpointAdded);
302 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events .BreakpointRemoved, breakpointRemoved); 309 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events .BreakpointRemoved, breakpointRemoved);
303 InspectorTest.addResult(" Created breakpoints manager"); 310 InspectorTest.addResult(" Created breakpoints manager");
304 dumpBreakpointStorage(breakpointManager); 311 dumpBreakpointStorage(breakpointManager);
305 return breakpointManager; 312 return breakpointManager;
306 } 313 }
307 314
308 function setBreakpoint(breakpointManager, uiSourceCode, lineNumber, columnNu mber, condition, enabled) 315 function setBreakpoint(breakpointManager, uiSourceCode, lineNumber, columnNu mber, condition, enabled)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } 358 }
352 if (lastUISourceCode) 359 if (lastUISourceCode)
353 dumpLocations(lastUISourceCode, locations); 360 dumpLocations(lastUISourceCode, locations);
354 } 361 }
355 362
356 function resetBreakpointManager(breakpointManager, next) 363 function resetBreakpointManager(breakpointManager, next)
357 { 364 {
358 dumpBreakpointStorage(breakpointManager); 365 dumpBreakpointStorage(breakpointManager);
359 InspectorTest.addResult(" Resetting breakpoint manager"); 366 InspectorTest.addResult(" Resetting breakpoint manager");
360 breakpointManager.removeAllBreakpoints(); 367 breakpointManager.removeAllBreakpoints();
361 breakpointManager.removeProvisionalBreakpointsForTest(mockTarget); 368 breakpointManager.removeProvisionalBreakpointsForTest();
362 uiSourceCodes = {}; 369 uiSourceCodes = {};
363 next(); 370 next();
364 } 371 }
365 372
366 InspectorTest.runTestSuite([ 373 InspectorTest.runTestSuite([
367 function testSetBreakpoint(next) 374 function testSetBreakpoint(next)
368 { 375 {
369 var breakpointManager = createBreakpointManager(); 376 var breakpointManager = createBreakpointManager();
370 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); 377 var uiSourceCode = addUISourceCode(breakpointManager, "a.js");
371 setBreakpoint(breakpointManager, uiSourceCode, 30, 0, "", true); 378 setBreakpoint(breakpointManager, uiSourceCode, 30, 0, "", true);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 597 }
591 598
592 function step3() 599 function step3()
593 { 600 {
594 dumpBreakpointLocations(breakpointManager); 601 dumpBreakpointLocations(breakpointManager);
595 InspectorTest.addResult("\n Navigating back to A."); 602 InspectorTest.addResult("\n Navigating back to A.");
596 mockTarget.debuggerModel.reset(); 603 mockTarget.debuggerModel.reset();
597 resetWorkspace(breakpointManager); 604 resetWorkspace(breakpointManager);
598 InspectorTest.addResult(" Resolving provisional breakpoint."); 605 InspectorTest.addResult(" Resolving provisional breakpoint.");
599 addTemporaryUISourceCode(breakpointManager, "a.js"); 606 addTemporaryUISourceCode(breakpointManager, "a.js");
600 var eventData = { breakpointId: "a.js:10", location: new WebInsp ector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)}; 607 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"); 608 addUISourceCode(breakpointManager, "a.js");
603 window.setBreakpointCallback = step4.bind(this); 609 window.setBreakpointCallback = step4.bind(this);
604 } 610 }
605 611
606 function step4() 612 function step4()
607 { 613 {
608 dumpBreakpointLocations(breakpointManager); 614 dumpBreakpointLocations(breakpointManager);
609 resetBreakpointManager(breakpointManager, step5); 615 resetBreakpointManager(breakpointManager, step5);
610 } 616 }
611 617
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 var breakpointManager = createBreakpointManager(serializedBreakpoint s); 665 var breakpointManager = createBreakpointManager(serializedBreakpoint s);
660 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); 666 var uiSourceCode = addUISourceCode(breakpointManager, "a.js");
661 window.setBreakpointCallback = step2.bind(this); 667 window.setBreakpointCallback = step2.bind(this);
662 668
663 function step2() 669 function step2()
664 { 670 {
665 dumpBreakpointLocations(breakpointManager); 671 dumpBreakpointLocations(breakpointManager);
666 mockTarget.debuggerModel.reset(); 672 mockTarget.debuggerModel.reset();
667 resetWorkspace(breakpointManager); 673 resetWorkspace(breakpointManager);
668 InspectorTest.addResult(" Resolving provisional breakpoint."); 674 InspectorTest.addResult(" Resolving provisional breakpoint.");
669 addTemporaryUISourceCode(breakpointManager, "a.js") 675 addTemporaryUISourceCode(breakpointManager, "a.js");
670 var eventData = { breakpointId: "a.js:10", location: new WebInsp ector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)}; 676 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(); 677 var breakpoints = breakpointManager.allBreakpoints();
673 InspectorTest.assertEquals(breakpoints.length, 1, "Exactly one p rovisional breakpoint should be registered in breakpoint manager."); 678 InspectorTest.assertEquals(breakpoints.length, 1, "Exactly one p rovisional breakpoint should be registered in breakpoint manager.");
674 dumpBreakpointLocations(breakpointManager); 679 dumpBreakpointLocations(breakpointManager);
675 resetBreakpointManager(breakpointManager, step3); 680 resetBreakpointManager(breakpointManager, step3);
676 } 681 }
677 682
678 function step3() 683 function step3()
679 { 684 {
680 dumpBreakpointLocations(breakpointManager); 685 dumpBreakpointLocations(breakpointManager);
681 next(); 686 next();
(...skipping 22 matching lines...) Expand all
704 709
705 function step2() 710 function step2()
706 { 711 {
707 dumpBreakpointLocations(breakpointManager); 712 dumpBreakpointLocations(breakpointManager);
708 InspectorTest.addResult("\n Reloading:"); 713 InspectorTest.addResult("\n Reloading:");
709 mockTarget.debuggerModel.reset(); 714 mockTarget.debuggerModel.reset();
710 resetWorkspace(breakpointManager); 715 resetWorkspace(breakpointManager);
711 716
712 InspectorTest.addResult("\n Adding files:"); 717 InspectorTest.addResult("\n Adding files:");
713 addTemporaryUISourceCode(breakpointManager, "a.js"); 718 addTemporaryUISourceCode(breakpointManager, "a.js");
714 var eventData = { breakpointId: "a.js:10", location: new WebInsp ector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)}; 719 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"); 720 uiSourceCodeA = addUISourceCode(breakpointManager, "a.js");
717 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true, true); 721 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true, true);
718 722
719 InspectorTest.addResult("\n Toggling source mapping."); 723 InspectorTest.addResult("\n Toggling source mapping.");
720 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceC odeB); 724 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceC odeB);
721 mockTarget.debuggerModel.pushSourceMapping(sourceMapping); 725 mockTarget.debuggerModel.pushSourceMapping(sourceMapping);
722 window.setBreakpointCallback = provisionalBreakpointSetAfterRelo ad.bind(this); 726 window.setBreakpointCallback = provisionalBreakpointSetAfterRelo ad.bind(this);
723 uiSourceCodeB.setSourceMappingForTarget(mockTarget, sourceMappin g); 727 uiSourceCodeB.setSourceMappingForTarget(mockTarget, sourceMappin g);
724 } 728 }
725 729
(...skipping 29 matching lines...) Expand all
755 { 759 {
756 dumpBreakpointLocations(breakpointManager); 760 dumpBreakpointLocations(breakpointManager);
757 InspectorTest.addResult("\n Reloading:"); 761 InspectorTest.addResult("\n Reloading:");
758 mockTarget.debuggerModel.reset(); 762 mockTarget.debuggerModel.reset();
759 resetWorkspace(breakpointManager); 763 resetWorkspace(breakpointManager);
760 764
761 InspectorTest.addResult("\n Adding file with script:"); 765 InspectorTest.addResult("\n Adding file with script:");
762 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); 766 var uiSourceCode = addUISourceCode(breakpointManager, "a.js");
763 767
764 InspectorTest.addResult("\n Emulating breakpoint resolved event :"); 768 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)}; 769 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 770
768 InspectorTest.addResult("\n Waiting for breakpoint to be set in debugger again:"); 771 InspectorTest.addResult("\n Waiting for breakpoint to be set in debugger again:");
769 window.setBreakpointCallback = step3.bind(this); 772 window.setBreakpointCallback = step3.bind(this);
770 } 773 }
771 774
772 function step3() 775 function step3()
773 { 776 {
774 dumpBreakpointLocations(breakpointManager); 777 dumpBreakpointLocations(breakpointManager);
775 resetBreakpointManager(breakpointManager, step4); 778 resetBreakpointManager(breakpointManager, step4);
776 } 779 }
777 780
778 function step4() 781 function step4()
779 { 782 {
780 dumpBreakpointLocations(breakpointManager); 783 dumpBreakpointLocations(breakpointManager);
781 next(); 784 next();
782 } 785 }
783 }, 786 },
784 ]); 787 ]);
785 }; 788 };
786 789
787 </script> 790 </script>
788 791
789 </head> 792 </head>
790 793
791 <body onload="runTest()"> 794 <body onload="runTest()">
792 <p>Tests BreakpointManager class.</p> 795 <p>Tests BreakpointManager class.</p>
793 796
794 </body> 797 </body>
795 </html> 798 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/inspector/sources/debugger/breakpoint-manager-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698