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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector/file-system-project-mapping.html

Issue 2542073002: DevTools: [Persistence] validate persistence binding. (Closed)
Patch Set: rebaseline tests Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/file-system-project-mapping-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="inspector-test.js"></script> 3 <script src="inspector-test.js"></script>
4 <script src="debugger-test.js"></script> 4 <script src="debugger-test.js"></script>
5 <script src="persistence/persistence-test.js"></script>
5 <script src="isolated-filesystem-test.js"></script> 6 <script src="isolated-filesystem-test.js"></script>
6 <script> 7 <script>
7 function addScript(url) 8 function addScript(url)
8 { 9 {
9 var script = document.createElement("script"); 10 var script = document.createElement("script");
10 script.setAttribute("src", url); 11 script.setAttribute("src", url);
11 document.head.appendChild(script); 12 document.head.appendChild(script);
12 } 13 }
13 14
14 function test() 15 function test()
15 { 16 {
16 var target = InspectorTest.mainTarget; 17 var target = InspectorTest.mainTarget;
17 var persistence = Persistence.persistence;
18 var fileSystemProjectId = Persistence.FileSystemWorkspaceBinding.projectId(" file:///var/www"); 18 var fileSystemProjectId = Persistence.FileSystemWorkspaceBinding.projectId(" file:///var/www");
19 19
20 function dumpFileSystemUISourceCodesMappings() 20 function dumpFileSystemUISourceCodesMappings()
21 { 21 {
22 var uiSourceCodes = Workspace.workspace.project(fileSystemProjectId).uiS ourceCodes(); 22 var uiSourceCodes = Workspace.workspace.project(fileSystemProjectId).uiS ourceCodes();
23 InspectorTest.addResult("UISourceCode uri to url mappings:"); 23 InspectorTest.addResult("UISourceCode uri to url mappings:");
24 for (var uiSourceCode of uiSourceCodes) { 24 for (var uiSourceCode of uiSourceCodes) {
25 var binding = persistence.binding(uiSourceCode); 25 var binding = Persistence.persistence.binding(uiSourceCode);
26 var url = binding ? binding.network.url() : ""; 26 var url = binding ? binding.network.url() : "";
27 InspectorTest.addResult(" " + uiSourceCode.url() + " -> " + url); 27 InspectorTest.addResult(" " + uiSourceCode.url() + " -> " + url);
28 } 28 }
29 } 29 }
30 30
31 InspectorTest.runTestSuite([ 31 InspectorTest.runTestSuite([
32 function testAutomaticMapping(next)
33 {
34 InspectorTest.addResult("Adding file system.");
35 var fs = new InspectorTest.TestFileSystem("file:///var/www");
36 fs.root.mkdir("html").addFile("foo.js", "<foo content>");
37 fs.root.addFile("bar.js", "<bar content>");
38 fs.reportCreated(fileSystemCreated1);
39 var networkUISourceCode;
40
41 function fileSystemCreated1()
42 {
43 InspectorTest.addResult("Adding network resource.");
44 InspectorTest.waitForUISourceCode(scriptsAdded, "resources/bar.j s");
45 InspectorTest.evaluateInPage("addScript('resources/html/foo.js') ");
46 InspectorTest.evaluateInPage("addScript('resources/bar.js')");
47 }
48
49 function scriptsAdded()
50 {
51 dumpFileSystemUISourceCodesMappings();
52
53 var uiSourceCode = Workspace.workspace.uiSourceCode(fileSystemPr ojectId, "file:///var/www/html/foo.js");
54 networkUISourceCode = Workspace.workspace.uiSourceCode(Bindings. NetworkProject.projectId(target, InspectorTest.resourceTreeModel.mainFrame, fals e), "http://127.0.0.1:8000/inspector/resources/html/foo.js");
55 InspectorTest.addResult("Adding mapping between network and file system resources.");
56
57 var fileSystemPath = Persistence.FileSystemWorkspaceBinding.file SystemPath(uiSourceCode.project().id());
58 Workspace.fileSystemMapping.addMappingForResource(networkUISourc eCode.url(), fileSystemPath, uiSourceCode.url());
59 var setting = JSON.stringify(Workspace.fileSystemMapping._fileSy stemMappingSetting.get());
60
61 InspectorTest.addResult("Emulate reloading inspector.");
62 fs.reportRemoved();
63 Workspace.fileSystemMapping._fileSystemMappingSetting.set(JSON.p arse(setting));
64 Workspace.fileSystemMapping._loadFromSettings();
65 fs.reportCreated(fileSystemCreated2);
66 }
67
68 function fileSystemCreated2()
69 {
70 dumpFileSystemUISourceCodesMappings();
71
72 InspectorTest.addResult("Removing mapping between network and fi le system resources.");
73 var uiSourceCode = Workspace.workspace.uiSourceCode(fileSystemPr ojectId, "file:///var/www/html/foo.js");
74 Workspace.fileSystemMapping.removeMappingForURL(uiSourceCode.url ());
75
76 InspectorTest.addResult("Emulate reloading inspector.");
77 fs.reportRemoved();
78 fs.reportCreated(fileSystemCreated3);
79 }
80
81 function fileSystemCreated3()
82 {
83 dumpFileSystemUISourceCodesMappings();
84
85 Workspace.fileSystemMapping.removeMappingForURL(networkUISourceC ode.url());
86 fs.reportRemoved();
87 next();
88 }
89 },
90
91 function testProjectBasedMapping(next) 32 function testProjectBasedMapping(next)
92 { 33 {
93 InspectorTest.addResult("Adding file system."); 34 InspectorTest.addResult("Adding file system.");
94 var fs = new InspectorTest.TestFileSystem("file:///var/www"); 35 var fs = new InspectorTest.TestFileSystem("file:///var/www");
95 fs.root.mkdir("html").addFile("foo.js", "<foo content>"); 36 fs.root.mkdir("html").addFile("foo.js", "var foo = 1;");
96 fs.root.mkdir("html2").addFile("bar.js", "<bar content>"); 37 fs.root.mkdir("html2").addFile("bar.js", "var bar = 2;");
97 fs.root.addFile(".devtools", JSON.stringify({ mappings: [ { folder: "/html/", url: "http://127.0.0.1:8000/inspector/resources/html/" }, { folder: "/ html2/", url: "http://127.0.0.1:8000/inspector/resources/html2/" } ]})); 38 fs.root.addFile(".devtools", JSON.stringify({ mappings: [ { folder: "/html/", url: "http://127.0.0.1:8000/inspector/resources/html/" }, { folder: "/ html2/", url: "http://127.0.0.1:8000/inspector/resources/html2/" } ]}));
98 fs.reportCreated(fileSystemCreated); 39 fs.reportCreated(fileSystemCreated);
99 40
100 function fileSystemCreated() 41 function fileSystemCreated()
101 { 42 {
102 InspectorTest.evaluateInPage("addScript('resources/html/foo.js') "); 43 InspectorTest.evaluateInPage("addScript('resources/html/foo.js') ");
103 InspectorTest.evaluateInPage("addScript('resources/html2/bar.js' )"); 44 InspectorTest.evaluateInPage("addScript('resources/html2/bar.js' )");
104 InspectorTest.waitForUISourceCode(scriptsAdded, "resources/html2 /bar.js"); 45 Promise.all([
46 InspectorTest.waitForBinding("foo.js"),
47 InspectorTest.waitForBinding("bar.js")
48 ]).then(onBindings);
105 } 49 }
106 50
107 function scriptsAdded() 51 function onBindings()
108 { 52 {
109 dumpFileSystemUISourceCodesMappings(); 53 dumpFileSystemUISourceCodesMappings();
110 fs.reportRemoved(); 54 fs.reportRemoved();
111 next(); 55 next();
112 } 56 }
113 } 57 }
114 ]); 58 ]);
115 }; 59 };
116 </script> 60 </script>
117 </head> 61 </head>
118 <body onload="runTest()"> 62 <body onload="runTest()">
119 <p>Tests file system project mappings.</p> 63 <p>Tests file system project mappings.</p>
120 </body> 64 </body>
121 </html> 65 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/file-system-project-mapping-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698