blob: 2d407baddfa5b357fc4b3e310753a762c930c7d0 [file] [log] [blame]
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script>
function test()
{
// At first fill file mapping with entries.
var fileMapping = new WebInspector.FileMapping();
var mappingEntries = [];
mappingEntries.push(new WebInspector.FileMapping.Entry("http://localhost/", "/var/www/"));
mappingEntries.push(new WebInspector.FileMapping.Entry("http://www.example.com/", "/home/example.com/"));
mappingEntries.push(new WebInspector.FileMapping.Entry("http://www.foo.com/", "/bar/"));
fileMapping.setMappingEntries(mappingEntries);
// Then create another file mapping to make sure it is correctly restored from the settings.
fileMapping = new WebInspector.FileMapping();
function testPathPrefixForURL(url)
{
var entry = fileMapping.mappingEntryForURL(url);
InspectorTest.addResult(" " + url + " -> " + (entry ? entry.pathPrefix : null));
}
function testURLPrefixForPath(path)
{
var entry = fileMapping.mappingEntryForPath(path);
InspectorTest.addResult(" " + path + " -> " + (entry ? entry.urlPrefix : null));
}
// Now test all FileMapping methods.
InspectorTest.addResult("Test mappingEntryForURL");
testPathPrefixForURL("http://www.example.com");
testPathPrefixForURL("http://www.example.com/");
testPathPrefixForURL("http://localhost/index.html");
testPathPrefixForURL("http://localhost/foo/index.html");
testPathPrefixForURL("https://localhost");
testPathPrefixForURL("http://example.com");
InspectorTest.addResult("Test mappingEntryForPath");
testURLPrefixForPath("/home/example.com");
testURLPrefixForPath("/home/example.com/");
testURLPrefixForPath("/var/www/index.html");
testURLPrefixForPath("/var/www/foo/index.html");
InspectorTest.completeTest();
}
</script>
</head>
<body onload="runTest()">
<p>Tests FileMapping</p>
</body>
</html>