| 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 src="resources/edit-me.js"></script> | 8 <script src="resources/edit-me.js"></script> |
| 9 <script> | 9 <script> |
| 10 function test() | 10 function test() |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 var manager; | 67 var manager; |
| 68 var resourceScriptMapping; | 68 var resourceScriptMapping; |
| 69 var defaultScriptMapping; | 69 var defaultScriptMapping; |
| 70 | 70 |
| 71 function createObjects(userCallback, useRealTarget) | 71 function createObjects(userCallback, useRealTarget) |
| 72 { | 72 { |
| 73 createWorkspaceWithTarget(callback, useRealTarget); | 73 createWorkspaceWithTarget(callback, useRealTarget); |
| 74 function callback(target) | 74 function callback(target) |
| 75 { | 75 { |
| 76 manager = InspectorTest.createIsolatedFileSystemManager(InspectorTes
t.testWorkspace, InspectorTest.testFileSystemMapping); | 76 manager = InspectorTest.createIsolatedFileSystemManager(InspectorTes
t.testWorkspace, InspectorTest.testFileSystemMapping); |
| 77 resourceScriptMapping = new WebInspector.ResourceScriptMapping(targe
t.debuggerModel, InspectorTest.testWorkspace, InspectorTest.testDebuggerWorkspac
eBinding); | 77 var entry = InspectorTest.testDebuggerWorkspaceBinding._targetToData
.get(target); |
| 78 defaultScriptMapping = new WebInspector.DefaultScriptMapping(target.
debuggerModel, InspectorTest.testWorkspace, InspectorTest.testDebuggerWorkspaceB
inding); | 78 resourceScriptMapping = entry._resourceMapping; |
| 79 defaultScriptMapping = entry._defaultMapping; |
| 79 userCallback(); | 80 userCallback(); |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 | 83 |
| 83 InspectorTest.runTestSuite([ | 84 InspectorTest.runTestSuite([ |
| 84 function testAutomaticMapping(next) | 85 function testAutomaticMapping(next) |
| 85 { | 86 { |
| 86 function uiSourceCodeAdded(uiSourceCode) { } | 87 function uiSourceCodeAdded(uiSourceCode) { } |
| 87 | 88 |
| 88 function dumpFileSystemUISourceCodesMappings() | 89 function dumpFileSystemUISourceCodesMappings() |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 173 |
| 173 var fileSystemPath = "/var/www"; | 174 var fileSystemPath = "/var/www"; |
| 174 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); | 175 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); |
| 175 var files = {"/html/foo.js": originalFileContent, "/bar.js": "<bar c
ontent>"}; | 176 var files = {"/html/foo.js": originalFileContent, "/bar.js": "<bar c
ontent>"}; |
| 176 var uiSourceCode; | 177 var uiSourceCode; |
| 177 var target; | 178 var target; |
| 178 createObjects(step1, true); | 179 createObjects(step1, true); |
| 179 | 180 |
| 180 function step1() | 181 function step1() |
| 181 { | 182 { |
| 183 InspectorTest._originalDebuggerBinding = WebInspector.debuggerWo
rkspaceBinding; |
| 184 WebInspector.debuggerWorkspaceBinding = InspectorTest.testDebugg
erWorkspaceBinding; |
| 182 target = InspectorTest.testTargetManager.targets()[0]; | 185 target = InspectorTest.testTargetManager.targets()[0]; |
| 183 target._connection = WebInspector.targetManager.targets()[0]; | |
| 184 WebInspector._originalTargetManager = WebInspector.targetManager
; | 186 WebInspector._originalTargetManager = WebInspector.targetManager
; |
| 185 WebInspector.targetManager = InspectorTest.testTargetManager; | 187 WebInspector.targetManager = InspectorTest.testTargetManager; |
| 186 InspectorTest.addResult("Adding file system."); | 188 InspectorTest.addResult("Adding file system."); |
| 187 manager.addMockFileSystem(fileSystemPath); | 189 manager.addMockFileSystem(fileSystemPath); |
| 188 InspectorTest.addResult("Adding file system mapping."); | 190 InspectorTest.addResult("Adding file system mapping."); |
| 189 InspectorTest.testFileSystemMapping.addFileMapping(fileSystemPat
h, "http://localhost/", "/"); | 191 InspectorTest.testFileSystemMapping.addFileMapping(fileSystemPat
h, "http://localhost/", "/"); |
| 190 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 2); | 192 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 2); |
| 191 manager.addFiles(fileSystemPath, files); | 193 manager.addFiles(fileSystemPath, files); |
| 192 | 194 |
| 193 loadScript(); | 195 loadScript(); |
| 194 | 196 |
| 195 uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSyst
emProjectId, "html/foo.js"); | 197 uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSyst
emProjectId, "html/foo.js"); |
| 196 InspectorTest.showUISourceCode(uiSourceCode, didShowScriptSource
); | 198 InspectorTest.showUISourceCode(uiSourceCode, didShowScriptSource
); |
| 197 } | 199 } |
| 198 | 200 |
| 199 function dumpUISourceCodeAndScriptContents() | 201 function dumpUISourceCodeAndScriptContents() |
| 200 { | 202 { |
| 201 InspectorTest.addResult("Dumping uiSourceCode and script content
:"); | 203 InspectorTest.addResult("Dumping uiSourceCode and script content
:"); |
| 202 InspectorTest.addResult(" uiSourceCode: " + uiSourceCode.work
ingCopy()); | 204 InspectorTest.addResult(" uiSourceCode: " + uiSourceCode.work
ingCopy()); |
| 203 InspectorTest.addResult(" script: " + scriptContent); | 205 InspectorTest.addResult(" script: " + scriptContent); |
| 204 } | 206 } |
| 205 | 207 |
| 206 function didShowScriptSource(sourceFrame) | 208 function didShowScriptSource(sourceFrame) |
| 207 { | 209 { |
| 208 dumpUISourceCodeAndScriptContents(); | 210 dumpUISourceCodeAndScriptContents(); |
| 209 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 211 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); |
| 210 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 212 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
| 211 | 213 |
| 212 InspectorTest.addResult("Editing uiSourceCode:"); | 214 InspectorTest.addResult("Editing uiSourceCode:"); |
| 213 uiSourceCode.setWorkingCopy("<foo content edited>"); | 215 uiSourceCode.setWorkingCopy("<foo content edited>"); |
| 214 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 216 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); |
| 215 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 217 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
| 216 | 218 |
| 217 function setScriptSourceOverrideFailure(scriptId, newContent, ca
llback) | 219 function setScriptSourceOverrideFailure(scriptId, newContent, ca
llback) |
| 218 { | 220 { |
| 219 callback("error"); | 221 callback("error"); |
| 220 } | 222 } |
| 221 InspectorTest.override(WebInspector.DebuggerModel.prototype, "se
tScriptSource", setScriptSourceOverrideFailure); | 223 InspectorTest.override(WebInspector.DebuggerModel.prototype, "se
tScriptSource", setScriptSourceOverrideFailure); |
| 222 | 224 |
| 223 InspectorTest.addResult("Committing uiSourceCode with live edit
failure:"); | 225 InspectorTest.addResult("Committing uiSourceCode with live edit
failure:"); |
| 224 uiSourceCode.commitWorkingCopy(function() { }); | 226 uiSourceCode.commitWorkingCopy(function() { }); |
| 225 dumpUISourceCodeAndScriptContents(); | 227 dumpUISourceCodeAndScriptContents(); |
| 226 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 228 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); |
| 227 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 229 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
| 228 | 230 |
| 229 InspectorTest.addResult("Reloading with saved but diverged uiSou
rceCode:"); | 231 InspectorTest.addResult("Reloading with saved but diverged uiSou
rceCode:"); |
| 230 unloadScript(); | 232 unloadScript(); |
| 231 InspectorTest.assertTrue(!uiSourceCode.scriptFileForTarget(targe
t), "UISourceCode should not have script file after unloading scripts."); | 233 InspectorTest.assertTrue(!resourceScriptMapping.scriptFile(uiSou
rceCode), "UISourceCode should not have script file after unloading scripts."); |
| 232 InspectorTest.assertTrue(!sourceFrame._muted, "Saved but diverge
d source frame should not be muted"); | 234 InspectorTest.assertTrue(!sourceFrame._muted, "Saved but diverge
d source frame should not be muted"); |
| 233 | 235 |
| 234 InspectorTest.addResult("Loading script."); | 236 InspectorTest.addResult("Loading script."); |
| 235 loadScript(); | 237 loadScript(); |
| 236 dumpUISourceCodeAndScriptContents(); | 238 dumpUISourceCodeAndScriptContents(); |
| 237 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 239 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); |
| 238 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 240 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
| 239 | 241 |
| 240 InspectorTest.addResult("Editing uiSourceCode again:"); | 242 InspectorTest.addResult("Editing uiSourceCode again:"); |
| 241 uiSourceCode.setWorkingCopy("<foo content edited again>"); | 243 uiSourceCode.setWorkingCopy("<foo content edited again>"); |
| 242 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 244 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); |
| 243 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 245 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
| 244 | 246 |
| 245 function setScriptSourceOverrideSuccess(scriptId, newContent, ca
llback) | 247 function setScriptSourceOverrideSuccess(scriptId, newContent, ca
llback) |
| 246 { | 248 { |
| 247 scriptContent = newContent; | 249 scriptContent = newContent; |
| 248 callback(); | 250 callback(); |
| 249 } | 251 } |
| 250 InspectorTest.override(WebInspector.DebuggerModel.prototype, "se
tScriptSource", setScriptSourceOverrideSuccess); | 252 InspectorTest.override(WebInspector.DebuggerModel.prototype, "se
tScriptSource", setScriptSourceOverrideSuccess); |
| 251 | 253 |
| 252 InspectorTest.addResult("Committing uiSourceCode again (with liv
e edit success now):"); | 254 InspectorTest.addResult("Committing uiSourceCode again (with liv
e edit success now):"); |
| 253 uiSourceCode.commitWorkingCopy(function() { }); | 255 uiSourceCode.commitWorkingCopy(function() { }); |
| 254 dumpUISourceCodeAndScriptContents(); | 256 dumpUISourceCodeAndScriptContents(); |
| 255 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 257 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); |
| 256 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 258 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
| 257 | 259 |
| 258 InspectorTest.addResult("Reloading page:"); | 260 InspectorTest.addResult("Reloading page:"); |
| 259 unloadScript(); | 261 unloadScript(); |
| 260 InspectorTest.assertTrue(!uiSourceCode.scriptFileForTarget(targe
t), "UISourceCode should not have script file after unloading scripts."); | 262 InspectorTest.assertTrue(!resourceScriptMapping.scriptFile(uiSou
rceCode), "UISourceCode should not have script file after unloading scripts."); |
| 261 InspectorTest.assertTrue(!sourceFrame._muted, "Saved and merged
source frame should not be muted"); | 263 InspectorTest.assertTrue(!sourceFrame._muted, "Saved and merged
source frame should not be muted"); |
| 262 InspectorTest.addResult("Loading script."); | 264 InspectorTest.addResult("Loading script."); |
| 263 loadScript(); | 265 loadScript(); |
| 264 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 266 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); |
| 265 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 267 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
| 266 | 268 |
| 267 InspectorTest.addResult("Editing uiSourceCode again and reloadin
g while it is dirty:"); | 269 InspectorTest.addResult("Editing uiSourceCode again and reloadin
g while it is dirty:"); |
| 268 uiSourceCode.setWorkingCopy("<foo content edited and dirty>"); | 270 uiSourceCode.setWorkingCopy("<foo content edited and dirty>"); |
| 269 unloadScript(); | 271 unloadScript(); |
| 270 InspectorTest.assertTrue(!uiSourceCode.scriptFileForTarget(targe
t), "UISourceCode should not have script file after unloading scripts."); | 272 InspectorTest.assertTrue(!resourceScriptMapping.scriptFile(uiSou
rceCode), "UISourceCode should not have script file after unloading scripts."); |
| 271 InspectorTest.assertTrue(sourceFrame._muted, "Dirty source frame
should be muted"); | 273 InspectorTest.assertTrue(sourceFrame._muted, "Dirty source frame
should be muted"); |
| 272 InspectorTest.addResult("Loading script."); | 274 InspectorTest.addResult("Loading script."); |
| 273 loadScript(); | 275 loadScript(); |
| 274 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 276 InspectorTest.addResult(" - hasDivergedFromVM: " + !!resourceScr
iptMapping.scriptFile(uiSourceCode).hasDivergedFromVM()); |
| 275 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 277 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
| 276 | 278 |
| 277 unloadScript(); | 279 unloadScript(); |
| 278 loadScript; | 280 loadScript; |
| 279 | 281 |
| 280 InspectorTest.testFileSystemMapping.removeFileMapping(fileSystem
Path, "http://localhost/", "/"); | 282 InspectorTest.testFileSystemMapping.removeFileMapping(fileSystem
Path, "http://localhost/", "/"); |
| 283 WebInspector.debuggerWorkspaceBinding = InspectorTest._originalD
ebuggerBinding; |
| 281 next(); | 284 next(); |
| 282 } | 285 } |
| 283 }, | 286 }, |
| 284 | 287 |
| 285 function testLiveEditReload(next) | 288 function testLiveEditReload(next) |
| 286 { | 289 { |
| 287 InspectorTest.showScriptSource("edit-me.js", didShowScriptSource); | 290 InspectorTest.showScriptSource("edit-me.js", didShowScriptSource); |
| 288 | 291 |
| 289 function didShowScriptSource(sourceFrame) | 292 function didShowScriptSource(sourceFrame) |
| 290 { | 293 { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 465 } |
| 463 }, | 466 }, |
| 464 ]); | 467 ]); |
| 465 }; | 468 }; |
| 466 </script> | 469 </script> |
| 467 </head> | 470 </head> |
| 468 <body onload="runTest()"> | 471 <body onload="runTest()"> |
| 469 <p>Tests file system project mappings.</p> | 472 <p>Tests file system project mappings.</p> |
| 470 </body> | 473 </body> |
| 471 </html> | 474 </html> |
| OLD | NEW |