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> | 4 <script> |
5 function test() | 5 function test() |
6 { | 6 { |
7 var paths = { | 7 var paths = { |
8 FOO: "/home/username/projects/foo", | 8 FOO: "/home/username/projects/foo", |
9 BAR: "/home/username/projects/bar", | 9 BAR: "/home/username/projects/bar", |
10 SITE1: "/www/site1" | 10 SITE1: "/www/site1" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 function dumpFileForURL(fileSystemMapping, url) | 55 function dumpFileForURL(fileSystemMapping, url) |
56 { | 56 { |
57 var hasMappingForURL = fileSystemMapping.hasMappingForURL(url); | 57 var hasMappingForURL = fileSystemMapping.hasMappingForURL(url); |
58 InspectorTest.addResult(" Has mapping for '" + url + "': " + hasMappi
ngForURL); | 58 InspectorTest.addResult(" Has mapping for '" + url + "': " + hasMappi
ngForURL); |
59 var fileForURL = fileSystemMapping.fileForURL(url); | 59 var fileForURL = fileSystemMapping.fileForURL(url); |
60 if (!fileForURL) | 60 if (!fileForURL) |
61 InspectorTest.addResult(" File for '" + url + "': null"); | 61 InspectorTest.addResult(" File for '" + url + "': null"); |
62 else | 62 else |
63 InspectorTest.addResult(" File for '" + url + "': " + fileForURL.
fileSystemPath + " / " + fileForURL.filePath); | 63 InspectorTest.addResult(" File for '" + url + "': " + fileForURL.
fileURL); |
64 } | 64 } |
65 | 65 |
66 function dumpURLForPath(fileSystemMapping, fileSystemPath, filePath) | 66 function dumpURLForPath(fileSystemMapping, fileSystemPath, filePath) |
67 { | 67 { |
68 var url = fileSystemMapping.urlForPath(fileSystemPath, filePath); | 68 var url = fileSystemMapping.urlForPath(fileSystemPath, filePath); |
69 InspectorTest.addResult(" URL for path '" + fileSystemPath + " / " +
filePath + "': " + url); | 69 InspectorTest.addResult(" URL for path '" + filePath + "': " + url); |
70 } | 70 } |
71 | 71 |
72 function checkAndDumpFileSystemMapping(fileSystemMapping) | 72 function checkAndDumpFileSystemMapping(fileSystemMapping) |
73 { | 73 { |
74 var fileSystemPaths = Object.keys(fileSystemMapping._fileSystemMappings)
; | 74 var fileSystemPaths = Object.keys(fileSystemMapping._fileSystemMappings)
; |
75 InspectorTest.addResult("Testing file system mapping."); | 75 InspectorTest.addResult("Testing file system mapping."); |
76 InspectorTest.addResult(" file system paths:"); | 76 InspectorTest.addResult(" file system paths:"); |
77 for (var i = 0; i < fileSystemPaths.length; ++i) { | 77 for (var i = 0; i < fileSystemPaths.length; ++i) { |
78 InspectorTest.addResult(" - " + fileSystemPaths[i]); | 78 InspectorTest.addResult(" - " + fileSystemPaths[i]); |
79 var entries = fileSystemMapping.mappingEntries(fileSystemPaths[i]); | 79 var entries = fileSystemMapping.mappingEntries(fileSystemPaths[i]); |
(...skipping 26 matching lines...) Expand all Loading... |
106 InspectorTest.addResult("Testing mappings for url:"); | 106 InspectorTest.addResult("Testing mappings for url:"); |
107 dumpFileForURL(fileSystemMapping, "http://www.bar.com/foo/folder/42.js"); | 107 dumpFileForURL(fileSystemMapping, "http://www.bar.com/foo/folder/42.js"); |
108 dumpFileForURL(fileSystemMapping, "http://www.foo.com/bar/folder/42.js"); | 108 dumpFileForURL(fileSystemMapping, "http://www.foo.com/bar/folder/42.js"); |
109 dumpFileForURL(fileSystemMapping, "http://localhost/index.html"); | 109 dumpFileForURL(fileSystemMapping, "http://localhost/index.html"); |
110 dumpFileForURL(fileSystemMapping, "https://localhost/index.html"); | 110 dumpFileForURL(fileSystemMapping, "https://localhost/index.html"); |
111 dumpFileForURL(fileSystemMapping, "http://localhost:8080/index.html"); | 111 dumpFileForURL(fileSystemMapping, "http://localhost:8080/index.html"); |
112 dumpFileForURL(fileSystemMapping, "http://localhost/"); | 112 dumpFileForURL(fileSystemMapping, "http://localhost/"); |
113 InspectorTest.addResult(""); | 113 InspectorTest.addResult(""); |
114 | 114 |
115 InspectorTest.addResult("Testing mappings for path:"); | 115 InspectorTest.addResult("Testing mappings for path:"); |
116 dumpURLForPath(fileSystemMapping, paths.FOO, "baz/folder/42.js"); | 116 dumpURLForPath(fileSystemMapping, paths.FOO, "file://" + paths.FOO + "/baz/f
older/42.js"); |
117 dumpURLForPath(fileSystemMapping, paths.FOO, "baz/folder/43.js"); | 117 dumpURLForPath(fileSystemMapping, paths.FOO, "file://" + paths.FOO + "/baz/f
older/43.js"); |
118 dumpURLForPath(fileSystemMapping, paths.FOO, "bar/folder/42.js"); | 118 dumpURLForPath(fileSystemMapping, paths.FOO, "file://" + paths.FOO + "/bar/f
older/42.js"); |
119 dumpURLForPath(fileSystemMapping, paths.FOO, "foo/folder/42.js"); | 119 dumpURLForPath(fileSystemMapping, paths.FOO, "file://" + paths.FOO + "/foo/f
older/42.js"); |
120 dumpURLForPath(fileSystemMapping, paths.FOO, "foo2/folder/42.js"); | 120 dumpURLForPath(fileSystemMapping, paths.FOO, "file://" + paths.FOO + "/foo2/
folder/42.js"); |
121 dumpURLForPath(fileSystemMapping, paths.SITE1, "foo/index.html"); | 121 dumpURLForPath(fileSystemMapping, paths.SITE1, "file://" + paths.SITE1 + "/f
oo/index.html"); |
122 dumpURLForPath(fileSystemMapping, paths.SITE1, "index.html"); | 122 dumpURLForPath(fileSystemMapping, paths.SITE1, "file://" + paths.SITE1 + "/i
ndex.html"); |
123 dumpURLForPath(fileSystemMapping, paths.SITE1, "foo"); | 123 dumpURLForPath(fileSystemMapping, paths.SITE1, "file://" + paths.SITE1 + "/f
oo"); |
124 dumpURLForPath(fileSystemMapping, paths.SITE1, "foo/"); | 124 dumpURLForPath(fileSystemMapping, paths.SITE1, "file://" + paths.SITE1 + "/f
oo/"); |
125 InspectorTest.addResult(""); | 125 InspectorTest.addResult(""); |
126 | 126 |
127 // Then create another file mapping to make sure it is correctly restored fr
om the settings. | 127 // Then create another file mapping to make sure it is correctly restored fr
om the settings. |
128 InspectorTest.addResult("Creating another file system mapping."); | 128 InspectorTest.addResult("Creating another file system mapping."); |
129 var fileSystemMapping = new WebInspector.FileSystemMapping(); | 129 var fileSystemMapping = new WebInspector.FileSystemMapping(); |
130 checkAndDumpFileSystemMapping(fileSystemMapping); | 130 checkAndDumpFileSystemMapping(fileSystemMapping); |
131 | 131 |
132 // Now remove file mappings. | 132 // Now remove file mappings. |
133 removeMappingForURL(fileSystemMapping, "http://www.bar.com/foo/folder/42.js"
); | 133 removeMappingForURL(fileSystemMapping, "http://www.bar.com/foo/folder/42.js"
); |
134 removeFileMapping(fileSystemMapping, paths.SITE1, "http://localhost/", "/"); | 134 removeFileMapping(fileSystemMapping, paths.SITE1, "http://localhost/", "/"); |
135 removeFileMapping(fileSystemMapping, paths.SITE1, "http://www.foo.com/", "/f
oo/"); | 135 removeFileMapping(fileSystemMapping, paths.SITE1, "http://www.foo.com/", "/f
oo/"); |
136 removeFileMapping(fileSystemMapping, paths.FOO, "http://www.example.com/bar/
", "/foo/"); | 136 removeFileMapping(fileSystemMapping, paths.FOO, "http://www.example.com/bar/
", "/foo/"); |
137 | 137 |
138 // Now remove file systems. | 138 // Now remove file systems. |
139 removeFileSystem(fileSystemMapping, paths.SITE1) | 139 removeFileSystem(fileSystemMapping, paths.SITE1) |
140 removeFileSystem(fileSystemMapping, paths.FOO) | 140 removeFileSystem(fileSystemMapping, paths.FOO) |
141 removeFileSystem(fileSystemMapping, paths.BAR) | 141 removeFileSystem(fileSystemMapping, paths.BAR) |
142 | 142 |
143 InspectorTest.completeTest(); | 143 InspectorTest.completeTest(); |
144 } | 144 } |
145 </script> | 145 </script> |
146 </head> | 146 </head> |
147 <body onload="runTest()"> | 147 <body onload="runTest()"> |
148 <p>Tests FileSystemMapping</p> | 148 <p>Tests FileSystemMapping</p> |
149 </body> | 149 </body> |
150 </html> | 150 </html> |
OLD | NEW |