forked from WebKitNix/webkitnix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfile-system-mapping.html
81 lines (73 loc) · 3.04 KB
/
file-system-mapping.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script>
function test()
{
var paths = {
FOO: "/home/username/projects/foo",
BAR: "/home/username/projects/bar",
SITE1: "/www/site1"
};
function addFileSystem(fileSystemMapping, path)
{
InspectorTest.addResult("Adding file system " + path);
fileSystemMapping.addFileSystemMapping(path);
}
function removeFileSystem(fileSystemMapping, path)
{
InspectorTest.addResult("Removing file system " + path);
fileSystemMapping.removeFileSystemMapping(path);
}
function checkAndDumpFileSystemMapping(fileSystemMapping)
{
var fileSystemPaths = fileSystemMapping.fileSystemPaths();
InspectorTest.addResult("Testing file system mapping.");
InspectorTest.addResult(" file system paths:");
for (var i = 0; i < fileSystemPaths.length; ++i)
InspectorTest.addResult(" - " + fileSystemPaths[i]);
InspectorTest.addResult(" fileSystemPathForPrefix:");
// Call fileSystemPathForPrefix twice for each path prefix to check caching.
for (var i = 0; i < 2; ++i) {
for (pathId in paths) {
var pathPrefix = paths[pathId];
var fileSystemPath = fileSystemMapping.fileSystemPathForPrefix(pathPrefix + "/");
if (!fileSystemPath)
continue;
InspectorTest.addResult(" " + pathPrefix + " => " + fileSystemPath);
}
}
InspectorTest.addResult("");
}
// At first create file system mapping and clear it.
var fileSystemMapping = new WebInspector.FileSystemMappingImpl();
var fileSystemPaths = fileSystemMapping.fileSystemPaths();
for (var i = 0; i < fileSystemPaths.length; ++i)
fileSystemMapping.removeFileSystemMapping(fileSystemPaths[i]);
// Now fill it with file systems and test.
checkAndDumpFileSystemMapping(fileSystemMapping);
addFileSystem(fileSystemMapping, paths.FOO)
checkAndDumpFileSystemMapping(fileSystemMapping);
addFileSystem(fileSystemMapping, paths.BAR)
checkAndDumpFileSystemMapping(fileSystemMapping);
addFileSystem(fileSystemMapping, paths.SITE1)
checkAndDumpFileSystemMapping(fileSystemMapping);
// Then create another file mapping to make sure it is correctly restored from the settings.
InspectorTest.addResult("Creating another file system mapping.");
var fileSystemMapping = new WebInspector.FileSystemMappingImpl();
checkAndDumpFileSystemMapping(fileSystemMapping);
// Now remove file systems and test.
removeFileSystem(fileSystemMapping, paths.SITE1)
checkAndDumpFileSystemMapping(fileSystemMapping);
removeFileSystem(fileSystemMapping, paths.FOO)
checkAndDumpFileSystemMapping(fileSystemMapping);
removeFileSystem(fileSystemMapping, paths.BAR)
checkAndDumpFileSystemMapping(fileSystemMapping);
InspectorTest.completeTest();
}
</script>
</head>
<body onload="runTest()">
<p>Tests FileSystemMapping</p>
</body>
</html>