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

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

Issue 2748933002: DevTools: remove dead code from breakpoint-manager.js test (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var initialize_BreakpointManagerTest = function() { 1 var initialize_BreakpointManagerTest = function() {
2 2
3 InspectorTest.createWorkspace = function(ignoreEvents) 3 InspectorTest.createWorkspace = function(ignoreEvents)
4 { 4 {
5 if (InspectorTest.testFileSystemWorkspaceBinding) 5 if (InspectorTest.testFileSystemWorkspaceBinding)
6 InspectorTest.testFileSystemWorkspaceBinding.dispose(); 6 InspectorTest.testFileSystemWorkspaceBinding.dispose();
7 Workspace.fileSystemMapping.resetForTesting(); 7 Workspace.fileSystemMapping.resetForTesting();
8 8
9 InspectorTest.testTargetManager = new SDK.TargetManager(); 9 InspectorTest.testTargetManager = new SDK.TargetManager();
10 InspectorTest.testWorkspace = new Workspace.Workspace(); 10 InspectorTest.testWorkspace = new Workspace.Workspace();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return target; 56 return target;
57 } 57 }
58 58
59 InspectorTest.createWorkspaceWithTarget = function(ignoreEvents) 59 InspectorTest.createWorkspaceWithTarget = function(ignoreEvents)
60 { 60 {
61 InspectorTest.createWorkspace(ignoreEvents); 61 InspectorTest.createWorkspace(ignoreEvents);
62 var target = InspectorTest.createMockTarget(InspectorTest._mockTargetId++); 62 var target = InspectorTest.createMockTarget(InspectorTest._mockTargetId++);
63 return target; 63 return target;
64 } 64 }
65 65
66 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent = function(callback, count, projectType)
67 {
68 InspectorTest.uiSourceCodeAddedEventsLeft = count || 1;
69 InspectorTest.testWorkspace.removeEventListener(Workspace.Workspace.Events.U ISourceCodeAdded, InspectorTest._defaultWorkspaceEventHandler);
70 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events.UISo urceCodeAdded, uiSourceCodeAdded);
71
72 function uiSourceCodeAdded(event)
73 {
74 if (projectType && event.data.project().type() !== projectType)
75 return;
76 if (!projectType && event.data.project().type() === Workspace.projectTyp es.Service)
77 return;
78 if (!(--InspectorTest.uiSourceCodeAddedEventsLeft)) {
79 InspectorTest.testWorkspace.removeEventListener(Workspace.Workspace. Events.UISourceCodeAdded, uiSourceCodeAdded);
80 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Eve nts.UISourceCodeAdded, InspectorTest._defaultWorkspaceEventHandler);
81 }
82 callback(event.data);
83 }
84 }
85
86 InspectorTest.waitForWorkspaceUISourceCodeRemovedEvent = function(callback, coun t)
87 {
88 InspectorTest.uiSourceCodeRemovedEventsLeft = count || 1;
89 InspectorTest.testWorkspace.removeEventListener(Workspace.Workspace.Events.U ISourceCodeRemoved, InspectorTest._defaultWorkspaceEventHandler);
90 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events.UISo urceCodeRemoved, uiSourceCodeRemoved);
91
92 function uiSourceCodeRemoved(event)
93 {
94 if (event.data.project().type() === Workspace.projectTypes.Service)
95 return;
96 if (!(--InspectorTest.uiSourceCodeRemovedEventsLeft)) {
97 InspectorTest.testWorkspace.removeEventListener(Workspace.Workspace. Events.UISourceCodeRemoved, uiSourceCodeRemoved);
98 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Eve nts.UISourceCodeRemoved, InspectorTest._defaultWorkspaceEventHandler);
99 }
100 callback(event.data);
101 }
102 }
103
104 InspectorTest.addMockUISourceCodeToWorkspace = function(url, type, content)
105 {
106 var mockContentProvider = Common.StaticContentProvider.fromString(url, type, content);
107 InspectorTest.testNetworkProject.addFile(mockContentProvider, null, false);
108 }
109
110 InspectorTest.addMockUISourceCodeViaNetwork = function(url, type, content, targe t)
111 {
112 var mockContentProvider = Common.StaticContentProvider.fromString(url, type, content);
113 InspectorTest.testNetworkProject.addFile(mockContentProvider, target.resourc eTreeModel.mainFrame, false);
114 }
115
116 InspectorTest._defaultWorkspaceEventHandler = function(event) 66 InspectorTest._defaultWorkspaceEventHandler = function(event)
117 { 67 {
118 var uiSourceCode = event.data; 68 var uiSourceCode = event.data;
119 if (uiSourceCode.project().type() === Workspace.projectTypes.Service) 69 if (uiSourceCode.project().type() === Workspace.projectTypes.Service)
120 return; 70 return;
121 InspectorTest.addResult(`Workspace event: ${event.type.toString()}: ${uiSour ceCode.url()}.`); 71 InspectorTest.addResult(`Workspace event: ${event.type.toString()}: ${uiSour ceCode.url()}.`);
122 } 72 }
123 73
124 InspectorTest.uiSourceCodeURL = function(uiSourceCode)
125 {
126 return uiSourceCode.url().replace(/.*LayoutTests/, "LayoutTests");
127 }
128
129 InspectorTest.dumpUISourceCode = function(uiSourceCode, callback)
130 {
131 InspectorTest.addResult("UISourceCode: " + InspectorTest.uiSourceCodeURL(uiS ourceCode));
132 if (uiSourceCode.contentType() === Common.resourceTypes.Script || uiSourceCo de.contentType() === Common.resourceTypes.Document)
133 InspectorTest.addResult("UISourceCode is content script: " + (uiSourceCo de.project().type() === Workspace.projectTypes.ContentScripts));
134 uiSourceCode.requestContent().then(didRequestContent);
135
136 function didRequestContent(content, contentEncoded)
137 {
138 InspectorTest.addResult("Highlighter type: " + Bindings.NetworkProject.u iSourceCodeMimeType(uiSourceCode));
139 InspectorTest.addResult("UISourceCode content: " + content);
140 callback();
141 }
142 }
143
144 InspectorTest.fileSystemUISourceCodes = function()
145 {
146 var uiSourceCodes = [];
147 var fileSystemProjects = Workspace.workspace.projectsForType(Workspace.proje ctTypes.FileSystem);
148 for (var project of fileSystemProjects)
149 uiSourceCodes = uiSourceCodes.concat(project.uiSourceCodes());
150 return uiSourceCodes;
151 }
152
153 InspectorTest.refreshFileSystemProjects = function(callback)
154 {
155 var barrier = new CallbackBarrier();
156 var projects = Workspace.workspace.projects();
157 for (var i = 0; i < projects.length; ++i)
158 projects[i].refresh("/", barrier.createCallback());
159 barrier.callWhenDone(callback);
160 }
161
162 InspectorTest.waitForGivenUISourceCode = function(name, callback)
163 {
164 var uiSourceCodes = Workspace.workspace.uiSourceCodes();
165 for (var i = 0; i < uiSourceCodes.length; ++i) {
166 if (uiSourceCodes[i].name() === name) {
167 setImmediate(callback);
168 return;
169 }
170 }
171 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCode Added, uiSourceCodeAdded);
172
173 function uiSourceCodeAdded(event)
174 {
175 if (event.data.name() === name) {
176 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.U ISourceCodeAdded, uiSourceCodeAdded);
177 setImmediate(callback);
178 }
179 }
180 }
181
182 InspectorTest.uiSourceCodes = {}; 74 InspectorTest.uiSourceCodes = {};
183 75
184 InspectorTest.dumpTargetIds = false;
185
186 InspectorTest.initializeDefaultMappingOnTarget = function(target) 76 InspectorTest.initializeDefaultMappingOnTarget = function(target)
187 { 77 {
188 var defaultMapping = { 78 var defaultMapping = {
189 rawLocationToUILocation: function(rawLocation) 79 rawLocationToUILocation: function(rawLocation)
190 { 80 {
191 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation( rawLocation.lineNumber, 0); 81 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation( rawLocation.lineNumber, 0);
192 }, 82 },
193 83
194 uiLocationToRawLocation: function(uiSourceCode, lineNumber) 84 uiLocationToRawLocation: function(uiSourceCode, lineNumber)
195 { 85 {
196 if (!InspectorTest.uiSourceCodes[uiSourceCode.url()]) 86 if (!InspectorTest.uiSourceCodes[uiSourceCode.url()])
197 return null; 87 return null;
198 return new SDK.DebuggerModel.Location(target.debuggerModel, uiSource Code.url(), lineNumber, 0); 88 return new SDK.DebuggerModel.Location(target.debuggerModel, uiSource Code.url(), lineNumber, 0);
199 }, 89 },
200 90
201 isIdentity: function() 91 isIdentity: function()
202 { 92 {
203 return true; 93 return true;
204 } 94 }
205 }; 95 };
206 target.defaultMapping = defaultMapping; 96 target.defaultMapping = defaultMapping;
207 } 97 }
208 98
209 InspectorTest.dumpTarget = function(targetAware)
210 {
211 return InspectorTest.dumpTargetIds ? "target " + targetAware.target().id() + " " : "";
212 }
213
214 InspectorTest.DebuggerModelMock = class extends SDK.SDKModel { 99 InspectorTest.DebuggerModelMock = class extends SDK.SDKModel {
215 constructor(target) 100 constructor(target)
216 { 101 {
217 super(target); 102 super(target);
218 this._target = target; 103 this._target = target;
219 this._breakpointResolvedEventTarget = new Common.Object(); 104 this._breakpointResolvedEventTarget = new Common.Object();
220 this._scripts = {}; 105 this._scripts = {};
221 this._breakpoints = {}; 106 this._breakpoints = {};
222 this._debuggerWorkspaceBinding = InspectorTest.testDebuggerWorkspaceBind ing; 107 this._debuggerWorkspaceBinding = InspectorTest.testDebuggerWorkspaceBind ing;
223 } 108 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 165 }
281 } 166 }
282 167
283 createRawLocation(script, line, column) 168 createRawLocation(script, line, column)
284 { 169 {
285 return new SDK.DebuggerModel.Location(this, script.scriptId, line, colum n); 170 return new SDK.DebuggerModel.Location(this, script.scriptId, line, colum n);
286 } 171 }
287 172
288 setBreakpointByURL(url, lineNumber, columnNumber, condition, callback) 173 setBreakpointByURL(url, lineNumber, columnNumber, condition, callback)
289 { 174 {
290 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.setBreakpoint(" + [url, lineNumber, condition].join(":") + ")"); 175 InspectorTest.addResult(" debuggerModel.setBreakpoint(" + [url, lineN umber, condition].join(":") + ")");
291 176
292 var breakpointId = url + ":" + lineNumber; 177 var breakpointId = url + ":" + lineNumber;
293 if (this._breakpoints[breakpointId]) { 178 if (this._breakpoints[breakpointId]) {
294 this._scheduleSetBeakpointCallback(callback, null); 179 this._scheduleSetBeakpointCallback(callback, null);
295 return; 180 return;
296 } 181 }
297 this._breakpoints[breakpointId] = true; 182 this._breakpoints[breakpointId] = true;
298 183
299 if (lineNumber >= 2000) { 184 if (lineNumber >= 2000) {
300 this._scheduleSetBeakpointCallback(callback, breakpointId, []); 185 this._scheduleSetBeakpointCallback(callback, breakpointId, []);
(...skipping 10 matching lines...) Expand all
311 if (script) { 196 if (script) {
312 var location = new SDK.DebuggerModel.Location(this, script.scriptId, lineNumber, 0); 197 var location = new SDK.DebuggerModel.Location(this, script.scriptId, lineNumber, 0);
313 locations.push(location); 198 locations.push(location);
314 } 199 }
315 200
316 this._scheduleSetBeakpointCallback(callback, breakpointId, locations); 201 this._scheduleSetBeakpointCallback(callback, breakpointId, locations);
317 } 202 }
318 203
319 removeBreakpoint(breakpointId, callback) 204 removeBreakpoint(breakpointId, callback)
320 { 205 {
321 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.removeBreakpoint(" + breakpointId + ")"); 206 InspectorTest.addResult(" debuggerModel.removeBreakpoint(" + breakpoi ntId + ")");
322 delete this._breakpoints[breakpointId]; 207 delete this._breakpoints[breakpointId];
323 if (callback) 208 if (callback)
324 setTimeout(callback, 0); 209 setTimeout(callback, 0);
325 } 210 }
326 211
327 setBreakpointsActive() { } 212 setBreakpointsActive() { }
328 213
329 scriptForId(scriptId) 214 scriptForId(scriptId)
330 { 215 {
331 return this._scripts[scriptId]; 216 return this._scripts[scriptId];
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 _breakpointResolved(breakpointId, location) 249 _breakpointResolved(breakpointId, location)
365 { 250 {
366 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI d, location); 251 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI d, location);
367 } 252 }
368 }; 253 };
369 254
370 InspectorTest.setupLiveLocationSniffers = function() 255 InspectorTest.setupLiveLocationSniffers = function()
371 { 256 {
372 InspectorTest.addSniffer(Bindings.DebuggerWorkspaceBinding.prototype, "creat eLiveLocation", function(rawLocation) 257 InspectorTest.addSniffer(Bindings.DebuggerWorkspaceBinding.prototype, "creat eLiveLocation", function(rawLocation)
373 { 258 {
374 InspectorTest.addResult(" Location created: " + InspectorTest.dumpTar get(rawLocation) + rawLocation.scriptId + ":" + rawLocation.lineNumber); 259 InspectorTest.addResult(" Location created: " + rawLocation.scriptId + ":" + rawLocation.lineNumber);
375 }, true); 260 }, true);
376 InspectorTest.addSniffer(Bindings.DebuggerWorkspaceBinding.Location.prototyp e, "dispose", function() 261 InspectorTest.addSniffer(Bindings.DebuggerWorkspaceBinding.Location.prototyp e, "dispose", function()
377 { 262 {
378 InspectorTest.addResult(" Location disposed: " + InspectorTest.dumpTa rget(this._rawLocation) + this._rawLocation.scriptId + ":" + this._rawLocation.l ineNumber); 263 InspectorTest.addResult(" Location disposed: " + this._rawLocation.sc riptId + ":" + this._rawLocation.lineNumber);
379 }, true); 264 }, true);
380 } 265 }
381 266
382 InspectorTest.addScript = function(target, breakpointManager, url) 267 InspectorTest.addScript = function(target, breakpointManager, url)
383 { 268 {
384 target.debuggerModel._addScript(url, url); 269 target.debuggerModel._addScript(url, url);
385 InspectorTest.addResult(" Adding script: " + url); 270 InspectorTest.addResult(" Adding script: " + url);
386 var uiSourceCodes = breakpointManager._workspace.uiSourceCodesForProjectType (Workspace.projectTypes.Debugger); 271 var uiSourceCodes = breakpointManager._workspace.uiSourceCodesForProjectType (Workspace.projectTypes.Debugger);
387 for (var i = 0; i < uiSourceCodes.length; ++i) { 272 for (var i = 0; i < uiSourceCodes.length; ++i) {
388 var uiSourceCode = uiSourceCodes[i]; 273 var uiSourceCode = uiSourceCodes[i];
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 446 }
562 447
563 function finish() 448 function finish()
564 { 449 {
565 InspectorTest.dumpBreakpointLocations(breakpointManager); 450 InspectorTest.dumpBreakpointLocations(breakpointManager);
566 next(); 451 next();
567 } 452 }
568 } 453 }
569 454
570 } 455 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698