| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="inspector-test.js"></script> |
| 4 <script src="debugger-test.js"></script> |
| 5 <script src="isolated-filesystem-test.js"></script> |
| 6 <script> |
| 7 function addScript(url) |
| 8 { |
| 9 var script = document.createElement("script"); |
| 10 script.setAttribute("src", url); |
| 11 document.head.appendChild(script); |
| 12 } |
| 13 |
| 14 function test() |
| 15 { |
| 16 var target = InspectorTest.mainTarget; |
| 17 var persistence = Persistence.persistence; |
| 18 var fileSystemProjectId = Persistence.FileSystemWorkspaceBinding.projectId("
file:///var/www"); |
| 19 |
| 20 function dumpFileSystemUISourceCodesMappings() |
| 21 { |
| 22 var uiSourceCodes = Workspace.workspace.project(fileSystemProjectId).uiS
ourceCodes(); |
| 23 InspectorTest.addResult("UISourceCode uri to url mappings:"); |
| 24 for (var uiSourceCode of uiSourceCodes) { |
| 25 var binding = persistence.binding(uiSourceCode); |
| 26 var url = binding ? binding.network.url() : ""; |
| 27 InspectorTest.addResult(" " + uiSourceCode.url() + " -> " + url); |
| 28 } |
| 29 } |
| 30 |
| 31 InspectorTest.runTestSuite([ |
| 32 function testAutomaticMapping(next) |
| 33 { |
| 34 InspectorTest.addResult("Adding file system."); |
| 35 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 36 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); |
| 37 fs.root.addFile("bar.js", "<bar content>"); |
| 38 fs.reportCreated(fileSystemCreated1); |
| 39 var networkUISourceCode; |
| 40 |
| 41 function fileSystemCreated1() |
| 42 { |
| 43 InspectorTest.addResult("Adding network resource."); |
| 44 InspectorTest.waitForUISourceCode(scriptsAdded, "resources/bar.j
s"); |
| 45 InspectorTest.evaluateInPage("addScript('resources/html/foo.js')
"); |
| 46 InspectorTest.evaluateInPage("addScript('resources/bar.js')"); |
| 47 } |
| 48 |
| 49 function scriptsAdded() |
| 50 { |
| 51 dumpFileSystemUISourceCodesMappings(); |
| 52 |
| 53 var uiSourceCode = Workspace.workspace.uiSourceCode(fileSystemPr
ojectId, "file:///var/www/html/foo.js"); |
| 54 networkUISourceCode = Workspace.workspace.uiSourceCode(Bindings.
NetworkProject.projectId(target, InspectorTest.resourceTreeModel.mainFrame, fals
e), "http://127.0.0.1:8000/inspector/resources/html/foo.js"); |
| 55 InspectorTest.addResult("Adding mapping between network and file
system resources."); |
| 56 |
| 57 var fileSystemPath = Persistence.FileSystemWorkspaceBinding.file
SystemPath(uiSourceCode.project().id()); |
| 58 Workspace.fileSystemMapping.addMappingForResource(networkUISourc
eCode.url(), fileSystemPath, uiSourceCode.url()); |
| 59 var setting = JSON.stringify(Workspace.fileSystemMapping._fileSy
stemMappingSetting.get()); |
| 60 |
| 61 InspectorTest.addResult("Emulate reloading inspector."); |
| 62 fs.reportRemoved(); |
| 63 Workspace.fileSystemMapping._fileSystemMappingSetting.set(JSON.p
arse(setting)); |
| 64 Workspace.fileSystemMapping._loadFromSettings(); |
| 65 fs.reportCreated(fileSystemCreated2); |
| 66 } |
| 67 |
| 68 function fileSystemCreated2() |
| 69 { |
| 70 dumpFileSystemUISourceCodesMappings(); |
| 71 |
| 72 InspectorTest.addResult("Removing mapping between network and fi
le system resources."); |
| 73 var uiSourceCode = Workspace.workspace.uiSourceCode(fileSystemPr
ojectId, "file:///var/www/html/foo.js"); |
| 74 Workspace.fileSystemMapping.removeMappingForURL(uiSourceCode.url
()); |
| 75 |
| 76 InspectorTest.addResult("Emulate reloading inspector."); |
| 77 fs.reportRemoved(); |
| 78 fs.reportCreated(fileSystemCreated3); |
| 79 } |
| 80 |
| 81 function fileSystemCreated3() |
| 82 { |
| 83 dumpFileSystemUISourceCodesMappings(); |
| 84 |
| 85 Workspace.fileSystemMapping.removeMappingForURL(networkUISourceC
ode.url()); |
| 86 fs.reportRemoved(); |
| 87 next(); |
| 88 } |
| 89 }, |
| 90 |
| 91 function testProjectBasedMapping(next) |
| 92 { |
| 93 InspectorTest.addResult("Adding file system."); |
| 94 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 95 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); |
| 96 fs.root.mkdir("html2").addFile("bar.js", "<bar content>"); |
| 97 fs.root.addFile(".devtools", JSON.stringify({ mappings: [ { folder:
"/html/", url: "http://127.0.0.1:8000/inspector/resources/html/" }, { folder: "/
html2/", url: "http://127.0.0.1:8000/inspector/resources/html2/" } ]})); |
| 98 fs.reportCreated(fileSystemCreated); |
| 99 |
| 100 function fileSystemCreated() |
| 101 { |
| 102 InspectorTest.evaluateInPage("addScript('resources/html/foo.js')
"); |
| 103 InspectorTest.evaluateInPage("addScript('resources/html2/bar.js'
)"); |
| 104 InspectorTest.waitForUISourceCode(scriptsAdded, "resources/html2
/bar.js"); |
| 105 } |
| 106 |
| 107 function scriptsAdded() |
| 108 { |
| 109 dumpFileSystemUISourceCodesMappings(); |
| 110 fs.reportRemoved(); |
| 111 next(); |
| 112 } |
| 113 } |
| 114 ]); |
| 115 }; |
| 116 </script> |
| 117 </head> |
| 118 <body onload="runTest()"> |
| 119 <p>Tests file system project mappings.</p> |
| 120 </body> |
| 121 </html> |
| OLD | NEW |