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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="../http/tests/inspector/debugger-test.js"></script>
<script src="../http/tests/inspector/workspace-test.js"></script>
<script src="../http/tests/inspector/isolated-filesystem-test.js"></script>
<script>
function test()
{
function dumpUISourceCodes(uiSourceCodes, next)
{
innerDumpUISourceCodes(uiSourceCodes, 0, next);
function innerDumpUISourceCodes(uiSourceCodes, startIndex, next)
{
InspectorTest.addResult("");
if (startIndex === uiSourceCodes.length) {
next();
return;
}
InspectorTest.dumpUISourceCode(uiSourceCodes[startIndex], dumpCallback.bind(this, uiSourceCodes, startIndex, next));
function dumpCallback(uiSourceCodes, startIndex, next)
{
uiSourceCodes[startIndex].requestMetadata(dumpMetadata.bind(this, uiSourceCodes, startIndex, next));
}
function dumpMetadata(uiSourceCodes, startIndex, next, modificationTime, size)
{
InspectorTest.addResult("modificationTime=" + modificationTime.getTime() + ", size=" + size);
innerDumpUISourceCodes.call(this, uiSourceCodes, startIndex + 1, next);
}
}
}
function dumpUISourceCodeLocations(uiSourceCodes, lineNumber)
{
InspectorTest.addResult("Dumping uiSourceCode location link texts:");
for (var i = 0; i < uiSourceCodes.length; ++i) {
var uiSourceCode = uiSourceCodes[i];
var uiLocation = new WebInspector.UILocation(uiSourceCode, lineNumber);
InspectorTest.addResult(" - " + uiLocation.linkText());
}
}
InspectorTest.runTestSuite([
function testFileSystems(next)
{
InspectorTest.createWorkspace();
var manager = InspectorTest.createIsolatedFileSystemManager(InspectorTest.testWorkspace, InspectorTest.testFileSystemMapping);
var uiSourceCodes = [];
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded, 3);
InspectorTest.addResult("Adding first file system.");
manager.addMockFileSystem("/var/www");
InspectorTest.addResult("Adding second file system.");
manager.addMockFileSystem("/foo/bar");
InspectorTest.addResult("Adding file mappings.");
InspectorTest.testFileSystemMapping.addFileMapping("/var/www", "http://localhost/", "/localhost/");
InspectorTest.testFileSystemMapping.addFileMapping("/foo/bar", "http://www.example.com/", "/");
InspectorTest.addResult("Adding files to file systems.");
manager.addFiles("/var/www", {"/localhost/foo.js": "<foo content>", "/bar.js": "<bark content>"});
manager.addFiles("/foo/bar", {"/baz.js": "<bazzz content>"});
dumpUISourceCodes(uiSourceCodes, uiSourceCodesDumped);
function uiSourceCodeAdded(uiSourceCode)
{
uiSourceCodes.push(uiSourceCode)
}
function uiSourceCodesDumped()
{
dumpUISourceCodeLocations(uiSourceCodes, 5);
InspectorTest.addResult("UISourceCode uri to url mappings:");
for (var i = 0; i < uiSourceCodes.length; ++i) {
var url = uiSourceCodes[i].url;
if (!url)
continue;
InspectorTest.addResult(" " + uiSourceCodes[i].uri() + " -> " + uiSourceCodes[i].url);
}
InspectorTest.addResult("UISourceCode url to uri mappings:");
for (var i = 0; i < uiSourceCodes.length; ++i) {
var url = uiSourceCodes[i].url;
if (!url)
continue;
var uri = InspectorTest.testWorkspace.uiSourceCodeForURL(url).uri();
InspectorTest.addResult(" " + url + " -> " + uri);
}
InspectorTest.testWorkspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeContentCommitted, contentCommitted, this);
uiSourceCodes[0].addRevision("<Modified UISourceCode content>");
}
function contentCommitted()
{
InspectorTest.addResult("After revision added:");
InspectorTest.dumpUISourceCode(uiSourceCodes[0], dumped);
function dumped()
{
uiSourceCodes[0].requestMetadata(dumpModifiedMetadata);
}
function dumpModifiedMetadata(modificationTime, size)
{
InspectorTest.addResult("New modificationTime=" + modificationTime.getTime() + ", size=" + size);
var uiSourceCodesCount = InspectorTest.testWorkspace.uiSourceCodes().length;
InspectorTest.addResult("Removing second file system.");
manager.removeMockFileSystem("/var/www");
InspectorTest.addResult(" number of uiSourceCodes in workspace after removing second file system: " + InspectorTest.testWorkspace.uiSourceCodes().length);
InspectorTest.addResult("Removing first file system.");
manager.removeMockFileSystem("/foo/bar");
InspectorTest.addResult(" number of uiSourceCodes in workspace after removing first file system: " + InspectorTest.testWorkspace.uiSourceCodes().length);
next();
}
}
},
]);
};
</script>
</head>
<body onload="runTest()">
<p>Tests file system project.</p>
</body>
</html>
|