| 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 <script src="../../../http/tests/inspector/debugger-test.js"></script> | 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> |
| 5 <script src="../../../http/tests/inspector/workspace-test.js"></script> | 5 <script src="../../../http/tests/inspector/workspace-test.js"></script> |
| 6 <script src="../../../http/tests/inspector/isolated-filesystem-test.js"></script
> | 6 <script src="../../../http/tests/inspector/isolated-filesystem-test.js"></script
> |
| 7 <script src="../../../http/tests/inspector/live-edit-test.js"></script> | 7 <script src="../../../http/tests/inspector/live-edit-test.js"></script> |
| 8 <script> | 8 <script> |
| 9 |
| 9 function test() | 10 function test() |
| 10 { | 11 { |
| 11 var target; | 12 var target; |
| 12 var resourceScriptMapping; | 13 var resourceScriptMapping; |
| 13 var defaultScriptMapping; | 14 var defaultScriptMapping; |
| 15 var persistence; |
| 14 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.projectId(
"file:///var/www"); | 16 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.projectId(
"file:///var/www"); |
| 15 WebInspector.networkMapping.dispose(); | 17 WebInspector.networkMapping.dispose(); |
| 16 | 18 |
| 17 function createWorkspaceWithTarget() | 19 function createWorkspaceWithTarget() |
| 18 { | 20 { |
| 19 target = InspectorTest.createWorkspaceWithTarget(false); | 21 target = InspectorTest.createWorkspaceWithTarget(false); |
| 20 var entry = InspectorTest.testDebuggerWorkspaceBinding._targetToData.get
(target); | 22 var entry = InspectorTest.testDebuggerWorkspaceBinding._targetToData.get
(target); |
| 21 resourceScriptMapping = entry._resourceMapping; | 23 resourceScriptMapping = entry._resourceMapping; |
| 22 defaultScriptMapping = entry._defaultMapping; | 24 defaultScriptMapping = entry._defaultMapping; |
| 23 } | 25 if (persistence) |
| 24 | 26 persistence.dispose(); |
| 25 function suspendStateChanged() | 27 persistence = new WebInspector.Persistence(InspectorTest.testWorkspace,
WebInspector.breakpointManager, WebInspector.fileSystemMapping); |
| 26 { | |
| 27 InspectorTest.addResult("(suspend state changed: " + InspectorTest.testT
argetManager.allTargetsSuspended() + ")"); | |
| 28 } | 28 } |
| 29 | 29 |
| 30 function dumpFileSystemUISourceCodesMappings() | 30 function dumpFileSystemUISourceCodesMappings() |
| 31 { | 31 { |
| 32 var uiSourceCodes = InspectorTest.testWorkspace.project(fileSystemProjec
tId).uiSourceCodes(); | 32 var uiSourceCodes = InspectorTest.testWorkspace.project(fileSystemProjec
tId).uiSourceCodes(); |
| 33 InspectorTest.addResult("UISourceCode uri to url mappings:"); | 33 InspectorTest.addResult("UISourceCode uri to url mappings:"); |
| 34 for (var i = 0; i < uiSourceCodes.length; ++i) { | 34 for (var uiSourceCode of uiSourceCodes) { |
| 35 var networkURL = InspectorTest.testNetworkMapping.networkURL(uiSourc
eCodes[i]); | 35 var binding = persistence.binding(uiSourceCode); |
| 36 InspectorTest.addResult(" " + uiSourceCodes[i].url() + " -> " + n
etworkURL); | 36 var networkURL = binding ? binding.network.url() : ""; |
| 37 InspectorTest.addResult(" " + uiSourceCode.url() + " -> " + netwo
rkURL); |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 InspectorTest.runTestSuite([ | 41 InspectorTest.runTestSuite([ |
| 41 function testAutomaticMapping(next) | 42 function testAutomaticMapping(next) |
| 42 { | 43 { |
| 43 createWorkspaceWithTarget(); | 44 createWorkspaceWithTarget(); |
| 44 | 45 |
| 45 InspectorTest.addResult("Adding file system."); | 46 InspectorTest.addResult("Adding file system."); |
| 46 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | 47 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 67 createWorkspaceWithTarget(); | 68 createWorkspaceWithTarget(); |
| 68 WebInspector.fileSystemMapping._fileSystemMappingSetting.set(JSO
N.parse(setting)); | 69 WebInspector.fileSystemMapping._fileSystemMappingSetting.set(JSO
N.parse(setting)); |
| 69 WebInspector.fileSystemMapping._loadFromSettings(); | 70 WebInspector.fileSystemMapping._loadFromSettings(); |
| 70 fs.reportCreated(fileSystemCreated2); | 71 fs.reportCreated(fileSystemCreated2); |
| 71 } | 72 } |
| 72 | 73 |
| 73 function fileSystemCreated2() | 74 function fileSystemCreated2() |
| 74 { | 75 { |
| 75 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 76 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); |
| 76 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 77 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", WebInspector.resourceTypes.Script, "<foo content>", target); |
| 78 |
| 77 dumpFileSystemUISourceCodesMappings(); | 79 dumpFileSystemUISourceCodesMappings(); |
| 78 | 80 |
| 79 InspectorTest.addResult("Removing mapping between network and fi
le system resources."); | 81 InspectorTest.addResult("Removing mapping between network and fi
le system resources."); |
| 80 var uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(file
SystemProjectId, "file:///var/www/html/foo.js"); | 82 var uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(file
SystemProjectId, "file:///var/www/html/foo.js"); |
| 81 InspectorTest.testNetworkMapping.removeMapping(uiSourceCode); | 83 InspectorTest.testNetworkMapping.removeMapping(uiSourceCode); |
| 82 | 84 |
| 83 InspectorTest.addResult("Emulate reloading inspector."); | 85 InspectorTest.addResult("Emulate reloading inspector."); |
| 84 fs.reportRemoved(); | 86 fs.reportRemoved(); |
| 85 createWorkspaceWithTarget(); | 87 createWorkspaceWithTarget(); |
| 86 fs.reportCreated(fileSystemCreated3); | 88 fs.reportCreated(fileSystemCreated3); |
| 87 } | 89 } |
| 88 | 90 |
| 89 function fileSystemCreated3() | 91 function fileSystemCreated3() |
| 90 { | 92 { |
| 91 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 93 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); |
| 92 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 94 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", WebInspector.resourceTypes.Script, "<foo content>", target); |
| 93 dumpFileSystemUISourceCodesMappings(); | 95 dumpFileSystemUISourceCodesMappings(); |
| 94 | 96 |
| 95 var networkURL = InspectorTest.testNetworkMapping.networkURL(net
workUISourceCode); | 97 var networkURL = InspectorTest.testNetworkMapping.networkURL(net
workUISourceCode); |
| 96 WebInspector.fileSystemMapping.removeMappingForURL(networkURL); | 98 WebInspector.fileSystemMapping.removeMappingForURL(networkURL); |
| 97 fs.reportRemoved(); | 99 fs.reportRemoved(); |
| 98 next(); | 100 next(); |
| 99 } | 101 } |
| 100 }, | 102 }, |
| 101 | 103 |
| 102 function testScriptFileOnReloadWithDirtyFile(next) | |
| 103 { | |
| 104 var originalFileContent = "<foo content>"; | |
| 105 var scriptURL = "http://localhost/html/foo.js"; | |
| 106 var scriptContent = originalFileContent + "\n //# sourceURL=" + scr
iptURL + " \n "; | |
| 107 function unloadScript() | |
| 108 { | |
| 109 resourceScriptMapping._debuggerReset(); | |
| 110 defaultScriptMapping._debuggerReset(); | |
| 111 } | |
| 112 | |
| 113 function loadScript() | |
| 114 { | |
| 115 script = InspectorTest.createScriptMock(scriptURL, 0, 0, false,
scriptContent, InspectorTest.testTargetManager.targets()[0]); | |
| 116 defaultScriptMapping.addScript(script); | |
| 117 resourceScriptMapping.addScript(script); | |
| 118 } | |
| 119 | |
| 120 var uiSourceCode; | |
| 121 | |
| 122 createWorkspaceWithTarget(); | |
| 123 | |
| 124 InspectorTest._originalDebuggerBinding = WebInspector.debuggerWorksp
aceBinding; | |
| 125 WebInspector.debuggerWorkspaceBinding = InspectorTest.testDebuggerWo
rkspaceBinding; | |
| 126 var target = InspectorTest.testTargetManager.targets()[0]; | |
| 127 WebInspector._originalTargetManager = WebInspector.targetManager; | |
| 128 WebInspector.targetManager = InspectorTest.testTargetManager; | |
| 129 | |
| 130 InspectorTest.addResult("Adding file system."); | |
| 131 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | |
| 132 fs.root.mkdir("html").addFile("foo.js", originalFileContent); | |
| 133 fs.root.addFile("bar.js", "<bar content>"); | |
| 134 InspectorTest.addResult("Adding file system mapping."); | |
| 135 fs.addFileMapping("http://localhost/", "/"); | |
| 136 fs.reportCreated(fileSystemCreated); | |
| 137 var sourceFrame; | |
| 138 | |
| 139 function waitForMappingsCheck(callback) | |
| 140 { | |
| 141 InspectorTest.addSniffer(WebInspector.ResourceScriptFile.prototy
pe, "_mappingCheckedForTest", onMappingChecked); | |
| 142 | |
| 143 function onMappingChecked() | |
| 144 { | |
| 145 setImmediate(callback); | |
| 146 } | |
| 147 } | |
| 148 | |
| 149 function fileSystemCreated() | |
| 150 { | |
| 151 loadScript(); | |
| 152 | |
| 153 uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSyst
emProjectId, "file:///var/www/html/foo.js"); | |
| 154 InspectorTest.showUISourceCode(uiSourceCode, sf => sourceFrame =
sf); | |
| 155 waitForMappingsCheck(didShowScriptSource); | |
| 156 } | |
| 157 | |
| 158 function dumpUISourceCodeAndScriptContents() | |
| 159 { | |
| 160 InspectorTest.addResult("Dumping uiSourceCode and script content
:"); | |
| 161 InspectorTest.addResult(" uiSourceCode: " + uiSourceCode.work
ingCopy()); | |
| 162 InspectorTest.addResult(" script: " + scriptContent); | |
| 163 } | |
| 164 | |
| 165 function didShowScriptSource() | |
| 166 { | |
| 167 dumpUISourceCodeAndScriptContents(); | |
| 168 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); | |
| 169 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | |
| 170 | |
| 171 InspectorTest.addResult("Editing uiSourceCode:"); | |
| 172 waitForMappingsCheck(onMappingChecked1); | |
| 173 uiSourceCode.setWorkingCopy("<foo content edited>"); | |
| 174 } | |
| 175 | |
| 176 function onMappingChecked1() | |
| 177 { | |
| 178 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); | |
| 179 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | |
| 180 | |
| 181 function setScriptSourceOverrideFailure(scriptId, newContent, ca
llback) | |
| 182 { | |
| 183 callback("error"); | |
| 184 } | |
| 185 InspectorTest.override(WebInspector.DebuggerModel.prototype, "se
tScriptSource", setScriptSourceOverrideFailure); | |
| 186 | |
| 187 InspectorTest.addResult("Committing uiSourceCode with live edit
failure:"); | |
| 188 waitForMappingsCheck(onMappingChecked2); | |
| 189 uiSourceCode.commitWorkingCopy(); | |
| 190 } | |
| 191 | |
| 192 function onMappingChecked2() | |
| 193 { | |
| 194 dumpUISourceCodeAndScriptContents(); | |
| 195 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); | |
| 196 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | |
| 197 | |
| 198 InspectorTest.addResult("Reloading with saved but diverged uiSou
rceCode:"); | |
| 199 unloadScript(); | |
| 200 InspectorTest.addResult("UISourceCode should not have script fil
e after unloading scripts: " + !resourceScriptMapping.scriptFile(uiSourceCode)); | |
| 201 InspectorTest.addResult("Saved but diverged source frame should
not be muted: " + !sourceFrame._muted); | |
| 202 | |
| 203 InspectorTest.addResult("Loading script."); | |
| 204 waitForMappingsCheck(onMappingChecked3); | |
| 205 loadScript(); | |
| 206 } | |
| 207 | |
| 208 function onMappingChecked3() | |
| 209 { | |
| 210 dumpUISourceCodeAndScriptContents(); | |
| 211 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); | |
| 212 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | |
| 213 | |
| 214 InspectorTest.addResult("Editing uiSourceCode again:"); | |
| 215 waitForMappingsCheck(onMappingChecked4); | |
| 216 uiSourceCode.setWorkingCopy("<foo content edited again>"); | |
| 217 } | |
| 218 | |
| 219 function onMappingChecked4() | |
| 220 { | |
| 221 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); | |
| 222 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | |
| 223 | |
| 224 function setScriptSourceOverrideSuccess(scriptId, newContent, ca
llback) | |
| 225 { | |
| 226 scriptContent = newContent; | |
| 227 callback(); | |
| 228 } | |
| 229 InspectorTest.override(WebInspector.DebuggerModel.prototype, "se
tScriptSource", setScriptSourceOverrideSuccess); | |
| 230 | |
| 231 InspectorTest.addResult("Committing uiSourceCode again (with liv
e edit success now):"); | |
| 232 waitForMappingsCheck(onMappingChecked5); | |
| 233 uiSourceCode.commitWorkingCopy(); | |
| 234 } | |
| 235 | |
| 236 function onMappingChecked5() | |
| 237 { | |
| 238 dumpUISourceCodeAndScriptContents(); | |
| 239 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); | |
| 240 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | |
| 241 | |
| 242 InspectorTest.addResult("Reloading page:"); | |
| 243 unloadScript(); | |
| 244 InspectorTest.addResult("UISourceCode should not have script fil
e after unloading scripts: " + !resourceScriptMapping.scriptFile(uiSourceCode)); | |
| 245 InspectorTest.addResult("Saved and merged source frame should no
t be muted: " + !sourceFrame._muted); | |
| 246 InspectorTest.addResult("Loading script."); | |
| 247 waitForMappingsCheck(onMappingChecked6); | |
| 248 loadScript(); | |
| 249 } | |
| 250 | |
| 251 function onMappingChecked6() | |
| 252 { | |
| 253 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); | |
| 254 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | |
| 255 | |
| 256 InspectorTest.addResult("Editing uiSourceCode again and reloadin
g while it is dirty:"); | |
| 257 uiSourceCode.setWorkingCopy("<foo content edited and dirty>"); | |
| 258 unloadScript(); | |
| 259 InspectorTest.addResult("UISourceCode should not have script fil
e after unloading scripts: " + !resourceScriptMapping.scriptFile(uiSourceCode)); | |
| 260 InspectorTest.addResult("Dirty source frame should be muted: " +
sourceFrame._muted); | |
| 261 InspectorTest.addResult("Loading script."); | |
| 262 waitForMappingsCheck(onMappingChecked7); | |
| 263 loadScript(); | |
| 264 } | |
| 265 | |
| 266 function onMappingChecked7() | |
| 267 { | |
| 268 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); | |
| 269 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | |
| 270 | |
| 271 unloadScript(); | |
| 272 loadScript; | |
| 273 | |
| 274 WebInspector.debuggerWorkspaceBinding = InspectorTest._originalD
ebuggerBinding; | |
| 275 fs.reportRemoved(); | |
| 276 next(); | |
| 277 } | |
| 278 }, | |
| 279 | |
| 280 function testRemoveProject(next) | 104 function testRemoveProject(next) |
| 281 { | 105 { |
| 282 function dumpWorkspaceUISourceCodes() | 106 function dumpWorkspaceUISourceCodes() |
| 283 { | 107 { |
| 284 InspectorTest.addResult("Dumping uiSourceCodes origin URLs:"); | 108 InspectorTest.addResult("Dumping uiSourceCodes origin URLs:"); |
| 285 var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); | 109 var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); |
| 286 for (var i = 0; i < uiSourceCodes.length; ++i) | 110 for (var i = 0; i < uiSourceCodes.length; ++i) |
| 287 InspectorTest.addResult(" - " + uiSourceCodes[i].url()); | 111 InspectorTest.addResult(" - " + uiSourceCodes[i].url()); |
| 288 } | 112 } |
| 289 | 113 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 305 | 129 |
| 306 function projectRemoved() | 130 function projectRemoved() |
| 307 { | 131 { |
| 308 InspectorTest.testWorkspace.removeEventListener(WebInspector.Wor
kspace.Events.ProjectRemoved, projectRemoved); | 132 InspectorTest.testWorkspace.removeEventListener(WebInspector.Wor
kspace.Events.ProjectRemoved, projectRemoved); |
| 309 InspectorTest.addResult("Received project removed event."); | 133 InspectorTest.addResult("Received project removed event."); |
| 310 fs.reportRemoved(); | 134 fs.reportRemoved(); |
| 311 setImmediate(next); | 135 setImmediate(next); |
| 312 } | 136 } |
| 313 }, | 137 }, |
| 314 | 138 |
| 315 function testURLAfterRenaming(next) | |
| 316 { | |
| 317 var index = 0; | |
| 318 var oldURL; | |
| 319 | |
| 320 createWorkspaceWithTarget(); | |
| 321 | |
| 322 InspectorTest.addResult("Adding file system."); | |
| 323 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | |
| 324 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); | |
| 325 fs.root.addFile("bar.js", "<bar content>"); | |
| 326 fs.root.mkdir("foo").mkdir("bar").addFile("baz.js", "<baz content>")
; | |
| 327 InspectorTest.addResult("Adding file system mapping."); | |
| 328 fs.addFileMapping("http://localhost/", "/"); | |
| 329 fs.reportCreated(fileSystemCreated); | |
| 330 var uiSourceCodes; | |
| 331 | |
| 332 function fileSystemCreated() | |
| 333 { | |
| 334 InspectorTest.addResult("Renaming files:"); | |
| 335 uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); | |
| 336 renameNextFile(); | |
| 337 } | |
| 338 | |
| 339 function renameNextFile() | |
| 340 { | |
| 341 var uiSourceCode = uiSourceCodes[index]; | |
| 342 oldURL = InspectorTest.testNetworkMapping.networkURL(uiSourceCod
e); | |
| 343 uiSourceCodes[index].rename("newName.js", fileRenamed); | |
| 344 } | |
| 345 | |
| 346 function fileRenamed() | |
| 347 { | |
| 348 var uiSourceCode = uiSourceCodes[index]; | |
| 349 var networkURL = InspectorTest.testNetworkMapping.networkURL(uiS
ourceCode); | |
| 350 InspectorTest.addResult(" uiSourceCode URL change after renam
ing: " + oldURL + " -> " + networkURL); | |
| 351 ++index; | |
| 352 if (index < uiSourceCodes.length) | |
| 353 renameNextFile(); | |
| 354 else { | |
| 355 fs.reportRemoved(); | |
| 356 next(); | |
| 357 } | |
| 358 } | |
| 359 }, | |
| 360 | |
| 361 function testProjectBasedMapping(next) | 139 function testProjectBasedMapping(next) |
| 362 { | 140 { |
| 363 createWorkspaceWithTarget(); | 141 createWorkspaceWithTarget(); |
| 364 InspectorTest.testTargetManager.addEventListener(WebInspector.Target
Manager.Events.SuspendStateChanged, suspendStateChanged); | |
| 365 | 142 |
| 366 InspectorTest.addResult("Adding file system."); | 143 InspectorTest.addResult("Adding file system."); |
| 367 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | 144 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 368 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); | 145 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); |
| 369 fs.root.mkdir("html2").addFile("bar.js", "<bar content>"); | 146 fs.root.mkdir("html2").addFile("bar.js", "<bar content>"); |
| 370 fs.root.addFile(".devtools", JSON.stringify({ mappings: [ { folder:
"/html/", url: "http://localhost/h1/" }, { folder: "/html2/", url: "http://local
host/h2/" } ]})); | 147 fs.root.addFile(".devtools", JSON.stringify({ mappings: [ { folder:
"/html/", url: "http://localhost/h1/" }, { folder: "/html2/", url: "http://local
host/h2/" } ]})); |
| 371 fs.reportCreated(fileSystemCreated); | 148 fs.reportCreated(fileSystemCreated); |
| 372 | 149 |
| 373 function fileSystemCreated() | 150 function fileSystemCreated() |
| 374 { | 151 { |
| 375 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/h1
/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 152 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/h1
/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); |
| 376 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/h2
/bar.js", WebInspector.resourceTypes.Script, "<bar content>", target); | 153 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/h2
/bar.js", WebInspector.resourceTypes.Script, "<bar content>", target); |
| 377 dumpFileSystemUISourceCodesMappings(); | 154 dumpFileSystemUISourceCodesMappings(); |
| 378 fs.reportRemoved(); | 155 fs.reportRemoved(); |
| 379 next(); | 156 next(); |
| 380 } | 157 } |
| 381 }, | |
| 382 | |
| 383 function testNodeJSWrapper(next) | |
| 384 { | |
| 385 createWorkspaceWithTarget(); | |
| 386 InspectorTest.addResult("Adding file system."); | |
| 387 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | |
| 388 var content = "var a = 1;" | |
| 389 var folder = fs.root.mkdir("html"); | |
| 390 folder.addFile("foo.js", "#!/usr/bin/env node;\n" + content); | |
| 391 folder.addFile("bar.js", content); | |
| 392 fs.root.addFile(".devtools", JSON.stringify({ mappings: [ { folder:
"/html/", url: "http://localhost/h1/" } ]})); | |
| 393 fs.reportCreated(fileSystemCreated); | |
| 394 | |
| 395 function fileSystemCreated() | |
| 396 { | |
| 397 debugger; | |
| 398 var uiSourceCodeFoo = InspectorTest.testWorkspace.uiSourceCode(f
ileSystemProjectId, "file:///var/www/html/foo.js"); | |
| 399 var uiSourceCodeBar = InspectorTest.testWorkspace.uiSourceCode(f
ileSystemProjectId, "file:///var/www/html/bar.js"); | |
| 400 | |
| 401 var nodePrefix = "(function (exports, require, module, __filenam
e, __dirname) { \n"; | |
| 402 var nodeSuffix = "\n});"; | |
| 403 | |
| 404 var scriptFoo = InspectorTest.createScriptMock("http://localhost
/h1/foo.js", 0, 0, false, nodePrefix + content + nodeSuffix, InspectorTest.testT
argetManager.targets()[0]); | |
| 405 defaultScriptMapping.addScript(scriptFoo); | |
| 406 resourceScriptMapping.addScript(scriptFoo); | |
| 407 InspectorTest.addResult("Is diverged: " + resourceScriptMapping.
scriptFile(uiSourceCodeFoo)._isDiverged()); | |
| 408 | |
| 409 var scriptBar = InspectorTest.createScriptMock("http://localhost
/h1/bar.js", 0, 0, false, nodePrefix + content + nodeSuffix, InspectorTest.testT
argetManager.targets()[0]); | |
| 410 defaultScriptMapping.addScript(scriptBar); | |
| 411 resourceScriptMapping.addScript(scriptBar); | |
| 412 InspectorTest.addResult("Is diverged: " + resourceScriptMapping.
scriptFile(uiSourceCodeBar)._isDiverged()); | |
| 413 next(); | |
| 414 } | |
| 415 } | 158 } |
| 416 ]); | 159 ]); |
| 417 }; | 160 }; |
| 418 </script> | 161 </script> |
| 419 </head> | 162 </head> |
| 420 <body onload="runTest()"> | 163 <body onload="runTest()"> |
| 421 <p>Tests file system project mappings.</p> | 164 <p>Tests file system project mappings.</p> |
| 422 </body> | 165 </body> |
| 423 </html> | 166 </html> |
| OLD | NEW |