| <html> |
| <head> |
| <script src="../http/tests/inspector/inspector-test.js"></script> |
| <script src="../http/tests/inspector/debugger-test.js"></script> |
| <script src="../http/tests/inspector/workspace-test.js"></script> |
| <script src="../http/tests/inspector/isolated-filesystem-test.js"></script> |
| <script> |
| function test() |
| { |
| function dumpUISourceCodes(uiSourceCodes, next) |
| { |
| innerDumpUISourceCodes(uiSourceCodes, 0, next); |
| |
| function innerDumpUISourceCodes(uiSourceCodes, startIndex, next) |
| { |
| InspectorTest.addResult(""); |
| if (startIndex === uiSourceCodes.length) { |
| next(); |
| return; |
| } |
| |
| InspectorTest.dumpUISourceCode(uiSourceCodes[startIndex], dumpCallback.bind(this, uiSourceCodes, startIndex, next)); |
| function dumpCallback(uiSourceCodes, startIndex, next) |
| { |
| uiSourceCodes[startIndex].requestMetadata(dumpMetadata.bind(this, uiSourceCodes, startIndex, next)); |
| } |
| |
| function dumpMetadata(uiSourceCodes, startIndex, next, modificationTime, size) |
| { |
| InspectorTest.addResult("modificationTime=" + modificationTime.getTime() + ", size=" + size); |
| innerDumpUISourceCodes.call(this, uiSourceCodes, startIndex + 1, next); |
| } |
| } |
| } |
| |
| function dumpUISourceCodeLocations(uiSourceCodes, lineNumber) |
| { |
| InspectorTest.addResult("Dumping uiSourceCode location link texts:"); |
| for (var i = 0; i < uiSourceCodes.length; ++i) { |
| var uiSourceCode = uiSourceCodes[i]; |
| var uiLocation = new WebInspector.UILocation(uiSourceCode, lineNumber); |
| InspectorTest.addResult(" - " + uiLocation.linkText()); |
| } |
| } |
| |
| InspectorTest.runTestSuite([ |
| function testFileSystems(next) |
| { |
| InspectorTest.createWorkspace(); |
| var manager = InspectorTest.createIsolatedFileSystemManager(InspectorTest.testWorkspace, InspectorTest.testFileSystemMapping); |
| var uiSourceCodes = []; |
| |
| InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded, 3); |
| InspectorTest.addResult("Adding first file system."); |
| manager.addMockFileSystem("/var/www"); |
| InspectorTest.addResult("Adding second file system."); |
| manager.addMockFileSystem("/foo/bar"); |
| |
| InspectorTest.addResult("Adding file mappings."); |
| InspectorTest.testFileSystemMapping.addFileMapping("/var/www", "http://localhost/", "/localhost/"); |
| InspectorTest.testFileSystemMapping.addFileMapping("/foo/bar", "http://www.example.com/", "/"); |
| |
| InspectorTest.addResult("Adding files to file systems."); |
| manager.addFiles("/var/www", {"/localhost/foo.js": "<foo content>", "/bar.js": "<bark content>"}); |
| manager.addFiles("/foo/bar", {"/baz.js": "<bazzz content>"}); |
| |
| dumpUISourceCodes(uiSourceCodes, uiSourceCodesDumped); |
| |
| function uiSourceCodeAdded(uiSourceCode) |
| { |
| uiSourceCodes.push(uiSourceCode) |
| } |
| |
| function uiSourceCodesDumped() |
| { |
| dumpUISourceCodeLocations(uiSourceCodes, 5); |
| InspectorTest.addResult("UISourceCode uri to url mappings:"); |
| for (var i = 0; i < uiSourceCodes.length; ++i) { |
| var url = uiSourceCodes[i].url; |
| if (!url) |
| continue; |
| InspectorTest.addResult(" " + uiSourceCodes[i].uri() + " -> " + uiSourceCodes[i].url); |
| } |
| InspectorTest.addResult("UISourceCode url to uri mappings:"); |
| for (var i = 0; i < uiSourceCodes.length; ++i) { |
| var url = uiSourceCodes[i].url; |
| if (!url) |
| continue; |
| var uri = InspectorTest.testWorkspace.uiSourceCodeForURL(url).uri(); |
| InspectorTest.addResult(" " + url + " -> " + uri); |
| } |
| InspectorTest.testWorkspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeContentCommitted, contentCommitted, this); |
| uiSourceCodes[0].addRevision("<Modified UISourceCode content>"); |
| } |
| |
| function contentCommitted() |
| { |
| InspectorTest.addResult("After revision added:"); |
| InspectorTest.dumpUISourceCode(uiSourceCodes[0], dumped); |
| |
| function dumped() |
| { |
| uiSourceCodes[0].requestMetadata(dumpModifiedMetadata); |
| } |
| |
| function dumpModifiedMetadata(modificationTime, size) |
| { |
| InspectorTest.addResult("New modificationTime=" + modificationTime.getTime() + ", size=" + size); |
| var uiSourceCodesCount = InspectorTest.testWorkspace.uiSourceCodes().length; |
| InspectorTest.addResult("Removing second file system."); |
| manager.removeMockFileSystem("/var/www"); |
| InspectorTest.addResult(" number of uiSourceCodes in workspace after removing second file system: " + InspectorTest.testWorkspace.uiSourceCodes().length); |
| InspectorTest.addResult("Removing first file system."); |
| manager.removeMockFileSystem("/foo/bar"); |
| InspectorTest.addResult(" number of uiSourceCodes in workspace after removing first file system: " + InspectorTest.testWorkspace.uiSourceCodes().length); |
| next(); |
| } |
| } |
| }, |
| ]); |
| }; |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Tests file system project.</p> |
| </body> |
| </html> |