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/workspace-test.js"></script> | 4 <script src="../http/tests/inspector/workspace-test.js"></script> |
5 <script> | 5 <script> |
6 function test() | 6 function test() |
7 { | 7 { |
8 var uiSourceCodes = {}; | 8 var uiSourceCodes = {}; |
9 var projects = {}; | 9 var projects = {}; |
10 var workspace = new WebInspector.Workspace(); | 10 var workspace = new WebInspector.Workspace(); |
11 | 11 |
12 function createUISourceCode(projectId, path) | 12 function createUISourceCode(projectId, relativePath) |
13 { | 13 { |
14 if (projectId.startsWith("1:")) | |
15 projectId = projectId.substring(2); | |
16 var project = projects[projectId]; | 14 var project = projects[projectId]; |
17 if (!projects[projectId]) { | 15 if (!projects[projectId]) { |
18 project = new WebInspector.ProjectStore(workspace, projectId, WebIns pector.projectTypes.Network, ""); | 16 var projectType = projectId.startsWith("file") ? WebInspector.projec tTypes.FileSystem : WebInspector.projectTypes.Network; |
17 project = new WebInspector.ProjectStore(workspace, projectId, projec tType, ""); | |
19 workspace.addProject(project); | 18 workspace.addProject(project); |
20 projects[projectId] = project; | 19 projects[projectId] = project; |
21 } | 20 } |
22 var uiSourceCode = project.createUISourceCode(path, WebInspector.resourc eTypes.Script); | 21 var uiSourceCode = project.createUISourceCode(projectId +"/" + relativeP ath, WebInspector.resourceTypes.Script); |
23 project.addUISourceCode(uiSourceCode); | 22 project.addUISourceCode(uiSourceCode); |
24 } | 23 } |
25 | 24 |
26 var fileSystemMapping = new WebInspector.FileSystemMapping(); | 25 var fileSystemMapping = new WebInspector.FileSystemMapping(); |
27 var fileSystemPath = "file:///var/www"; | |
28 var projectId = WebInspector.FileSystemWorkspaceBinding.projectId(fileSystem Path); | |
29 fileSystemMapping.addFileSystem("file:///var/www"); | 26 fileSystemMapping.addFileSystem("file:///var/www"); |
30 fileSystemMapping.addFileMapping("file:///var/www", "http://localhost/", "/l ocalhost/"); | 27 fileSystemMapping.addFileMapping("file:///var/www", "http://localhost/", "/l ocalhost/"); |
31 var fileSystemWorkspaceBinding = new WebInspector.FileSystemWorkspaceBinding (WebInspector.isolatedFileSystemManager, workspace); | |
32 var networkMapping = new WebInspector.NetworkMapping(WebInspector.targetMana ger, workspace, fileSystemWorkspaceBinding, fileSystemMapping); | |
33 | 28 |
34 function dumpHasMappingForURL(url) | 29 function dumpHasMappingForURL(url) |
35 { | 30 { |
36 var result = networkMapping.hasMappingForNetworkURL(url) | 31 var result = fileSystemMapping.hasMappingForNetworkURL(url) |
37 if (result) | 32 if (result) |
38 InspectorTest.addResult(" url " + url + " is mapped."); | 33 InspectorTest.addResult(" url " + url + " is mapped."); |
39 else | 34 else |
40 InspectorTest.addResult(" url " + url + " is not mapped."); | 35 InspectorTest.addResult(" url " + url + " is not mapped."); |
41 } | 36 } |
42 | 37 |
43 function dumpUISourceCodeForURL(url) | 38 function dumpUISourceCodeForURL(url) |
44 { | 39 { |
45 var uiSourceCode = networkMapping.uiSourceCodeForURLForAnyTarget(url); | 40 var uiSourceCode = workspace.uiSourceCodeForURL(url); |
46 InspectorTest.addResult(" url " + url + " is mapped to " + (uiSourceC ode ? uiSourceCode.url() : null)); | 41 InspectorTest.addResult(" url " + url + " is mapped to " + (uiSourceC ode ? uiSourceCode.url() : null)); |
47 } | 42 } |
48 | 43 |
49 function dumpURLForPath(fileSystemPath, filePath) | 44 function dumpURLForPath(fileSystemPath, filePath) |
50 { | 45 { |
51 var url = networkMapping._networkURLForFileSystemURL(fileSystemPath, fil eSystemPath + "/" + filePath) | 46 var url = fileSystemMapping.networkURLForFileSystemURL(fileSystemPath, f ileSystemPath + "/" + filePath) |
52 InspectorTest.addResult(" path " + fileSystemPath + " / " + filePath + " is mapped to " + (url ? url : null)); | 47 InspectorTest.addResult(" path " + fileSystemPath + " / " + filePath + " is mapped to " + (url ? url : null)); |
53 } | 48 } |
54 | |
55 createUISourceCode(projectId, "file:///var/www/localhost/index.html"); | |
56 | 49 |
57 createUISourceCode("1:http://www.example.com", "index.html"); | 50 createUISourceCode("file:///var/www", "localhost/index.html"); |
58 createUISourceCode("1:http://localhost", "index.html"); | 51 |
59 createUISourceCode("1:http://localhost", "foo/index.html"); | 52 createUISourceCode("http://www.example.com", "index.html"); |
60 createUISourceCode("1:https://localhost", "index.html"); | 53 createUISourceCode("http://localhost", "index.html"); |
54 createUISourceCode("http://localhost", "foo/index.html"); | |
55 createUISourceCode("https://localhost", "index.html"); | |
61 | 56 |
62 dumpHasMappingForURL("http://www.example.com/index.html"); | 57 dumpHasMappingForURL("http://www.example.com/index.html"); |
63 dumpHasMappingForURL("http://localhost/index.html"); | 58 dumpHasMappingForURL("http://localhost/index.html"); |
64 dumpHasMappingForURL("http://localhost/foo/index.html"); | 59 dumpHasMappingForURL("http://localhost/foo/index.html"); |
65 dumpHasMappingForURL("https://localhost/index.html"); | 60 dumpHasMappingForURL("https://localhost/index.html"); |
66 InspectorTest.addResult(""); | 61 InspectorTest.addResult(""); |
67 | 62 |
68 dumpUISourceCodeForURL("http://www.example.com/index.html"); | 63 dumpUISourceCodeForURL("http://www.example.com/index.html"); |
dgozman
2016/09/24 16:17:07
I think that now this block does not make sense, s
| |
69 dumpUISourceCodeForURL("http://localhost/index.html"); | 64 dumpUISourceCodeForURL("http://localhost/index.html"); |
70 dumpUISourceCodeForURL("http://localhost/foo/index.html"); | 65 dumpUISourceCodeForURL("http://localhost/foo/index.html"); |
71 dumpUISourceCodeForURL("https://localhost/index.html"); | 66 dumpUISourceCodeForURL("https://localhost/index.html"); |
67 dumpUISourceCodeForURL("file:///var/www/localhost/index.html"); | |
72 InspectorTest.addResult(""); | 68 InspectorTest.addResult(""); |
73 | 69 |
74 dumpURLForPath("file:///home/example.com", "foo/index.html"); | 70 dumpURLForPath("file:///home/example.com", "foo/index.html"); |
75 dumpURLForPath("file:///home/example.com", "index.html"); | 71 dumpURLForPath("file:///home/example.com", "index.html"); |
76 dumpURLForPath("file:///var/www", "localhost/index.html"); | 72 dumpURLForPath("file:///var/www", "localhost/index.html"); |
77 dumpURLForPath("file:///var/www", "localhost/foo/index.html"); | 73 dumpURLForPath("file:///var/www", "localhost/foo/index.html"); |
78 dumpURLForPath("file:///home/foo", "index.html"); | 74 dumpURLForPath("file:///home/foo", "index.html"); |
79 | 75 |
80 InspectorTest.completeTest(); | 76 InspectorTest.completeTest(); |
81 } | 77 } |
82 </script> | 78 </script> |
83 </head> | 79 </head> |
84 <body onload="runTest()"> | 80 <body onload="runTest()"> |
85 <p>Tests workspace mappings</p> | 81 <p>Tests workspace mappings</p> |
86 </body> | 82 </body> |
87 </html> | 83 </html> |
OLD | NEW |