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() |
11 { | 11 { |
| 12 var mockTargetId = 1; |
| 13 var MockTarget = function(name, connection, callback) |
| 14 { |
| 15 WebInspector.Target.call(this, name, connection, callback); |
| 16 } |
| 17 MockTarget.prototype = { |
| 18 _loadedWithCapabilities: function(callback) |
| 19 { |
| 20 this.debuggerModel = new WebInspector.DebuggerModel(this); |
| 21 this.runtimeModel = WebInspector.targetManager.mainTarget().runtimeM
odel; |
| 22 this.consoleModel = WebInspector.targetManager.mainTarget().consoleM
odel; |
| 23 |
| 24 if (callback) |
| 25 callback(); |
| 26 }, |
| 27 |
| 28 __proto__: WebInspector.Target.prototype |
| 29 } |
| 30 |
| 31 function createMockTarget(userCallback, useRealTarget) |
| 32 { |
| 33 var target = new MockTarget("mock-target-" + (mockTargetId++), new Inspe
ctorBackendClass.StubConnection(), callback); |
| 34 function callback() |
| 35 { |
| 36 InspectorTest.testTargetManager.addTarget(target); |
| 37 setTimeout(function() { userCallback(target); }, 0); |
| 38 } |
| 39 } |
| 40 |
| 41 function createWorkspaceWithTarget(userCallback, useRealTarget) |
| 42 { |
| 43 InspectorTest.createWorkspace(); |
| 44 createMockTarget(callback, useRealTarget); |
| 45 function callback(target) |
| 46 { |
| 47 target.resourceTreeModel = WebInspector.targetManager.mainTarget().r
esourceTreeModel; |
| 48 userCallback(target); |
| 49 } |
| 50 } |
| 51 |
12 function dumpUISourceCodes(uiSourceCodes, next) | 52 function dumpUISourceCodes(uiSourceCodes, next) |
13 { | 53 { |
14 innerDumpUISourceCodes(uiSourceCodes, 0, next); | 54 innerDumpUISourceCodes(uiSourceCodes, 0, next); |
15 | 55 |
16 function innerDumpUISourceCodes(uiSourceCodes, startIndex, next) | 56 function innerDumpUISourceCodes(uiSourceCodes, startIndex, next) |
17 { | 57 { |
18 InspectorTest.addResult(""); | 58 InspectorTest.addResult(""); |
19 if (startIndex === uiSourceCodes.length) { | 59 if (startIndex === uiSourceCodes.length) { |
20 next(); | 60 next(); |
21 return; | 61 return; |
22 } | 62 } |
23 InspectorTest.dumpUISourceCode(uiSourceCodes[startIndex], innerDumpU
ISourceCodes.bind(this, uiSourceCodes, startIndex + 1, next)); | 63 InspectorTest.dumpUISourceCode(uiSourceCodes[startIndex], innerDumpU
ISourceCodes.bind(this, uiSourceCodes, startIndex + 1, next)); |
24 } | 64 } |
25 } | 65 } |
26 | 66 |
27 var manager; | 67 var manager; |
28 var resourceScriptMapping; | 68 var resourceScriptMapping; |
29 var defaultScriptMapping; | 69 var defaultScriptMapping; |
30 function createObjects() | 70 |
| 71 function createObjects(userCallback, useRealTarget) |
31 { | 72 { |
32 InspectorTest.createWorkspace(); | 73 createWorkspaceWithTarget(callback, useRealTarget); |
33 manager = InspectorTest.createIsolatedFileSystemManager(InspectorTest.te
stWorkspace, InspectorTest.testFileSystemMapping); | 74 function callback(target) |
34 resourceScriptMapping = new WebInspector.ResourceScriptMapping(WebInspec
tor.debuggerModel, InspectorTest.testWorkspace); | 75 { |
35 defaultScriptMapping = new WebInspector.DefaultScriptMapping(WebInspecto
r.debuggerModel,InspectorTest.testWorkspace); | 76 manager = InspectorTest.createIsolatedFileSystemManager(InspectorTes
t.testWorkspace, InspectorTest.testFileSystemMapping); |
| 77 resourceScriptMapping = new WebInspector.ResourceScriptMapping(targe
t.debuggerModel, InspectorTest.testWorkspace, InspectorTest.testDebuggerWorkspac
eBinding); |
| 78 defaultScriptMapping = new WebInspector.DefaultScriptMapping(target.
debuggerModel, InspectorTest.testWorkspace, InspectorTest.testDebuggerWorkspaceB
inding); |
| 79 userCallback(); |
| 80 } |
36 } | 81 } |
37 | 82 |
38 InspectorTest.runTestSuite([ | 83 InspectorTest.runTestSuite([ |
39 function testAutomaticMapping(next) | 84 function testAutomaticMapping(next) |
40 { | 85 { |
41 function uiSourceCodeAdded(uiSourceCode) { } | 86 function uiSourceCodeAdded(uiSourceCode) { } |
42 | 87 |
43 function dumpFileSystemUISourceCodesMappings() | 88 function dumpFileSystemUISourceCodesMappings() |
44 { | 89 { |
45 var uiSourceCodes = InspectorTest.testWorkspace.project(fileSyst
emProjectId).uiSourceCodes(); | 90 var uiSourceCodes = InspectorTest.testWorkspace.project(fileSyst
emProjectId).uiSourceCodes(); |
46 InspectorTest.addResult("UISourceCode uri to url mappings:"); | 91 InspectorTest.addResult("UISourceCode uri to url mappings:"); |
47 for (var i = 0; i < uiSourceCodes.length; ++i) | 92 for (var i = 0; i < uiSourceCodes.length; ++i) |
48 InspectorTest.addResult(" " + uiSourceCodes[i].uri() + "
-> " + uiSourceCodes[i].url); | 93 InspectorTest.addResult(" " + uiSourceCodes[i].uri() + "
-> " + uiSourceCodes[i].url); |
49 } | 94 } |
50 | 95 |
51 var fileSystemPath = "/var/www"; | 96 var fileSystemPath = "/var/www"; |
52 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); | 97 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); |
53 var files = {"/html/foo.js": "<foo content>", "/bar.js": "<bar conte
nt>"}; | 98 var files = {"/html/foo.js": "<foo content>", "/bar.js": "<bar conte
nt>"}; |
| 99 var uiSourceCode; |
| 100 var networkUISourceCode; |
| 101 var setting; |
54 | 102 |
55 createObjects(); | 103 createObjects(step1); |
56 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed, 4); | 104 function step1() |
57 InspectorTest.addResult("Adding file system."); | 105 { |
58 manager.addMockFileSystem(fileSystemPath); | 106 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 4); |
59 manager.addFiles(fileSystemPath, files); | 107 InspectorTest.addResult("Adding file system."); |
60 InspectorTest.addResult("Adding network resource."); | 108 manager.addMockFileSystem(fileSystemPath); |
61 InspectorTest.addMockUISourceCodeToWorkspace("http://localhost/html/
foo.js", WebInspector.resourceTypes.Script, "<foo content>"); | 109 manager.addFiles(fileSystemPath, files); |
62 InspectorTest.addMockUISourceCodeToWorkspace("http://localhost/bar.j
s", WebInspector.resourceTypes.Script, "<foo content>"); | 110 InspectorTest.addResult("Adding network resource."); |
63 dumpFileSystemUISourceCodesMappings(); | 111 InspectorTest.addMockUISourceCodeToWorkspace("http://localhost/h
tml/foo.js", WebInspector.resourceTypes.Script, "<foo content>"); |
64 var uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSyst
emProjectId, "html/foo.js"); | 112 InspectorTest.addMockUISourceCodeToWorkspace("http://localhost/b
ar.js", WebInspector.resourceTypes.Script, "<foo content>"); |
65 var networkUISourceCode = InspectorTest.testWorkspace.uiSourceCode("
http://localhost", "html/foo.js"); | 113 dumpFileSystemUISourceCodesMappings(); |
66 InspectorTest.override(WebInspector.SourcesPanel.prototype, "_sugges
tReload", function() { }); | 114 uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSyst
emProjectId, "html/foo.js"); |
67 InspectorTest.addResult("Adding mapping between network and file sys
tem resources."); | 115 networkUISourceCode = InspectorTest.testWorkspace.uiSourceCode("
http://localhost", "html/foo.js"); |
68 InspectorTest.testWorkspace.addMapping(networkUISourceCode, uiSource
Code, manager.fileSystemWorkspaceBinding); | 116 InspectorTest.override(WebInspector.SourcesPanel.prototype, "_su
ggestReload", function() { }); |
69 var setting = InspectorTest.testFileSystemMapping._fileSystemMapping
Setting; | 117 InspectorTest.addResult("Adding mapping between network and file
system resources."); |
70 InspectorTest.addResult("Emulate reloading inspector."); | 118 InspectorTest.testWorkspace.addMapping(networkUISourceCode, uiSo
urceCode, manager.fileSystemWorkspaceBinding); |
71 createObjects(); | 119 setting = InspectorTest.testFileSystemMapping._fileSystemMapping
Setting; |
72 InspectorTest.testFileSystemMapping._fileSystemMappingSetting = sett
ing; | 120 InspectorTest.addResult("Emulate reloading inspector."); |
73 InspectorTest.testFileSystemMapping._loadFromSettings(); | 121 createObjects(step2); |
74 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed, 2); | 122 } |
75 manager.addMockFileSystem(fileSystemPath, true); | |
76 manager.addFiles(fileSystemPath, files); | |
77 dumpFileSystemUISourceCodesMappings(); | |
78 InspectorTest.addResult("Removing mapping between network and file s
ystem resources."); | |
79 uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSystemPr
ojectId, "html/foo.js"); | |
80 InspectorTest.testWorkspace.removeMapping(uiSourceCode); | |
81 | 123 |
82 InspectorTest.addResult("Emulate reloading inspector."); | 124 function step2() |
83 createObjects(); | 125 { |
84 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed, 2); | 126 InspectorTest.testFileSystemMapping._fileSystemMappingSetting =
setting; |
85 manager.addMockFileSystem(fileSystemPath); | 127 InspectorTest.testFileSystemMapping._loadFromSettings(); |
86 manager.addFiles(fileSystemPath, files); | 128 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 2); |
87 dumpFileSystemUISourceCodesMappings(); | 129 manager.addMockFileSystem(fileSystemPath, true); |
| 130 manager.addFiles(fileSystemPath, files); |
| 131 dumpFileSystemUISourceCodesMappings(); |
| 132 InspectorTest.addResult("Removing mapping between network and fi
le system resources."); |
| 133 uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSyst
emProjectId, "html/foo.js"); |
| 134 InspectorTest.testWorkspace.removeMapping(uiSourceCode); |
88 | 135 |
89 InspectorTest.testFileSystemMapping.removeMappingForURL(networkUISou
rceCode.url); | 136 InspectorTest.addResult("Emulate reloading inspector."); |
90 next(); | 137 createObjects(step3); |
| 138 } |
| 139 |
| 140 function step3() |
| 141 { |
| 142 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 2); |
| 143 manager.addMockFileSystem(fileSystemPath); |
| 144 manager.addFiles(fileSystemPath, files); |
| 145 dumpFileSystemUISourceCodesMappings(); |
| 146 |
| 147 InspectorTest.testFileSystemMapping.removeMappingForURL(networkU
ISourceCode.url); |
| 148 next(); |
| 149 } |
91 }, | 150 }, |
92 | 151 |
93 function testScriptFileOnReloadWithDirtyFile(next) | 152 function testScriptFileOnReloadWithDirtyFile(next) |
94 { | 153 { |
95 var originalFileContent = "<foo content>"; | 154 var originalFileContent = "<foo content>"; |
96 var scriptURL = "http://localhost/html/foo.js"; | 155 var scriptURL = "http://localhost/html/foo.js"; |
97 var scriptContent = originalFileContent + "\n //# sourceURL=" + scr
iptURL + " \n "; | 156 var scriptContent = originalFileContent + "\n //# sourceURL=" + scr
iptURL + " \n "; |
98 function uiSourceCodeAdded(uiSourceCode) { } | 157 function uiSourceCodeAdded(uiSourceCode) { } |
99 | 158 |
100 function unloadScript() | 159 function unloadScript() |
101 { | 160 { |
102 resourceScriptMapping._debuggerReset(); | 161 resourceScriptMapping._debuggerReset(); |
103 defaultScriptMapping._debuggerReset(); | 162 defaultScriptMapping._debuggerReset(); |
104 } | 163 } |
105 | 164 |
106 function loadScript() | 165 function loadScript() |
107 { | 166 { |
108 script = InspectorTest.createScriptMock(scriptURL, 0, 0, false,
scriptContent); | 167 script = InspectorTest.createScriptMock(scriptURL, 0, 0, false,
scriptContent, InspectorTest.testTargetManager.targets()[0]); |
109 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 1); | 168 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 1); |
110 defaultScriptMapping.addScript(script); | 169 defaultScriptMapping.addScript(script); |
111 resourceScriptMapping.addScript(script); | 170 resourceScriptMapping.addScript(script); |
112 } | 171 } |
113 | 172 |
114 var fileSystemPath = "/var/www"; | 173 var fileSystemPath = "/var/www"; |
115 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); | 174 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); |
116 var files = {"/html/foo.js": originalFileContent, "/bar.js": "<bar c
ontent>"}; | 175 var files = {"/html/foo.js": originalFileContent, "/bar.js": "<bar c
ontent>"}; |
117 createObjects(); | 176 var uiSourceCode; |
118 InspectorTest.addResult("Adding file system."); | 177 var target; |
119 manager.addMockFileSystem(fileSystemPath); | 178 createObjects(step1, true); |
120 InspectorTest.addResult("Adding file system mapping."); | |
121 InspectorTest.testFileSystemMapping.addFileMapping(fileSystemPath, "
http://localhost/", "/"); | |
122 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed, 2); | |
123 manager.addFiles(fileSystemPath, files); | |
124 | 179 |
125 loadScript(); | 180 function step1() |
| 181 { |
| 182 target = InspectorTest.testTargetManager.targets()[0]; |
| 183 target._connection = WebInspector.targetManager.targets()[0]; |
| 184 WebInspector._originalTargetManager = WebInspector.targetManager
; |
| 185 WebInspector.targetManager = InspectorTest.testTargetManager; |
| 186 InspectorTest.addResult("Adding file system."); |
| 187 manager.addMockFileSystem(fileSystemPath); |
| 188 InspectorTest.addResult("Adding file system mapping."); |
| 189 InspectorTest.testFileSystemMapping.addFileMapping(fileSystemPat
h, "http://localhost/", "/"); |
| 190 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 2); |
| 191 manager.addFiles(fileSystemPath, files); |
126 | 192 |
127 var uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSyst
emProjectId, "html/foo.js"); | 193 loadScript(); |
128 InspectorTest.showUISourceCode(uiSourceCode, didShowScriptSource); | 194 |
| 195 uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSyst
emProjectId, "html/foo.js"); |
| 196 InspectorTest.showUISourceCode(uiSourceCode, didShowScriptSource
); |
| 197 } |
129 | 198 |
130 function dumpUISourceCodeAndScriptContents() | 199 function dumpUISourceCodeAndScriptContents() |
131 { | 200 { |
132 InspectorTest.addResult("Dumping uiSourceCode and script content
:"); | 201 InspectorTest.addResult("Dumping uiSourceCode and script content
:"); |
133 InspectorTest.addResult(" uiSourceCode: " + uiSourceCode.work
ingCopy()); | 202 InspectorTest.addResult(" uiSourceCode: " + uiSourceCode.work
ingCopy()); |
134 InspectorTest.addResult(" script: " + scriptContent); | 203 InspectorTest.addResult(" script: " + scriptContent); |
135 } | 204 } |
136 | 205 |
137 function didShowScriptSource(sourceFrame) | 206 function didShowScriptSource(sourceFrame) |
138 { | 207 { |
139 var target = WebInspector.targetManager.targets()[0]; | |
140 dumpUISourceCodeAndScriptContents(); | 208 dumpUISourceCodeAndScriptContents(); |
141 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 209 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); |
142 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 210 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
143 | 211 |
144 InspectorTest.addResult("Editing uiSourceCode:"); | 212 InspectorTest.addResult("Editing uiSourceCode:"); |
145 uiSourceCode.setWorkingCopy("<foo content edited>"); | 213 uiSourceCode.setWorkingCopy("<foo content edited>"); |
146 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 214 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); |
147 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 215 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
148 | 216 |
149 function setScriptSourceOverrideFailure(scriptId, newContent, ca
llback) | 217 function setScriptSourceOverrideFailure(scriptId, newContent, ca
llback) |
150 { | 218 { |
151 callback("error"); | 219 callback("error"); |
152 } | 220 } |
153 InspectorTest.override(WebInspector.debuggerModel, "setScriptSou
rce", setScriptSourceOverrideFailure); | 221 InspectorTest.override(WebInspector.DebuggerModel.prototype, "se
tScriptSource", setScriptSourceOverrideFailure); |
154 | 222 |
155 InspectorTest.addResult("Committing uiSourceCode with live edit
failure:"); | 223 InspectorTest.addResult("Committing uiSourceCode with live edit
failure:"); |
156 uiSourceCode.commitWorkingCopy(function() { }); | 224 uiSourceCode.commitWorkingCopy(function() { }); |
157 dumpUISourceCodeAndScriptContents(); | 225 dumpUISourceCodeAndScriptContents(); |
158 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 226 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); |
159 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 227 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
160 | 228 |
161 InspectorTest.addResult("Reloading with saved but diverged uiSou
rceCode:"); | 229 InspectorTest.addResult("Reloading with saved but diverged uiSou
rceCode:"); |
162 unloadScript(); | 230 unloadScript(); |
163 InspectorTest.assertTrue(!uiSourceCode.scriptFileForTarget(targe
t), "UISourceCode should not have script file after unloading scripts."); | 231 InspectorTest.assertTrue(!uiSourceCode.scriptFileForTarget(targe
t), "UISourceCode should not have script file after unloading scripts."); |
164 InspectorTest.assertTrue(!sourceFrame._muted, "Saved but diverge
d source frame should not be muted"); | 232 InspectorTest.assertTrue(!sourceFrame._muted, "Saved but diverge
d source frame should not be muted"); |
165 | 233 |
166 InspectorTest.addResult("Loading script."); | 234 InspectorTest.addResult("Loading script."); |
167 loadScript(); | 235 loadScript(); |
168 dumpUISourceCodeAndScriptContents(); | 236 dumpUISourceCodeAndScriptContents(); |
169 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 237 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); |
170 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 238 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
171 | 239 |
172 InspectorTest.addResult("Editing uiSourceCode again:"); | 240 InspectorTest.addResult("Editing uiSourceCode again:"); |
173 uiSourceCode.setWorkingCopy("<foo content edited again>"); | 241 uiSourceCode.setWorkingCopy("<foo content edited again>"); |
174 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 242 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); |
175 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 243 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
176 | 244 |
177 function setScriptSourceOverrideSuccess(scriptId, newContent, ca
llback) | 245 function setScriptSourceOverrideSuccess(scriptId, newContent, ca
llback) |
178 { | 246 { |
179 scriptContent = newContent; | 247 scriptContent = newContent; |
180 callback(); | 248 callback(); |
181 } | 249 } |
182 InspectorTest.override(WebInspector.debuggerModel, "setScriptSou
rce", setScriptSourceOverrideSuccess); | 250 InspectorTest.override(WebInspector.DebuggerModel.prototype, "se
tScriptSource", setScriptSourceOverrideSuccess); |
183 | 251 |
184 InspectorTest.addResult("Committing uiSourceCode again (with liv
e edit success now):"); | 252 InspectorTest.addResult("Committing uiSourceCode again (with liv
e edit success now):"); |
185 uiSourceCode.commitWorkingCopy(function() { }); | 253 uiSourceCode.commitWorkingCopy(function() { }); |
186 dumpUISourceCodeAndScriptContents(); | 254 dumpUISourceCodeAndScriptContents(); |
187 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); | 255 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCod
e.scriptFileForTarget(target).hasDivergedFromVM()); |
188 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); | 256 InspectorTest.addResult(" - sourceFrame._muted: " + !!sourceFram
e._muted); |
189 | 257 |
190 InspectorTest.addResult("Reloading page:"); | 258 InspectorTest.addResult("Reloading page:"); |
191 unloadScript(); | 259 unloadScript(); |
192 InspectorTest.assertTrue(!uiSourceCode.scriptFileForTarget(targe
t), "UISourceCode should not have script file after unloading scripts."); | 260 InspectorTest.assertTrue(!uiSourceCode.scriptFileForTarget(targe
t), "UISourceCode should not have script file after unloading scripts."); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 306 } |
239 | 307 |
240 function pageReloaded() | 308 function pageReloaded() |
241 { | 309 { |
242 // Now reload again as part of test. | 310 // Now reload again as part of test. |
243 InspectorTest.reloadPage(pageReloadedAgain); | 311 InspectorTest.reloadPage(pageReloadedAgain); |
244 } | 312 } |
245 | 313 |
246 function pageReloadedAgain() | 314 function pageReloadedAgain() |
247 { | 315 { |
| 316 WebInspector.targetManager = WebInspector._originalTargetManager
; |
248 InspectorTest.showScriptSource("edit-me.js", didShowFile); | 317 InspectorTest.showScriptSource("edit-me.js", didShowFile); |
249 } | 318 } |
250 | 319 |
251 function didShowFile(sourceFrame) | 320 function didShowFile(sourceFrame) |
252 { | 321 { |
253 replaceInSource(sourceFrame, "return 0;", "return \"live-edited
string\";", didEditScriptSource); | 322 replaceInSource(sourceFrame, "return 0;", "return \"live-edited
string\";", didEditScriptSource); |
254 } | 323 } |
255 | 324 |
256 function didEditScriptSource() | 325 function didEditScriptSource() |
257 { | 326 { |
258 InspectorTest.evaluateInPage("f()", didEvaluateInPage) | 327 InspectorTest.evaluateInPage("f()", didEvaluateInPage) |
259 } | 328 } |
260 | 329 |
261 function didEvaluateInPage(result) | 330 function didEvaluateInPage(result) |
262 { | 331 { |
263 InspectorTest.assertEquals("live-edited string", result.descript
ion, "edited function returns wrong result"); | 332 InspectorTest.assertEquals("live-edited string", result.descript
ion, "edited function returns wrong result"); |
264 var panel = WebInspector.inspectorView.panel("sources"); | 333 var panel = WebInspector.inspectorView.panel("sources"); |
265 InspectorTest.dumpSourceFrameContents(panel.visibleView); | 334 InspectorTest.dumpSourceFrameContents(panel.visibleView); |
266 next(); | 335 next(); |
267 } | 336 } |
268 | 337 |
269 function replaceInSource(sourceFrame, string, replacement, callback) | 338 function replaceInSource(sourceFrame, string, replacement, callback) |
270 { | 339 { |
271 InspectorTest.addSniffer(WebInspector.debuggerModel, "_didEditSc
riptSource", callback); | 340 InspectorTest.addSniffer(WebInspector.DebuggerModel.prototype, "
_didEditScriptSource", callback); |
272 InspectorTest.replaceInSource(sourceFrame, string, replacement); | 341 InspectorTest.replaceInSource(sourceFrame, string, replacement); |
273 InspectorTest.commitSource(sourceFrame); | 342 InspectorTest.commitSource(sourceFrame); |
274 | |
275 } | 343 } |
276 }, | 344 }, |
277 | 345 |
278 function testExcludingFolders(next) | 346 function testExcludingFolders(next) |
279 { | 347 { |
280 function uiSourceCodeAdded(uiSourceCode) {} | 348 function uiSourceCodeAdded(uiSourceCode) {} |
281 function uiSourceCodeRemoved(uiSourceCode) {} | 349 function uiSourceCodeRemoved(uiSourceCode) {} |
282 | 350 |
283 function dumpWorkspaceUISourceCodes() | 351 function dumpWorkspaceUISourceCodes() |
284 { | 352 { |
285 InspectorTest.addResult("Dumping uiSourceCodes origin URLs:"); | 353 InspectorTest.addResult("Dumping uiSourceCodes origin URLs:"); |
286 var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); | 354 var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); |
287 for (var i = 0; i < uiSourceCodes.length; ++i) | 355 for (var i = 0; i < uiSourceCodes.length; ++i) |
288 InspectorTest.addResult(" - " + uiSourceCodes[i].originURL(
)); | 356 InspectorTest.addResult(" - " + uiSourceCodes[i].originURL(
)); |
289 } | 357 } |
290 | 358 |
291 var fileSystemPath = "/var/www"; | 359 var fileSystemPath = "/var/www"; |
292 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); | 360 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); |
293 var files = {"/html/foo.js": "", "/.git/foogit.js": "", "/bar.js": "
", "/html2/foo.js": ""}; | 361 var files = {"/html/foo.js": "", "/.git/foogit.js": "", "/bar.js": "
", "/html2/foo.js": ""}; |
294 createObjects(); | 362 createObjects(step1); |
295 InspectorTest.addResult("Adding file system."); | 363 |
296 manager.addMockFileSystem(fileSystemPath); | 364 function step1() |
297 InspectorTest.addResult("Adding exclusion pattern and excluded folde
r."); | 365 { |
298 InspectorTest.testFileSystemMapping.addExcludedFolder(fileSystemPath
, "/html/"); | 366 InspectorTest.addResult("Adding file system."); |
299 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed, 2); | 367 manager.addMockFileSystem(fileSystemPath); |
300 manager.addFiles(fileSystemPath, files); | 368 InspectorTest.addResult("Adding exclusion pattern and excluded f
older."); |
301 dumpWorkspaceUISourceCodes(); | 369 InspectorTest.testFileSystemMapping.addExcludedFolder(fileSystem
Path, "/html/"); |
302 InspectorTest.addResult("Excluding html2 folder:"); | 370 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 2); |
303 InspectorTest.waitForWorkspaceUISourceCodeRemovedEvent(uiSourceCodeR
emoved); | 371 manager.addFiles(fileSystemPath, files); |
304 InspectorTest.testWorkspace.uiSourceCodes()[0].project().excludeFold
er("/html2/"); | 372 dumpWorkspaceUISourceCodes(); |
305 dumpWorkspaceUISourceCodes(); | 373 InspectorTest.addResult("Excluding html2 folder:"); |
306 next(); | 374 InspectorTest.waitForWorkspaceUISourceCodeRemovedEvent(uiSourceC
odeRemoved); |
| 375 InspectorTest.testWorkspace.uiSourceCodes()[0].project().exclude
Folder("/html2/"); |
| 376 dumpWorkspaceUISourceCodes(); |
| 377 next(); |
| 378 } |
307 }, | 379 }, |
308 | 380 |
309 function testRemoveProject(next) | 381 function testRemoveProject(next) |
310 { | 382 { |
311 function uiSourceCodeAdded(uiSourceCode) {} | 383 function uiSourceCodeAdded(uiSourceCode) {} |
312 function uiSourceCodeRemoved(uiSourceCode) {} | 384 function uiSourceCodeRemoved(uiSourceCode) {} |
313 | 385 |
314 function dumpWorkspaceUISourceCodes() | 386 function dumpWorkspaceUISourceCodes() |
315 { | 387 { |
316 InspectorTest.addResult("Dumping uiSourceCodes origin URLs:"); | 388 InspectorTest.addResult("Dumping uiSourceCodes origin URLs:"); |
317 var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); | 389 var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes(); |
318 for (var i = 0; i < uiSourceCodes.length; ++i) | 390 for (var i = 0; i < uiSourceCodes.length; ++i) |
319 InspectorTest.addResult(" - " + uiSourceCodes[i].originURL(
)); | 391 InspectorTest.addResult(" - " + uiSourceCodes[i].originURL(
)); |
320 } | 392 } |
321 | 393 |
322 var fileSystemPath = "/var/www"; | 394 var fileSystemPath = "/var/www"; |
323 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); | 395 var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.pr
ojectId(fileSystemPath); |
324 var files = {"/foo.js": ""}; | 396 var files = {"/foo.js": ""}; |
325 createObjects(); | 397 createObjects(step1); |
326 InspectorTest.addResult("Adding file system."); | 398 |
327 manager.addMockFileSystem(fileSystemPath); | 399 function step1() |
328 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed, 2); | 400 { |
329 manager.addFiles(fileSystemPath, files); | 401 InspectorTest.addResult("Adding file system."); |
330 dumpWorkspaceUISourceCodes(); | 402 manager.addMockFileSystem(fileSystemPath); |
331 InspectorTest.addResult("Removing project:"); | 403 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCod
eAdded, 2); |
332 var project = InspectorTest.testWorkspace.uiSourceCodes()[0].project
(); | 404 manager.addFiles(fileSystemPath, files); |
333 InspectorTest.testWorkspace.addEventListener(WebInspector.Workspace.
Events.ProjectRemoved, projectRemoved); | 405 dumpWorkspaceUISourceCodes(); |
334 project.remove(); | 406 InspectorTest.addResult("Removing project:"); |
| 407 var project = InspectorTest.testWorkspace.uiSourceCodes()[0].pro
ject(); |
| 408 InspectorTest.testWorkspace.addEventListener(WebInspector.Worksp
ace.Events.ProjectRemoved, projectRemoved); |
| 409 project.remove(); |
| 410 } |
335 | 411 |
336 function projectRemoved() | 412 function projectRemoved() |
337 { | 413 { |
338 InspectorTest.addResult("Received project removed event."); | 414 InspectorTest.addResult("Received project removed event."); |
339 next(); | 415 next(); |
340 } | 416 } |
341 }, | 417 }, |
342 ]); | 418 ]); |
343 }; | 419 }; |
344 </script> | 420 </script> |
345 </head> | 421 </head> |
346 <body onload="runTest()"> | 422 <body onload="runTest()"> |
347 <p>Tests file system project mappings.</p> | 423 <p>Tests file system project mappings.</p> |
348 </body> | 424 </body> |
349 </html> | 425 </html> |
OLD | NEW |