| <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 = uiSourceCode.uiLocation(lineNumber); |
| InspectorTest.addResult(" - " + uiLocation.linkText()); |
| } |
| } |
| |
| InspectorTest.runTestSuite([ |
| function testFileSystems(next) |
| { |
| InspectorTest.addResult("Adding first file system."); |
| var fs1 = new InspectorTest.TestFileSystem("/var/www"); |
| var fs2 = new InspectorTest.TestFileSystem("/foo/bar"); |
| InspectorTest.addResult("Adding second file system."); |
| |
| fs1.reportCreated(); |
| fs2.reportCreated(); |
| InspectorTest.addResult("Adding file mappings."); |
| WebInspector.isolatedFileSystemManager.mapping().addFileMapping("/var/www", "http://localhost/", "/localhost/"); |
| WebInspector.isolatedFileSystemManager.mapping().addFileMapping("/foo/bar", "http://www.example.com/", "/"); |
| |
| InspectorTest.addResult("Adding files to file systems."); |
| |
| var localhostDir = fs1.root.mkdir("localhost"); |
| localhostDir.addFile("foo.js", "<foo content>"); |
| fs1.root.addFile("bar.js", "<bark content>"); |
| |
| fs2.root.addFile("baz.js", "<bazzz content>"); |
| |
| InspectorTest.refreshFileSystemProjects(onProjectsRefreshed); |
| |
| var uiSourceCodes; |
| |
| function onProjectsRefreshed() |
| { |
| uiSourceCodes = InspectorTest.fileSystemUISourceCodes(); |
| 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 = WebInspector.networkMapping.networkURL(uiSourceCodes[i]); |
| if (!url) |
| continue; |
| InspectorTest.addResult(" " + uiSourceCodes[i].uri() + " -> " + url); |
| } |
| InspectorTest.addResult("UISourceCode url to uri mappings:"); |
| for (var i = 0; i < uiSourceCodes.length; ++i) { |
| var url = WebInspector.networkMapping.networkURL(uiSourceCodes[i]); |
| if (!url) |
| continue; |
| var uri = WebInspector.networkMapping.uiSourceCodeForURLForAnyTarget(url).uri(); |
| InspectorTest.addResult(" " + url + " -> " + uri); |
| } |
| WebInspector.workspace.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.fileSystemUISourceCodes().length; |
| InspectorTest.addResult("Removing second file system."); |
| fs1.removeFileSystem(); |
| InspectorTest.addResult(" number of uiSourceCodes in workspace after removing second file system: " + InspectorTest.fileSystemUISourceCodes().length); |
| InspectorTest.addResult("Removing first file system."); |
| fs2.removeFileSystem(); |
| InspectorTest.addResult(" number of uiSourceCodes in workspace after removing first file system: " + InspectorTest.fileSystemUISourceCodes().length); |
| next(); |
| } |
| } |
| }, |
| ]); |
| }; |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Tests file system project.</p> |
| </body> |
| </html> |