Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / file-system-mapping.html
blob7ca9a0141ad7056ef7b3db37be650ccb60f5f596
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script>
5 function test()
7 var paths = {
8 FOO: "/home/username/projects/foo",
9 BAR: "/home/username/projects/bar",
10 SITE1: "/www/site1"
13 function addFileSystem(fileSystemMapping, path)
15 InspectorTest.addResult("Adding file system " + path);
16 fileSystemMapping.addFileSystem(path);
17 checkAndDumpFileSystemMapping(fileSystemMapping);
20 function removeFileSystem(fileSystemMapping, path)
22 InspectorTest.addResult("Removing file system " + path);
23 fileSystemMapping.removeFileSystem(path);
24 checkAndDumpFileSystemMapping(fileSystemMapping);
27 function addFileMapping(fileSystemMapping, fileSystemPath, urlPrefix, pathPrefix)
29 InspectorTest.addResult("Adding file mapping (" + fileSystemPath + ", " + urlPrefix + ", " + pathPrefix + ")");
30 fileSystemMapping.addFileMapping(fileSystemPath, urlPrefix, pathPrefix);
31 checkAndDumpFileSystemMapping(fileSystemMapping);
34 function removeFileMapping(fileSystemMapping, fileSystemPath, urlPrefix, pathPrefix)
36 InspectorTest.addResult("Removing file mapping (" + fileSystemPath + ", " + urlPrefix + ", " + pathPrefix + ")");
37 fileSystemMapping.removeFileMapping(fileSystemPath, urlPrefix, pathPrefix);
38 checkAndDumpFileSystemMapping(fileSystemMapping);
41 function removeMappingForURL(fileSystemMapping, urlPrefix)
43 InspectorTest.addResult("Removing file mapping for url " + urlPrefix);
44 fileSystemMapping.removeMappingForURL(urlPrefix);
45 checkAndDumpFileSystemMapping(fileSystemMapping);
48 function addMappingForResource(fileSystemMapping, url, fileSystemPath, filePath)
50 InspectorTest.addResult("Adding file mapping for resource (" + url + ", " + fileSystemPath + ", " + filePath + ")");
51 fileSystemMapping.addMappingForResource(url, fileSystemPath, filePath);
52 checkAndDumpFileSystemMapping(fileSystemMapping);
55 function dumpFileForURL(fileSystemMapping, url)
57 var hasMappingForURL = fileSystemMapping.hasMappingForURL(url);
58 InspectorTest.addResult(" Has mapping for '" + url + "': " + hasMappingForURL);
59 var fileForURL = fileSystemMapping.fileForURL(url);
60 if (!fileForURL)
61 InspectorTest.addResult(" File for '" + url + "': null");
62 else
63 InspectorTest.addResult(" File for '" + url + "': " + fileForURL.fileSystemPath + " / " + fileForURL.filePath);
66 function dumpURLForPath(fileSystemMapping, fileSystemPath, filePath)
68 var url = fileSystemMapping.urlForPath(fileSystemPath, filePath);
69 InspectorTest.addResult(" URL for path '" + fileSystemPath + " / " + filePath + "': " + url);
72 function checkAndDumpFileSystemMapping(fileSystemMapping)
74 var fileSystemPaths = fileSystemMapping.fileSystemPaths();
75 InspectorTest.addResult("Testing file system mapping.");
76 InspectorTest.addResult(" file system paths:");
77 for (var i = 0; i < fileSystemPaths.length; ++i) {
78 InspectorTest.addResult(" - " + fileSystemPaths[i]);
79 var entries = fileSystemMapping.mappingEntries(fileSystemPaths[i]);
80 for (var j = 0; j < entries.length; ++j) {
81 var entry = entries[j];
82 InspectorTest.addResult(" - " + JSON.stringify(entries[j]));
85 InspectorTest.addResult("");
88 // At first create file system mapping and clear it.
89 var fileSystemMapping = new WebInspector.FileSystemMapping();
90 var fileSystemPaths = fileSystemMapping.fileSystemPaths();
91 for (var i = 0; i < fileSystemPaths.length; ++i)
92 fileSystemMapping.removeFileSystem(fileSystemPaths[i]);
94 // Now fill it with file systems.
95 checkAndDumpFileSystemMapping(fileSystemMapping);
96 addFileSystem(fileSystemMapping, paths.FOO)
97 addFileSystem(fileSystemMapping, paths.BAR)
98 addFileSystem(fileSystemMapping, paths.SITE1)
100 // Now fill it with file mappings.
101 addFileMapping(fileSystemMapping, paths.SITE1, "http://localhost/", "/");
102 addFileMapping(fileSystemMapping, paths.SITE1, "http://www.foo.com/", "/foo/");
103 addFileMapping(fileSystemMapping, paths.FOO, "http://www.example.com/bar/", "/foo/");
104 addMappingForResource(fileSystemMapping, "http://www.bar.com/foo/folder/42.js", paths.FOO, "baz/folder/42.js");
106 InspectorTest.addResult("Testing mappings for url:");
107 dumpFileForURL(fileSystemMapping, "http://www.bar.com/foo/folder/42.js");
108 dumpFileForURL(fileSystemMapping, "http://www.foo.com/bar/folder/42.js");
109 dumpFileForURL(fileSystemMapping, "http://localhost/index.html");
110 dumpFileForURL(fileSystemMapping, "https://localhost/index.html");
111 dumpFileForURL(fileSystemMapping, "http://localhost:8080/index.html");
112 dumpFileForURL(fileSystemMapping, "http://localhost/");
113 InspectorTest.addResult("");
115 InspectorTest.addResult("Testing mappings for path:");
116 dumpURLForPath(fileSystemMapping, paths.FOO, "baz/folder/42.js");
117 dumpURLForPath(fileSystemMapping, paths.FOO, "baz/folder/43.js");
118 dumpURLForPath(fileSystemMapping, paths.FOO, "bar/folder/42.js");
119 dumpURLForPath(fileSystemMapping, paths.FOO, "foo/folder/42.js");
120 dumpURLForPath(fileSystemMapping, paths.FOO, "foo2/folder/42.js");
121 dumpURLForPath(fileSystemMapping, paths.SITE1, "foo/index.html");
122 dumpURLForPath(fileSystemMapping, paths.SITE1, "index.html");
123 dumpURLForPath(fileSystemMapping, paths.SITE1, "foo");
124 dumpURLForPath(fileSystemMapping, paths.SITE1, "foo/");
125 InspectorTest.addResult("");
127 // Then create another file mapping to make sure it is correctly restored from the settings.
128 InspectorTest.addResult("Creating another file system mapping.");
129 var fileSystemMapping = new WebInspector.FileSystemMapping();
130 checkAndDumpFileSystemMapping(fileSystemMapping);
132 // Now remove file mappings.
133 removeMappingForURL(fileSystemMapping, "http://www.bar.com/foo/folder/42.js");
134 removeFileMapping(fileSystemMapping, paths.SITE1, "http://localhost/", "/");
135 removeFileMapping(fileSystemMapping, paths.SITE1, "http://www.foo.com/", "/foo/");
136 removeFileMapping(fileSystemMapping, paths.FOO, "http://www.example.com/bar/", "/foo/");
138 // Now remove file systems.
139 removeFileSystem(fileSystemMapping, paths.SITE1)
140 removeFileSystem(fileSystemMapping, paths.FOO)
141 removeFileSystem(fileSystemMapping, paths.BAR)
143 InspectorTest.completeTest();
145 </script>
146 </head>
147 <body onload="runTest()">
148 <p>Tests FileSystemMapping</p>
149 </body>
150 </html>