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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/sources/debugger-breakpoints/breakpoint-manager.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
OLDNEW
1 var initialize_BreakpointManagerTest = function() { 1 var initialize_BreakpointManagerTest = function() {
2 2
3 InspectorTest.uiSourceCodes = {}; 3 InspectorTest.uiSourceCodes = {};
4 4
5 InspectorTest.dumpTargetIds = false; 5 InspectorTest.dumpTargetIds = false;
6 6
7 InspectorTest.initializeDefaultMappingOnTarget = function(target) 7 InspectorTest.initializeDefaultMappingOnTarget = function(target)
8 { 8 {
9 var defaultMapping = { 9 var defaultMapping = {
10 rawLocationToUILocation: function(rawLocation) 10 rawLocationToUILocation: function(rawLocation)
11 { 11 {
12 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation( rawLocation.lineNumber, 0); 12 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation( rawLocation.lineNumber, 0);
13 }, 13 },
14 14
15 uiLocationToRawLocation: function(uiSourceCode, lineNumber) 15 uiLocationToRawLocation: function(uiSourceCode, lineNumber)
16 { 16 {
17 if (!InspectorTest.uiSourceCodes[uiSourceCode.url()]) 17 if (!InspectorTest.uiSourceCodes[uiSourceCode.url()])
18 return null; 18 return null;
19 return new WebInspector.DebuggerModel.Location(target.debuggerModel, uiSourceCode.url(), lineNumber, 0); 19 return new SDK.DebuggerModel.Location(target.debuggerModel, uiSource Code.url(), lineNumber, 0);
20 }, 20 },
21 21
22 isIdentity: function() 22 isIdentity: function()
23 { 23 {
24 return true; 24 return true;
25 } 25 }
26 }; 26 };
27 target.defaultMapping = defaultMapping; 27 target.defaultMapping = defaultMapping;
28 } 28 }
29 29
30 InspectorTest.dumpTarget = function(targetAware) 30 InspectorTest.dumpTarget = function(targetAware)
31 { 31 {
32 return InspectorTest.dumpTargetIds ? "target " + targetAware.target().id() + " " : ""; 32 return InspectorTest.dumpTargetIds ? "target " + targetAware.target().id() + " " : "";
33 } 33 }
34 34
35 InspectorTest.DebuggerModelMock = class extends WebInspector.SDKModel { 35 InspectorTest.DebuggerModelMock = class extends SDK.SDKModel {
36 constructor(target) 36 constructor(target)
37 { 37 {
38 super(WebInspector.DebuggerModel, target); 38 super(SDK.DebuggerModel, target);
39 this._breakpointResolvedEventTarget = new WebInspector.Object(); 39 this._breakpointResolvedEventTarget = new Common.Object();
40 this._scripts = {}; 40 this._scripts = {};
41 this._breakpoints = {}; 41 this._breakpoints = {};
42 this._debuggerWorkspaceBinding = InspectorTest.testDebuggerWorkspaceBind ing; 42 this._debuggerWorkspaceBinding = InspectorTest.testDebuggerWorkspaceBind ing;
43 } 43 }
44 44
45 target() 45 target()
46 { 46 {
47 return this._target; 47 return this._target;
48 } 48 }
49 49
50 _targetDisposed() { } 50 _targetDisposed() { }
51 51
52 debuggerEnabled() 52 debuggerEnabled()
53 { 53 {
54 return true; 54 return true;
55 } 55 }
56 56
57 scriptsForSourceURL(url) 57 scriptsForSourceURL(url)
58 { 58 {
59 var script = this._scriptForURL(url); 59 var script = this._scriptForURL(url);
60 return script ? [script] : []; 60 return script ? [script] : [];
61 } 61 }
62 62
63 _addScript(scriptId, url) 63 _addScript(scriptId, url)
64 { 64 {
65 var script = new WebInspector.Script(this, scriptId, url); 65 var script = new SDK.Script(this, scriptId, url);
66 this._scripts[scriptId] = script; 66 this._scripts[scriptId] = script;
67 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc riptSource({data: script}); 67 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc riptSource({data: script});
68 } 68 }
69 69
70 _registerScript(script) 70 _registerScript(script)
71 { 71 {
72 this._scripts[script.scriptId] = script; 72 this._scripts[script.scriptId] = script;
73 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc riptSource({data: script}); 73 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc riptSource({data: script});
74 } 74 }
75 75
(...skipping 17 matching lines...) Expand all
93 if (window.setBreakpointCallback) { 93 if (window.setBreakpointCallback) {
94 var savedCallback = window.setBreakpointCallback; 94 var savedCallback = window.setBreakpointCallback;
95 delete window.setBreakpointCallback; 95 delete window.setBreakpointCallback;
96 savedCallback(); 96 savedCallback();
97 } 97 }
98 } 98 }
99 } 99 }
100 100
101 createRawLocation(script, line, column) 101 createRawLocation(script, line, column)
102 { 102 {
103 return new WebInspector.DebuggerModel.Location(this, script.scriptId, li ne, column); 103 return new SDK.DebuggerModel.Location(this, script.scriptId, line, colum n);
104 } 104 }
105 105
106 setBreakpointByURL(url, lineNumber, columnNumber, condition, callback) 106 setBreakpointByURL(url, lineNumber, columnNumber, condition, callback)
107 { 107 {
108 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.setBreakpoint(" + [url, lineNumber, condition].join(":") + ")"); 108 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.setBreakpoint(" + [url, lineNumber, condition].join(":") + ")");
109 109
110 var breakpointId = url + ":" + lineNumber; 110 var breakpointId = url + ":" + lineNumber;
111 if (this._breakpoints[breakpointId]) { 111 if (this._breakpoints[breakpointId]) {
112 this._scheduleSetBeakpointCallback(callback, null); 112 this._scheduleSetBeakpointCallback(callback, null);
113 return; 113 return;
114 } 114 }
115 this._breakpoints[breakpointId] = true; 115 this._breakpoints[breakpointId] = true;
116 116
117 if (lineNumber >= 2000) { 117 if (lineNumber >= 2000) {
118 this._scheduleSetBeakpointCallback(callback, breakpointId, []); 118 this._scheduleSetBeakpointCallback(callback, breakpointId, []);
119 return; 119 return;
120 } 120 }
121 if (lineNumber >= 1000) { 121 if (lineNumber >= 1000) {
122 var shiftedLocation = new WebInspector.DebuggerModel.Location(this, url, lineNumber + 10, columnNumber); 122 var shiftedLocation = new SDK.DebuggerModel.Location(this, url, line Number + 10, columnNumber);
123 this._scheduleSetBeakpointCallback(callback, breakpointId, [shiftedL ocation]); 123 this._scheduleSetBeakpointCallback(callback, breakpointId, [shiftedL ocation]);
124 return; 124 return;
125 } 125 }
126 126
127 var locations = []; 127 var locations = [];
128 var script = this._scriptForURL(url); 128 var script = this._scriptForURL(url);
129 if (script) { 129 if (script) {
130 var location = new WebInspector.DebuggerModel.Location(this, script. scriptId, lineNumber, 0); 130 var location = new SDK.DebuggerModel.Location(this, script.scriptId, lineNumber, 0);
131 locations.push(location); 131 locations.push(location);
132 } 132 }
133 133
134 this._scheduleSetBeakpointCallback(callback, breakpointId, locations); 134 this._scheduleSetBeakpointCallback(callback, breakpointId, locations);
135 } 135 }
136 136
137 removeBreakpoint(breakpointId, callback) 137 removeBreakpoint(breakpointId, callback)
138 { 138 {
139 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.removeBreakpoint(" + breakpointId + ")"); 139 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.removeBreakpoint(" + breakpointId + ")");
140 delete this._breakpoints[breakpointId]; 140 delete this._breakpoints[breakpointId];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 _breakpointResolved(breakpointId, location) 182 _breakpointResolved(breakpointId, location)
183 { 183 {
184 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI d, location); 184 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI d, location);
185 } 185 }
186 }; 186 };
187 187
188 InspectorTest.setupLiveLocationSniffers = function() 188 InspectorTest.setupLiveLocationSniffers = function()
189 { 189 {
190 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.prototype, "c reateLiveLocation", function(rawLocation) 190 InspectorTest.addSniffer(Bindings.DebuggerWorkspaceBinding.prototype, "creat eLiveLocation", function(rawLocation)
191 { 191 {
192 InspectorTest.addResult(" Location created: " + InspectorTest.dumpTar get(rawLocation) + rawLocation.scriptId + ":" + rawLocation.lineNumber); 192 InspectorTest.addResult(" Location created: " + InspectorTest.dumpTar get(rawLocation) + rawLocation.scriptId + ":" + rawLocation.lineNumber);
193 }, true); 193 }, true);
194 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.Location.prot otype, "dispose", function() 194 InspectorTest.addSniffer(Bindings.DebuggerWorkspaceBinding.Location.prototyp e, "dispose", function()
195 { 195 {
196 InspectorTest.addResult(" Location disposed: " + InspectorTest.dumpTa rget(this._rawLocation) + this._rawLocation.scriptId + ":" + this._rawLocation.l ineNumber); 196 InspectorTest.addResult(" Location disposed: " + InspectorTest.dumpTa rget(this._rawLocation) + this._rawLocation.scriptId + ":" + this._rawLocation.l ineNumber);
197 }, true); 197 }, true);
198 } 198 }
199 199
200 InspectorTest.addScript = function(target, breakpointManager, url) 200 InspectorTest.addScript = function(target, breakpointManager, url)
201 { 201 {
202 target.debuggerModel._addScript(url, url); 202 target.debuggerModel._addScript(url, url);
203 InspectorTest.addResult(" Adding script: " + url); 203 InspectorTest.addResult(" Adding script: " + url);
204 var uiSourceCodes = breakpointManager._workspace.uiSourceCodesForProjectType (WebInspector.projectTypes.Debugger); 204 var uiSourceCodes = breakpointManager._workspace.uiSourceCodesForProjectType (Workspace.projectTypes.Debugger);
205 for (var i = 0; i < uiSourceCodes.length; ++i) { 205 for (var i = 0; i < uiSourceCodes.length; ++i) {
206 var uiSourceCode = uiSourceCodes[i]; 206 var uiSourceCode = uiSourceCodes[i];
207 if (uiSourceCode.url() === url) { 207 if (uiSourceCode.url() === url) {
208 breakpointManager._debuggerWorkspaceBinding.setSourceMapping(target, uiSourceCode, breakpointManager.defaultMapping); 208 breakpointManager._debuggerWorkspaceBinding.setSourceMapping(target, uiSourceCode, breakpointManager.defaultMapping);
209 InspectorTest.uiSourceCodes[url] = uiSourceCode; 209 InspectorTest.uiSourceCodes[url] = uiSourceCode;
210 return uiSourceCode; 210 return uiSourceCode;
211 } 211 }
212 } 212 }
213 } 213 }
214 214
215 InspectorTest.addUISourceCode = function(target, breakpointManager, url, doNotSe tSourceMapping, doNotAddScript) 215 InspectorTest.addUISourceCode = function(target, breakpointManager, url, doNotSe tSourceMapping, doNotAddScript)
216 { 216 {
217 if (!doNotAddScript) 217 if (!doNotAddScript)
218 InspectorTest.addScript(target, breakpointManager, url); 218 InspectorTest.addScript(target, breakpointManager, url);
219 InspectorTest.addResult(" Adding UISourceCode: " + url); 219 InspectorTest.addResult(" Adding UISourceCode: " + url);
220 var contentProvider = WebInspector.StaticContentProvider.fromString(url, Web Inspector.resourceTypes.Script, ""); 220 var contentProvider = Common.StaticContentProvider.fromString(url, Common.re sourceTypes.Script, "");
221 var binding = breakpointManager._debuggerWorkspaceBinding; 221 var binding = breakpointManager._debuggerWorkspaceBinding;
222 var uiSourceCode = InspectorTest.testNetworkProject.addFile(contentProvider, null); 222 var uiSourceCode = InspectorTest.testNetworkProject.addFile(contentProvider, null);
223 InspectorTest.uiSourceCodes[url] = uiSourceCode; 223 InspectorTest.uiSourceCodes[url] = uiSourceCode;
224 if (!doNotSetSourceMapping) { 224 if (!doNotSetSourceMapping) {
225 breakpointManager._debuggerWorkspaceBinding.setSourceMapping(target, uiS ourceCode, breakpointManager.defaultMapping); 225 breakpointManager._debuggerWorkspaceBinding.setSourceMapping(target, uiS ourceCode, breakpointManager.defaultMapping);
226 breakpointManager._debuggerWorkspaceBinding.updateLocations(target.debug gerModel.scriptForId(url)); 226 breakpointManager._debuggerWorkspaceBinding.updateLocations(target.debug gerModel.scriptForId(url));
227 } 227 }
228 return uiSourceCode; 228 return uiSourceCode;
229 } 229 }
230 230
231 InspectorTest.createBreakpointManager = function(targetManager, debuggerWorkspac eBinding, persistentBreakpoints) 231 InspectorTest.createBreakpointManager = function(targetManager, debuggerWorkspac eBinding, persistentBreakpoints)
232 { 232 {
233 InspectorTest._pendingBreakpointUpdates = 0; 233 InspectorTest._pendingBreakpointUpdates = 0;
234 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.pro totype, "_updateInDebugger", updateInDebugger, true); 234 InspectorTest.addSniffer(Bindings.BreakpointManager.TargetBreakpoint.prototy pe, "_updateInDebugger", updateInDebugger, true);
235 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.pro totype, "_didUpdateInDebugger", didUpdateInDebugger, true); 235 InspectorTest.addSniffer(Bindings.BreakpointManager.TargetBreakpoint.prototy pe, "_didUpdateInDebugger", didUpdateInDebugger, true);
236 236
237 function updateInDebugger() 237 function updateInDebugger()
238 { 238 {
239 InspectorTest._pendingBreakpointUpdates++; 239 InspectorTest._pendingBreakpointUpdates++;
240 } 240 }
241 241
242 function didUpdateInDebugger() 242 function didUpdateInDebugger()
243 { 243 {
244 InspectorTest._pendingBreakpointUpdates--; 244 InspectorTest._pendingBreakpointUpdates--;
245 InspectorTest._notifyAfterBreakpointUpdate(); 245 InspectorTest._notifyAfterBreakpointUpdate();
(...skipping 18 matching lines...) Expand all
264 InspectorTest.addResult(" breakpointRemoved(" + [uiLocation.uiSourceC ode.url(), uiLocation.lineNumber, uiLocation.columnNumber].join(", ") + ")"); 264 InspectorTest.addResult(" breakpointRemoved(" + [uiLocation.uiSourceC ode.url(), uiLocation.lineNumber, uiLocation.columnNumber].join(", ") + ")");
265 } 265 }
266 var targets = targetManager.targets(); 266 var targets = targetManager.targets();
267 var mappingForManager; 267 var mappingForManager;
268 for (var i = 0; i < targets.length; ++i) { 268 for (var i = 0; i < targets.length; ++i) {
269 InspectorTest.initializeDefaultMappingOnTarget(targets[i]); 269 InspectorTest.initializeDefaultMappingOnTarget(targets[i]);
270 if (!mappingForManager) 270 if (!mappingForManager)
271 mappingForManager = targets[i].defaultMapping; 271 mappingForManager = targets[i].defaultMapping;
272 } 272 }
273 273
274 var breakpointManager = new WebInspector.BreakpointManager(setting, debugger WorkspaceBinding._workspace, targetManager, debuggerWorkspaceBinding); 274 var breakpointManager = new Bindings.BreakpointManager(setting, debuggerWork spaceBinding._workspace, targetManager, debuggerWorkspaceBinding);
275 breakpointManager.defaultMapping = mappingForManager; 275 breakpointManager.defaultMapping = mappingForManager;
276 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.Bre akpointAdded, breakpointAdded); 276 breakpointManager.addEventListener(Bindings.BreakpointManager.Events.Breakpo intAdded, breakpointAdded);
277 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.Bre akpointRemoved, breakpointRemoved); 277 breakpointManager.addEventListener(Bindings.BreakpointManager.Events.Breakpo intRemoved, breakpointRemoved);
278 InspectorTest.addResult(" Created breakpoints manager"); 278 InspectorTest.addResult(" Created breakpoints manager");
279 InspectorTest.dumpBreakpointStorage(breakpointManager); 279 InspectorTest.dumpBreakpointStorage(breakpointManager);
280 return breakpointManager; 280 return breakpointManager;
281 } 281 }
282 282
283 InspectorTest.setBreakpoint = function(breakpointManager, uiSourceCode, lineNumb er, columnNumber, condition, enabled, setBreakpointCallback) 283 InspectorTest.setBreakpoint = function(breakpointManager, uiSourceCode, lineNumb er, columnNumber, condition, enabled, setBreakpointCallback)
284 { 284 {
285 InspectorTest.addResult(" Setting breakpoint at " + uiSourceCode.url() + ": " + lineNumber + ":" + columnNumber + " enabled:" + enabled + " condition:" + co ndition); 285 InspectorTest.addResult(" Setting breakpoint at " + uiSourceCode.url() + ": " + lineNumber + ":" + columnNumber + " enabled:" + enabled + " condition:" + co ndition);
286 if (setBreakpointCallback) 286 if (setBreakpointCallback)
287 window.setBreakpointCallback = setBreakpointCallback; 287 window.setBreakpointCallback = setBreakpointCallback;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 } 379 }
380 380
381 function finish() 381 function finish()
382 { 382 {
383 InspectorTest.dumpBreakpointLocations(breakpointManager); 383 InspectorTest.dumpBreakpointLocations(breakpointManager);
384 next(); 384 next();
385 } 385 }
386 } 386 }
387 387
388 } 388 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698