| 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 |
| 10 function test() | 10 function test() |
| 11 { | 11 { |
| 12 var target; | 12 var target; |
| 13 var resourceScriptMapping; | 13 var resourceScriptMapping; |
| 14 var defaultScriptMapping; | 14 var defaultScriptMapping; |
| 15 var persistence; | 15 var persistence; |
| 16 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.projectId(
"file:///var/www"); | 16 var fileSystemProjectId = Bindings.FileSystemWorkspaceBinding.projectId("fil
e:///var/www"); |
| 17 WebInspector.networkMapping.dispose(); | 17 Bindings.networkMapping.dispose(); |
| 18 | 18 |
| 19 function createWorkspaceWithTarget() | 19 function createWorkspaceWithTarget() |
| 20 { | 20 { |
| 21 target = InspectorTest.createWorkspaceWithTarget(false); | 21 target = InspectorTest.createWorkspaceWithTarget(false); |
| 22 var entry = InspectorTest.testDebuggerWorkspaceBinding._targetToData.get
(target); | 22 var entry = InspectorTest.testDebuggerWorkspaceBinding._targetToData.get
(target); |
| 23 resourceScriptMapping = entry._resourceMapping; | 23 resourceScriptMapping = entry._resourceMapping; |
| 24 defaultScriptMapping = entry._defaultMapping; | 24 defaultScriptMapping = entry._defaultMapping; |
| 25 if (persistence) | 25 if (persistence) |
| 26 persistence.dispose(); | 26 persistence.dispose(); |
| 27 persistence = new WebInspector.Persistence(InspectorTest.testWorkspace,
WebInspector.breakpointManager, WebInspector.fileSystemMapping); | 27 persistence = new Persistence.Persistence(InspectorTest.testWorkspace, B
indings.breakpointManager, Workspace.fileSystemMapping); |
| 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 uiSourceCode of uiSourceCodes) { | 34 for (var uiSourceCode of uiSourceCodes) { |
| 35 var binding = persistence.binding(uiSourceCode); | 35 var binding = persistence.binding(uiSourceCode); |
| 36 var url = binding ? binding.network.url() : ""; | 36 var url = binding ? binding.network.url() : ""; |
| 37 InspectorTest.addResult(" " + uiSourceCode.url() + " -> " + url); | 37 InspectorTest.addResult(" " + uiSourceCode.url() + " -> " + url); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 InspectorTest.runTestSuite([ | 41 InspectorTest.runTestSuite([ |
| 42 function testAutomaticMapping(next) | 42 function testAutomaticMapping(next) |
| 43 { | 43 { |
| 44 createWorkspaceWithTarget(); | 44 createWorkspaceWithTarget(); |
| 45 | 45 |
| 46 InspectorTest.addResult("Adding file system."); | 46 InspectorTest.addResult("Adding file system."); |
| 47 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | 47 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 48 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); | 48 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); |
| 49 fs.root.addFile("bar.js", "<bar content>"); | 49 fs.root.addFile("bar.js", "<bar content>"); |
| 50 fs.reportCreated(fileSystemCreated1); | 50 fs.reportCreated(fileSystemCreated1); |
| 51 var networkUISourceCode; | 51 var networkUISourceCode; |
| 52 | 52 |
| 53 function fileSystemCreated1() | 53 function fileSystemCreated1() |
| 54 { | 54 { |
| 55 InspectorTest.addResult("Adding network resource."); | 55 InspectorTest.addResult("Adding network resource."); |
| 56 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 56 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", Common.resourceTypes.Script, "<foo content>", target); |
| 57 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 57 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", Common.resourceTypes.Script, "<foo content>", target); |
| 58 dumpFileSystemUISourceCodesMappings(); | 58 dumpFileSystemUISourceCodesMappings(); |
| 59 | 59 |
| 60 var uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(file
SystemProjectId, "file:///var/www/html/foo.js"); | 60 var uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(file
SystemProjectId, "file:///var/www/html/foo.js"); |
| 61 networkUISourceCode = InspectorTest.testWorkspace.uiSourceCode(W
ebInspector.NetworkProject.projectId(target, target.resourceTreeModel.mainFrame,
false), "http://localhost/html/foo.js"); | 61 networkUISourceCode = InspectorTest.testWorkspace.uiSourceCode(B
indings.NetworkProject.projectId(target, target.resourceTreeModel.mainFrame, fal
se), "http://localhost/html/foo.js"); |
| 62 InspectorTest.addResult("Adding mapping between network and file
system resources."); | 62 InspectorTest.addResult("Adding mapping between network and file
system resources."); |
| 63 InspectorTest.testNetworkMapping.addMapping(networkUISourceCode,
uiSourceCode); | 63 InspectorTest.testNetworkMapping.addMapping(networkUISourceCode,
uiSourceCode); |
| 64 var setting = JSON.stringify(WebInspector.fileSystemMapping._fil
eSystemMappingSetting.get()); | 64 var setting = JSON.stringify(Workspace.fileSystemMapping._fileSy
stemMappingSetting.get()); |
| 65 | 65 |
| 66 InspectorTest.addResult("Emulate reloading inspector."); | 66 InspectorTest.addResult("Emulate reloading inspector."); |
| 67 fs.reportRemoved(); | 67 fs.reportRemoved(); |
| 68 createWorkspaceWithTarget(); | 68 createWorkspaceWithTarget(); |
| 69 WebInspector.fileSystemMapping._fileSystemMappingSetting.set(JSO
N.parse(setting)); | 69 Workspace.fileSystemMapping._fileSystemMappingSetting.set(JSON.p
arse(setting)); |
| 70 WebInspector.fileSystemMapping._loadFromSettings(); | 70 Workspace.fileSystemMapping._loadFromSettings(); |
| 71 fs.reportCreated(fileSystemCreated2); | 71 fs.reportCreated(fileSystemCreated2); |
| 72 } | 72 } |
| 73 | 73 |
| 74 function fileSystemCreated2() | 74 function fileSystemCreated2() |
| 75 { | 75 { |
| 76 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 76 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", Common.resourceTypes.Script, "<foo content>", target); |
| 77 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 77 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", Common.resourceTypes.Script, "<foo content>", target); |
| 78 | 78 |
| 79 dumpFileSystemUISourceCodesMappings(); | 79 dumpFileSystemUISourceCodesMappings(); |
| 80 | 80 |
| 81 InspectorTest.addResult("Removing mapping between network and fi
le system resources."); | 81 InspectorTest.addResult("Removing mapping between network and fi
le system resources."); |
| 82 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"); |
| 83 InspectorTest.testNetworkMapping.removeMapping(uiSourceCode); | 83 InspectorTest.testNetworkMapping.removeMapping(uiSourceCode); |
| 84 | 84 |
| 85 InspectorTest.addResult("Emulate reloading inspector."); | 85 InspectorTest.addResult("Emulate reloading inspector."); |
| 86 fs.reportRemoved(); | 86 fs.reportRemoved(); |
| 87 createWorkspaceWithTarget(); | 87 createWorkspaceWithTarget(); |
| 88 fs.reportCreated(fileSystemCreated3); | 88 fs.reportCreated(fileSystemCreated3); |
| 89 } | 89 } |
| 90 | 90 |
| 91 function fileSystemCreated3() | 91 function fileSystemCreated3() |
| 92 { | 92 { |
| 93 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 93 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ht
ml/foo.js", Common.resourceTypes.Script, "<foo content>", target); |
| 94 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 94 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/ba
r.js", Common.resourceTypes.Script, "<foo content>", target); |
| 95 dumpFileSystemUISourceCodesMappings(); | 95 dumpFileSystemUISourceCodesMappings(); |
| 96 | 96 |
| 97 WebInspector.fileSystemMapping.removeMappingForURL(networkUISour
ceCode.url()); | 97 Workspace.fileSystemMapping.removeMappingForURL(networkUISourceC
ode.url()); |
| 98 fs.reportRemoved(); | 98 fs.reportRemoved(); |
| 99 next(); | 99 next(); |
| 100 } | 100 } |
| 101 }, | 101 }, |
| 102 | 102 |
| 103 function testRemoveProject(next) | 103 function testRemoveProject(next) |
| 104 { | 104 { |
| 105 function dumpWorkspaceUISourceCodes() | 105 function dumpWorkspaceUISourceCodes() |
| 106 { | 106 { |
| 107 InspectorTest.addResult("Dumping uiSourceCodes origin URLs:"); | 107 InspectorTest.addResult("Dumping uiSourceCodes origin URLs:"); |
| 108 var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); | 108 var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); |
| 109 for (var i = 0; i < uiSourceCodes.length; ++i) | 109 for (var i = 0; i < uiSourceCodes.length; ++i) |
| 110 InspectorTest.addResult(" - " + uiSourceCodes[i].url()); | 110 InspectorTest.addResult(" - " + uiSourceCodes[i].url()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 createWorkspaceWithTarget(); | 113 createWorkspaceWithTarget(); |
| 114 | 114 |
| 115 InspectorTest.addResult("Adding file system."); | 115 InspectorTest.addResult("Adding file system."); |
| 116 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | 116 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 117 fs.root.addFile("foo.js", ""); | 117 fs.root.addFile("foo.js", ""); |
| 118 fs.reportCreated(fileSystemCreated); | 118 fs.reportCreated(fileSystemCreated); |
| 119 | 119 |
| 120 function fileSystemCreated() | 120 function fileSystemCreated() |
| 121 { | 121 { |
| 122 dumpWorkspaceUISourceCodes(); | 122 dumpWorkspaceUISourceCodes(); |
| 123 InspectorTest.addResult("Removing project:"); | 123 InspectorTest.addResult("Removing project:"); |
| 124 InspectorTest.testWorkspace.addEventListener(WebInspector.Worksp
ace.Events.ProjectRemoved, projectRemoved); | 124 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace
.Events.ProjectRemoved, projectRemoved); |
| 125 InspectorTest.testTargetManager.removeTarget(target); | 125 InspectorTest.testTargetManager.removeTarget(target); |
| 126 target = null; | 126 target = null; |
| 127 } | 127 } |
| 128 | 128 |
| 129 function projectRemoved() | 129 function projectRemoved() |
| 130 { | 130 { |
| 131 InspectorTest.testWorkspace.removeEventListener(WebInspector.Wor
kspace.Events.ProjectRemoved, projectRemoved); | 131 InspectorTest.testWorkspace.removeEventListener(Workspace.Worksp
ace.Events.ProjectRemoved, projectRemoved); |
| 132 InspectorTest.addResult("Received project removed event."); | 132 InspectorTest.addResult("Received project removed event."); |
| 133 fs.reportRemoved(); | 133 fs.reportRemoved(); |
| 134 setImmediate(next); | 134 setImmediate(next); |
| 135 } | 135 } |
| 136 }, | 136 }, |
| 137 | 137 |
| 138 function testProjectBasedMapping(next) | 138 function testProjectBasedMapping(next) |
| 139 { | 139 { |
| 140 createWorkspaceWithTarget(); | 140 createWorkspaceWithTarget(); |
| 141 | 141 |
| 142 InspectorTest.addResult("Adding file system."); | 142 InspectorTest.addResult("Adding file system."); |
| 143 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | 143 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 144 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); | 144 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); |
| 145 fs.root.mkdir("html2").addFile("bar.js", "<bar content>"); | 145 fs.root.mkdir("html2").addFile("bar.js", "<bar content>"); |
| 146 fs.root.addFile(".devtools", JSON.stringify({ mappings: [ { folder:
"/html/", url: "http://localhost/h1/" }, { folder: "/html2/", url: "http://local
host/h2/" } ]})); | 146 fs.root.addFile(".devtools", JSON.stringify({ mappings: [ { folder:
"/html/", url: "http://localhost/h1/" }, { folder: "/html2/", url: "http://local
host/h2/" } ]})); |
| 147 fs.reportCreated(fileSystemCreated); | 147 fs.reportCreated(fileSystemCreated); |
| 148 | 148 |
| 149 function fileSystemCreated() | 149 function fileSystemCreated() |
| 150 { | 150 { |
| 151 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/h1
/foo.js", WebInspector.resourceTypes.Script, "<foo content>", target); | 151 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/h1
/foo.js", Common.resourceTypes.Script, "<foo content>", target); |
| 152 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/h2
/bar.js", WebInspector.resourceTypes.Script, "<bar content>", target); | 152 InspectorTest.addMockUISourceCodeViaNetwork("http://localhost/h2
/bar.js", Common.resourceTypes.Script, "<bar content>", target); |
| 153 dumpFileSystemUISourceCodesMappings(); | 153 dumpFileSystemUISourceCodesMappings(); |
| 154 fs.reportRemoved(); | 154 fs.reportRemoved(); |
| 155 next(); | 155 next(); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 ]); | 158 ]); |
| 159 }; | 159 }; |
| 160 </script> | 160 </script> |
| 161 </head> | 161 </head> |
| 162 <body onload="runTest()"> | 162 <body onload="runTest()"> |
| 163 <p>Tests file system project mappings.</p> | 163 <p>Tests file system project mappings.</p> |
| 164 </body> | 164 </body> |
| 165 </html> | 165 </html> |
| OLD | NEW |