Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/workspace-mapping.html

Issue 2349343002: DevTools: introduce persistence/ module (Closed)
Patch Set: simplify test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script> 3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/workspace-test.js"></script> 4 <script src="../http/tests/inspector/workspace-test.js"></script>
5 <script> 5 <script>
6 function test() 6 function test()
7 { 7 {
8 var uiSourceCodes = {};
9 var projects = {}; 8 var projects = {};
10 var workspace = new WebInspector.Workspace(); 9 var workspace = new WebInspector.Workspace();
11 10
12 function createUISourceCode(projectId, path) 11 function createUISourceCode(projectId, relativePath)
13 { 12 {
14 if (projectId.startsWith("1:"))
15 projectId = projectId.substring(2);
16 var project = projects[projectId]; 13 var project = projects[projectId];
17 if (!projects[projectId]) { 14 if (!projects[projectId]) {
18 project = new WebInspector.ProjectStore(workspace, projectId, WebIns pector.projectTypes.Network, ""); 15 var projectType = projectId.startsWith("file") ? WebInspector.projec tTypes.FileSystem : WebInspector.projectTypes.Network;
16 project = new WebInspector.ProjectStore(workspace, projectId, projec tType, "");
19 workspace.addProject(project); 17 workspace.addProject(project);
20 projects[projectId] = project; 18 projects[projectId] = project;
21 } 19 }
22 var uiSourceCode = project.createUISourceCode(path, WebInspector.resourc eTypes.Script); 20 var uiSourceCode = project.createUISourceCode(projectId +"/" + relativeP ath, WebInspector.resourceTypes.Script);
23 project.addUISourceCode(uiSourceCode); 21 project.addUISourceCode(uiSourceCode);
24 } 22 }
25 23
26 var fileSystemMapping = new WebInspector.FileSystemMapping();
27 var fileSystemPath = "file:///var/www";
28 var projectId = WebInspector.FileSystemWorkspaceBinding.projectId(fileSystem Path);
29 fileSystemMapping.addFileSystem("file:///var/www");
30 fileSystemMapping.addFileMapping("file:///var/www", "http://localhost/", "/l ocalhost/");
31 var fileSystemWorkspaceBinding = new WebInspector.FileSystemWorkspaceBinding (WebInspector.isolatedFileSystemManager, workspace);
32 var networkMapping = new WebInspector.NetworkMapping(WebInspector.targetMana ger, workspace, fileSystemWorkspaceBinding, fileSystemMapping);
33
34 function dumpHasMappingForURL(url)
35 {
36 var result = networkMapping.hasMappingForNetworkURL(url)
37 if (result)
38 InspectorTest.addResult(" url " + url + " is mapped.");
39 else
40 InspectorTest.addResult(" url " + url + " is not mapped.");
41 }
42
43 function dumpUISourceCodeForURL(url) 24 function dumpUISourceCodeForURL(url)
44 { 25 {
45 var uiSourceCode = networkMapping.uiSourceCodeForURLForAnyTarget(url); 26 var uiSourceCode = workspace.uiSourceCodeForURL(url);
46 InspectorTest.addResult(" url " + url + " is mapped to " + (uiSourceC ode ? uiSourceCode.url() : null)); 27 InspectorTest.addResult("uiSourceCode for url " + url + ": " + (uiSource Code ? "EXISTS" : "null"));
47 } 28 }
48 29
49 function dumpURLForPath(fileSystemPath, filePath) 30 createUISourceCode("file:///var/www", "localhost/index.html");
50 {
51 var url = networkMapping._networkURLForFileSystemURL(fileSystemPath, fil eSystemPath + "/" + filePath)
52 InspectorTest.addResult(" path " + fileSystemPath + " / " + filePath + " is mapped to " + (url ? url : null));
53 }
54
55 createUISourceCode(projectId, "file:///var/www/localhost/index.html");
56 31
57 createUISourceCode("1:http://www.example.com", "index.html"); 32 createUISourceCode("http://www.example.com", "index.html");
58 createUISourceCode("1:http://localhost", "index.html"); 33 createUISourceCode("http://localhost", "index.html");
59 createUISourceCode("1:http://localhost", "foo/index.html"); 34 createUISourceCode("http://localhost", "foo/index.html");
60 createUISourceCode("1:https://localhost", "index.html"); 35 createUISourceCode("https://localhost", "index.html");
61
62 dumpHasMappingForURL("http://www.example.com/index.html");
63 dumpHasMappingForURL("http://localhost/index.html");
64 dumpHasMappingForURL("http://localhost/foo/index.html");
65 dumpHasMappingForURL("https://localhost/index.html");
66 InspectorTest.addResult("");
67 36
68 dumpUISourceCodeForURL("http://www.example.com/index.html"); 37 dumpUISourceCodeForURL("http://www.example.com/index.html");
69 dumpUISourceCodeForURL("http://localhost/index.html"); 38 dumpUISourceCodeForURL("http://localhost/index.html");
70 dumpUISourceCodeForURL("http://localhost/foo/index.html"); 39 dumpUISourceCodeForURL("http://localhost/foo/index.html");
71 dumpUISourceCodeForURL("https://localhost/index.html"); 40 dumpUISourceCodeForURL("https://localhost/index.html");
72 InspectorTest.addResult(""); 41 dumpUISourceCodeForURL("file:///var/www/localhost/index.html");
73 42 dumpUISourceCodeForURL("file:///var/www/localhost/index2.html");
74 dumpURLForPath("file:///home/example.com", "foo/index.html");
75 dumpURLForPath("file:///home/example.com", "index.html");
76 dumpURLForPath("file:///var/www", "localhost/index.html");
77 dumpURLForPath("file:///var/www", "localhost/foo/index.html");
78 dumpURLForPath("file:///home/foo", "index.html");
79 43
80 InspectorTest.completeTest(); 44 InspectorTest.completeTest();
81 } 45 }
82 </script> 46 </script>
83 </head> 47 </head>
84 <body onload="runTest()"> 48 <body onload="runTest()">
85 <p>Tests workspace mappings</p> 49 <p>Tests workspace mappings</p>
86 </body> 50 </body>
87 </html> 51 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698