3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/workspace-test.js"></script>
8 var uiSourceCodes = {};
9 var projectDelegates = {};
10 var projectStores = {};
11 function createUISourceCode(projectId, path)
13 var projectStore = projectStores[projectId];
14 if (!projectStores[projectId]) {
15 projectStore = workspace.addProject(projectId, new MockProjectDelegate());
16 projectStores[projectId] = projectStore;
19 var parentPath = path.substring(0, path.lastIndexOf("/"));
20 var name = path.substring(path.lastIndexOf("/") + 1);
21 var fileDescriptor = new WebInspector.FileDescriptor(parentPath, name, path, path, WebInspector.resourceTypes.Script);
22 projectStore.addFile(fileDescriptor);
25 function MockProjectDelegate() {}
26 MockProjectDelegate.prototype.url = function() { return ""; }
27 MockProjectDelegate.prototype.displayName = function() {};
28 MockProjectDelegate.prototype.type = function() { return WebInspector.projectTypes.Network };
30 var fileSystemMapping = new WebInspector.FileSystemMapping();
31 var fileSystemPath = "/var/www";
32 var projectId = WebInspector.FileSystemWorkspaceBinding.projectId(fileSystemPath);
33 fileSystemMapping.addFileSystem("/var/www");
34 fileSystemMapping.addFileMapping("/var/www", "http://localhost/", "/localhost/");
35 var workspace = new WebInspector.Workspace(fileSystemMapping);
37 function dumpHasMappingForURL(url)
39 var result = workspace.hasMappingForURL(url)
41 InspectorTest.addResult(" url " + url + " is mapped.");
43 InspectorTest.addResult(" url " + url + " is not mapped.");
46 function dumpUISourceCodeForURL(url)
48 var uiSourceCode = workspace.uiSourceCodeForURL(url)
49 InspectorTest.addResult(" url " + url + " is mapped to " + (uiSourceCode ? uiSourceCode.uri() : null));
52 function dumpURLForPath(fileSystemPath, filePath)
54 var url = workspace.urlForPath(fileSystemPath, filePath)
55 InspectorTest.addResult(" path " + fileSystemPath + " / " + filePath + " is mapped to " + (url ? url : null));
58 createUISourceCode(projectId, "localhost/index.html");
60 createUISourceCode("http://www.example.com", "index.html");
61 createUISourceCode("http://localhost", "index.html");
62 createUISourceCode("http://localhost", "foo/index.html");
63 createUISourceCode("https://localhost", "index.html");
65 dumpHasMappingForURL("http://www.example.com/index.html");
66 dumpHasMappingForURL("http://localhost/index.html");
67 dumpHasMappingForURL("http://localhost/foo/index.html");
68 dumpHasMappingForURL("https://localhost/index.html");
69 InspectorTest.addResult("");
71 dumpUISourceCodeForURL("http://www.example.com/index.html");
72 dumpUISourceCodeForURL("http://localhost/index.html");
73 dumpUISourceCodeForURL("http://localhost/foo/index.html");
74 dumpUISourceCodeForURL("https://localhost/index.html");
75 InspectorTest.addResult("");
77 dumpURLForPath("/home/example.com", "foo/index.html");
78 dumpURLForPath("/home/example.com", "index.html");
79 dumpURLForPath("/var/www", "localhost/index.html");
80 dumpURLForPath("/var/www", "localhost/foo/index.html");
81 dumpURLForPath("/home/foo", "index.html");
83 InspectorTest.completeTest();
87 <body onload="runTest()">
88 <p>Tests workspace mappings</p>