Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / workspace-mapping.html
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/workspace-test.js"></script>
5 <script>
6 function test()
7 {
8     var uiSourceCodes = {};
9     var projectDelegates = {};
10     var projectStores = {};
11     function createUISourceCode(projectId, path)
12     {
13         var projectStore = projectStores[projectId];
14         if (!projectStores[projectId]) {
15             projectStore = workspace.addProject(projectId, new MockProjectDelegate());
16             projectStores[projectId] = projectStore;
17         }
18
19         var parentPath = path.substring(0, path.lastIndexOf("/"));
20         var name = path.substring(path.lastIndexOf("/") + 1);
21         var fileDescriptor = new WebInspector.FileDescriptor(parentPath, name, path, path, WebInspector.resourceTypes.Script);
22         projectStore.addFile(fileDescriptor);
23     }
24
25     function MockProjectDelegate() {}
26     MockProjectDelegate.prototype.url = function() { return ""; }
27     MockProjectDelegate.prototype.displayName = function() {};
28     MockProjectDelegate.prototype.type = function() { return WebInspector.projectTypes.Network };
29
30     var fileSystemMapping = new WebInspector.FileSystemMapping();
31     var fileSystemPath = "/var/www";
32     var projectId = WebInspector.FileSystemWorkspaceBinding.projectId(fileSystemPath);
33     fileSystemMapping.addFileSystem("/var/www");
34     fileSystemMapping.addFileMapping("/var/www", "http://localhost/", "/localhost/");
35     var workspace = new WebInspector.Workspace(fileSystemMapping);
36
37     function dumpHasMappingForURL(url)
38     {
39         var result = workspace.hasMappingForURL(url)
40         if (result)
41             InspectorTest.addResult("    url " + url + " is mapped.");
42         else
43             InspectorTest.addResult("    url " + url + " is not mapped.");
44     }
45
46     function dumpUISourceCodeForURL(url)
47     {
48         var uiSourceCode = workspace.uiSourceCodeForURL(url)
49         InspectorTest.addResult("    url " + url + " is mapped to " + (uiSourceCode ? uiSourceCode.uri() : null));
50     }
51
52     function dumpURLForPath(fileSystemPath, filePath)
53     {
54         var url = workspace.urlForPath(fileSystemPath, filePath)
55         InspectorTest.addResult("    path " + fileSystemPath + " / " + filePath + " is mapped to " + (url ? url : null));
56     }
57     
58     createUISourceCode(projectId, "localhost/index.html");
59
60     createUISourceCode("http://www.example.com", "index.html");
61     createUISourceCode("http://localhost", "index.html");
62     createUISourceCode("http://localhost", "foo/index.html");
63     createUISourceCode("https://localhost", "index.html");
64
65     dumpHasMappingForURL("http://www.example.com/index.html");
66     dumpHasMappingForURL("http://localhost/index.html");
67     dumpHasMappingForURL("http://localhost/foo/index.html");
68     dumpHasMappingForURL("https://localhost/index.html");
69     InspectorTest.addResult("");
70
71     dumpUISourceCodeForURL("http://www.example.com/index.html");
72     dumpUISourceCodeForURL("http://localhost/index.html");
73     dumpUISourceCodeForURL("http://localhost/foo/index.html");
74     dumpUISourceCodeForURL("https://localhost/index.html");
75     InspectorTest.addResult("");
76
77     dumpURLForPath("/home/example.com", "foo/index.html");
78     dumpURLForPath("/home/example.com", "index.html");
79     dumpURLForPath("/var/www", "localhost/index.html");
80     dumpURLForPath("/var/www", "localhost/foo/index.html");
81     dumpURLForPath("/home/foo", "index.html");
82
83     InspectorTest.completeTest();
84 }
85 </script>
86 </head>
87 <body onload="runTest()">
88 <p>Tests workspace mappings</p>
89 </body>
90 </html>