| OLD | NEW |
| 1 var initialize_BreakpointManagerTest = function() { | 1 var initialize_BreakpointManagerTest = function() { |
| 2 | 2 |
| 3 InspectorTest.createWorkspace = function(ignoreEvents) |
| 4 { |
| 5 if (InspectorTest.testFileSystemWorkspaceBinding) |
| 6 InspectorTest.testFileSystemWorkspaceBinding.dispose(); |
| 7 Workspace.fileSystemMapping.resetForTesting(); |
| 8 |
| 9 InspectorTest.testTargetManager = new SDK.TargetManager(); |
| 10 InspectorTest.testWorkspace = new Workspace.Workspace(); |
| 11 InspectorTest.testFileSystemWorkspaceBinding = new Persistence.FileSystemWor
kspaceBinding(Workspace.isolatedFileSystemManager, InspectorTest.testWorkspace); |
| 12 InspectorTest.testNetworkProjectManager = new Bindings.NetworkProjectManager
(InspectorTest.testTargetManager, InspectorTest.testWorkspace); |
| 13 InspectorTest.testDebuggerWorkspaceBinding = new Bindings.DebuggerWorkspaceB
inding(InspectorTest.testTargetManager, InspectorTest.testWorkspace); |
| 14 InspectorTest.testCSSWorkspaceBinding = new Bindings.CSSWorkspaceBinding(Ins
pectorTest.testTargetManager, InspectorTest.testWorkspace); |
| 15 |
| 16 InspectorTest.testTargetManager.observeTargets({ |
| 17 targetAdded: function(target) |
| 18 { |
| 19 InspectorTest.testNetworkProject = Bindings.NetworkProject.forTarget
(target); |
| 20 }, |
| 21 |
| 22 targetRemoved: function(target) |
| 23 { |
| 24 } |
| 25 }); |
| 26 |
| 27 if (ignoreEvents) |
| 28 return; |
| 29 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events.UISo
urceCodeAdded, InspectorTest._defaultWorkspaceEventHandler); |
| 30 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events.UISo
urceCodeRemoved, InspectorTest._defaultWorkspaceEventHandler); |
| 31 } |
| 32 |
| 33 InspectorTest._mockTargetId = 1; |
| 34 InspectorTest._pageCapabilities = |
| 35 SDK.Target.Capability.Browser | SDK.Target.Capability.DOM | |
| 36 SDK.Target.Capability.JS | SDK.Target.Capability.Log | |
| 37 SDK.Target.Capability.Network | SDK.Target.Capability.Worker; |
| 38 |
| 39 InspectorTest.createMockTarget = function(id, debuggerModelConstructor, capabili
ties) |
| 40 { |
| 41 capabilities = capabilities || InspectorTest._pageCapabilities; |
| 42 var MockTarget = class extends SDK.Target { |
| 43 constructor(name, connectionFactory, callback) { |
| 44 super(InspectorTest.testTargetManager, name, capabilities, connectio
nFactory, null, callback); |
| 45 this._inspectedURL = InspectorTest.mainTarget.inspectedURL(); |
| 46 this.consoleModel = new SDK.ConsoleModel(this); |
| 47 this.networkManager = new SDK.NetworkManager(this); |
| 48 this.runtimeModel = new SDK.RuntimeModel(this); |
| 49 this.securityOriginManager = SDK.SecurityOriginManager.fromTarget(th
is); |
| 50 this.resourceTreeModel = new SDK.ResourceTreeModel(this, this.networ
kManager, this.securityOriginManager); |
| 51 this.resourceTreeModel._cachedResourcesProcessed = true; |
| 52 this.resourceTreeModel._frameAttached("42", 0); |
| 53 this.debuggerModel = debuggerModelConstructor ? new debuggerModelCon
structor(this) : new SDK.DebuggerModel(this); |
| 54 this._modelByConstructor.set(SDK.DebuggerModel, this.debuggerModel); |
| 55 this.domModel = new SDK.DOMModel(this); |
| 56 this.cssModel = new SDK.CSSModel(this, this.domModel); |
| 57 } |
| 58 |
| 59 _loadedWithCapabilities() |
| 60 { |
| 61 } |
| 62 }; |
| 63 |
| 64 var target = new MockTarget("mock-target-" + id, (params) => new SDK.StubCon
nection(params)); |
| 65 InspectorTest.testTargetManager.addTarget(target); |
| 66 return target; |
| 67 } |
| 68 |
| 69 InspectorTest.createWorkspaceWithTarget = function(ignoreEvents) |
| 70 { |
| 71 InspectorTest.createWorkspace(ignoreEvents); |
| 72 var target = InspectorTest.createMockTarget(InspectorTest._mockTargetId++); |
| 73 return target; |
| 74 } |
| 75 |
| 76 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent = function(callback, count,
projectType) |
| 77 { |
| 78 InspectorTest.uiSourceCodeAddedEventsLeft = count || 1; |
| 79 InspectorTest.testWorkspace.removeEventListener(Workspace.Workspace.Events.U
ISourceCodeAdded, InspectorTest._defaultWorkspaceEventHandler); |
| 80 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events.UISo
urceCodeAdded, uiSourceCodeAdded); |
| 81 |
| 82 function uiSourceCodeAdded(event) |
| 83 { |
| 84 if (projectType && event.data.project().type() !== projectType) |
| 85 return; |
| 86 if (!projectType && event.data.project().type() === Workspace.projectTyp
es.Service) |
| 87 return; |
| 88 if (!(--InspectorTest.uiSourceCodeAddedEventsLeft)) { |
| 89 InspectorTest.testWorkspace.removeEventListener(Workspace.Workspace.
Events.UISourceCodeAdded, uiSourceCodeAdded); |
| 90 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Eve
nts.UISourceCodeAdded, InspectorTest._defaultWorkspaceEventHandler); |
| 91 } |
| 92 callback(event.data); |
| 93 } |
| 94 } |
| 95 |
| 96 InspectorTest.waitForWorkspaceUISourceCodeRemovedEvent = function(callback, coun
t) |
| 97 { |
| 98 InspectorTest.uiSourceCodeRemovedEventsLeft = count || 1; |
| 99 InspectorTest.testWorkspace.removeEventListener(Workspace.Workspace.Events.U
ISourceCodeRemoved, InspectorTest._defaultWorkspaceEventHandler); |
| 100 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events.UISo
urceCodeRemoved, uiSourceCodeRemoved); |
| 101 |
| 102 function uiSourceCodeRemoved(event) |
| 103 { |
| 104 if (event.data.project().type() === Workspace.projectTypes.Service) |
| 105 return; |
| 106 if (!(--InspectorTest.uiSourceCodeRemovedEventsLeft)) { |
| 107 InspectorTest.testWorkspace.removeEventListener(Workspace.Workspace.
Events.UISourceCodeRemoved, uiSourceCodeRemoved); |
| 108 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Eve
nts.UISourceCodeRemoved, InspectorTest._defaultWorkspaceEventHandler); |
| 109 } |
| 110 callback(event.data); |
| 111 } |
| 112 } |
| 113 |
| 114 InspectorTest.addMockUISourceCodeToWorkspace = function(url, type, content) |
| 115 { |
| 116 var mockContentProvider = Common.StaticContentProvider.fromString(url, type,
content); |
| 117 InspectorTest.testNetworkProject.addFile(mockContentProvider, null, false); |
| 118 } |
| 119 |
| 120 InspectorTest.addMockUISourceCodeViaNetwork = function(url, type, content, targe
t) |
| 121 { |
| 122 var mockContentProvider = Common.StaticContentProvider.fromString(url, type,
content); |
| 123 InspectorTest.testNetworkProject.addFile(mockContentProvider, target.resourc
eTreeModel.mainFrame, false); |
| 124 } |
| 125 |
| 126 InspectorTest._defaultWorkspaceEventHandler = function(event) |
| 127 { |
| 128 var uiSourceCode = event.data; |
| 129 if (uiSourceCode.project().type() === Workspace.projectTypes.Service) |
| 130 return; |
| 131 InspectorTest.addResult(`Workspace event: ${event.type.toString()}: ${uiSour
ceCode.url()}.`); |
| 132 } |
| 133 |
| 134 InspectorTest.uiSourceCodeURL = function(uiSourceCode) |
| 135 { |
| 136 return uiSourceCode.url().replace(/.*LayoutTests/, "LayoutTests"); |
| 137 } |
| 138 |
| 139 InspectorTest.dumpUISourceCode = function(uiSourceCode, callback) |
| 140 { |
| 141 InspectorTest.addResult("UISourceCode: " + InspectorTest.uiSourceCodeURL(uiS
ourceCode)); |
| 142 if (uiSourceCode.contentType() === Common.resourceTypes.Script || uiSourceCo
de.contentType() === Common.resourceTypes.Document) |
| 143 InspectorTest.addResult("UISourceCode is content script: " + (uiSourceCo
de.project().type() === Workspace.projectTypes.ContentScripts)); |
| 144 uiSourceCode.requestContent().then(didRequestContent); |
| 145 |
| 146 function didRequestContent(content, contentEncoded) |
| 147 { |
| 148 InspectorTest.addResult("Highlighter type: " + Bindings.NetworkProject.u
iSourceCodeMimeType(uiSourceCode)); |
| 149 InspectorTest.addResult("UISourceCode content: " + content); |
| 150 callback(); |
| 151 } |
| 152 } |
| 153 |
| 154 InspectorTest.fileSystemUISourceCodes = function() |
| 155 { |
| 156 var uiSourceCodes = []; |
| 157 var fileSystemProjects = Workspace.workspace.projectsForType(Workspace.proje
ctTypes.FileSystem); |
| 158 for (var project of fileSystemProjects) |
| 159 uiSourceCodes = uiSourceCodes.concat(project.uiSourceCodes()); |
| 160 return uiSourceCodes; |
| 161 } |
| 162 |
| 163 InspectorTest.refreshFileSystemProjects = function(callback) |
| 164 { |
| 165 var barrier = new CallbackBarrier(); |
| 166 var projects = Workspace.workspace.projects(); |
| 167 for (var i = 0; i < projects.length; ++i) |
| 168 projects[i].refresh("/", barrier.createCallback()); |
| 169 barrier.callWhenDone(callback); |
| 170 } |
| 171 |
| 172 InspectorTest.waitForGivenUISourceCode = function(name, callback) |
| 173 { |
| 174 var uiSourceCodes = Workspace.workspace.uiSourceCodes(); |
| 175 for (var i = 0; i < uiSourceCodes.length; ++i) { |
| 176 if (uiSourceCodes[i].name() === name) { |
| 177 setImmediate(callback); |
| 178 return; |
| 179 } |
| 180 } |
| 181 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCode
Added, uiSourceCodeAdded); |
| 182 |
| 183 function uiSourceCodeAdded(event) |
| 184 { |
| 185 if (event.data.name() === name) { |
| 186 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.U
ISourceCodeAdded, uiSourceCodeAdded); |
| 187 setImmediate(callback); |
| 188 } |
| 189 } |
| 190 } |
| 191 |
| 3 InspectorTest.uiSourceCodes = {}; | 192 InspectorTest.uiSourceCodes = {}; |
| 4 | 193 |
| 5 InspectorTest.dumpTargetIds = false; | 194 InspectorTest.dumpTargetIds = false; |
| 6 | 195 |
| 7 InspectorTest.initializeDefaultMappingOnTarget = function(target) | 196 InspectorTest.initializeDefaultMappingOnTarget = function(target) |
| 8 { | 197 { |
| 9 var defaultMapping = { | 198 var defaultMapping = { |
| 10 rawLocationToUILocation: function(rawLocation) | 199 rawLocationToUILocation: function(rawLocation) |
| 11 { | 200 { |
| 12 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation(
rawLocation.lineNumber, 0); | 201 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation(
rawLocation.lineNumber, 0); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 568 } |
| 380 | 569 |
| 381 function finish() | 570 function finish() |
| 382 { | 571 { |
| 383 InspectorTest.dumpBreakpointLocations(breakpointManager); | 572 InspectorTest.dumpBreakpointLocations(breakpointManager); |
| 384 next(); | 573 next(); |
| 385 } | 574 } |
| 386 } | 575 } |
| 387 | 576 |
| 388 } | 577 } |
| OLD | NEW |