3 <script src=
"../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../http/tests/inspector/debugger-test.js"></script>
5 <script src=
"../http/tests/inspector/workspace-test.js"></script>
6 <script src=
"../http/tests/inspector/isolated-filesystem-test.js"></script>
10 function dumpUISourceCodes(uiSourceCodes
, next
)
12 innerDumpUISourceCodes(uiSourceCodes
, 0, next
);
14 function innerDumpUISourceCodes(uiSourceCodes
, startIndex
, next
)
16 InspectorTest
.addResult("");
17 if (startIndex
=== uiSourceCodes
.length
) {
22 InspectorTest
.dumpUISourceCode(uiSourceCodes
[startIndex
], dumpCallback
.bind(this, uiSourceCodes
, startIndex
, next
));
23 function dumpCallback(uiSourceCodes
, startIndex
, next
)
25 uiSourceCodes
[startIndex
].requestMetadata(dumpMetadata
.bind(this, uiSourceCodes
, startIndex
, next
));
28 function dumpMetadata(uiSourceCodes
, startIndex
, next
, modificationTime
, size
)
30 InspectorTest
.addResult("modificationTime=" + modificationTime
.getTime() + ", size=" + size
);
31 innerDumpUISourceCodes
.call(this, uiSourceCodes
, startIndex
+ 1, next
);
36 function dumpUISourceCodeLocations(uiSourceCodes
, lineNumber
)
38 InspectorTest
.addResult("Dumping uiSourceCode location link texts:");
39 for (var i
= 0; i
< uiSourceCodes
.length
; ++i
) {
40 var uiSourceCode
= uiSourceCodes
[i
];
41 var uiLocation
= uiSourceCode
.uiLocation(lineNumber
);
42 InspectorTest
.addResult(" - " + uiLocation
.linkText());
46 InspectorTest
.runTestSuite([
47 function testFileSystems(next
)
49 InspectorTest
.addResult("Adding first file system.");
50 var fs1
= new InspectorTest
.TestFileSystem("/var/www");
51 var fs2
= new InspectorTest
.TestFileSystem("/foo/bar");
52 InspectorTest
.addResult("Adding second file system.");
56 InspectorTest
.addResult("Adding file mappings.");
57 WebInspector
.isolatedFileSystemManager
.mapping().addFileMapping("/var/www", "http://localhost/", "/localhost/");
58 WebInspector
.isolatedFileSystemManager
.mapping().addFileMapping("/foo/bar", "http://www.example.com/", "/");
60 InspectorTest
.addResult("Adding files to file systems.");
62 var localhostDir
= fs1
.root
.mkdir("localhost");
63 localhostDir
.addFile("foo.js", "<foo content>");
64 fs1
.root
.addFile("bar.js", "<bark content>");
66 fs2
.root
.addFile("baz.js", "<bazzz content>");
68 InspectorTest
.refreshFileSystemProjects(onProjectsRefreshed
);
72 function onProjectsRefreshed()
74 uiSourceCodes
= InspectorTest
.fileSystemUISourceCodes();
75 dumpUISourceCodes(uiSourceCodes
, uiSourceCodesDumped
);
78 function uiSourceCodeAdded(uiSourceCode
)
80 uiSourceCodes
.push(uiSourceCode
)
83 function uiSourceCodesDumped()
85 dumpUISourceCodeLocations(uiSourceCodes
, 5);
86 InspectorTest
.addResult("UISourceCode uri to url mappings:");
87 for (var i
= 0; i
< uiSourceCodes
.length
; ++i
) {
88 var url
= WebInspector
.networkMapping
.networkURL(uiSourceCodes
[i
]);
91 InspectorTest
.addResult(" " + uiSourceCodes
[i
].uri() + " -> " + url
);
93 InspectorTest
.addResult("UISourceCode url to uri mappings:");
94 for (var i
= 0; i
< uiSourceCodes
.length
; ++i
) {
95 var url
= WebInspector
.networkMapping
.networkURL(uiSourceCodes
[i
]);
98 var uri
= WebInspector
.networkMapping
.uiSourceCodeForURLForAnyTarget(url
).uri();
99 InspectorTest
.addResult(" " + url
+ " -> " + uri
);
101 WebInspector
.workspace
.addEventListener(WebInspector
.Workspace
.Events
.UISourceCodeContentCommitted
, contentCommitted
, this);
102 uiSourceCodes
[0].addRevision("<Modified UISourceCode content>");
105 function contentCommitted()
107 InspectorTest
.addResult("After revision added:");
108 InspectorTest
.dumpUISourceCode(uiSourceCodes
[0], dumped
);
112 uiSourceCodes
[0].requestMetadata(dumpModifiedMetadata
);
115 function dumpModifiedMetadata(modificationTime
, size
)
117 InspectorTest
.addResult("New modificationTime=" + modificationTime
.getTime() + ", size=" + size
);
118 var uiSourceCodesCount
= InspectorTest
.fileSystemUISourceCodes().length
;
119 InspectorTest
.addResult("Removing second file system.");
120 fs1
.removeFileSystem();
121 InspectorTest
.addResult(" number of uiSourceCodes in workspace after removing second file system: " + InspectorTest
.fileSystemUISourceCodes().length
);
122 InspectorTest
.addResult("Removing first file system.");
123 fs2
.removeFileSystem();
124 InspectorTest
.addResult(" number of uiSourceCodes in workspace after removing first file system: " + InspectorTest
.fileSystemUISourceCodes().length
);
133 <body onload=
"runTest()">
134 <p>Tests file system project.
</p>