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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-sync-content-nodejs.html

Issue 2349343002: DevTools: introduce persistence/ module (Closed)
Patch Set: reupload 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
(Empty)
1 <html>
2 <head>
3 <script src="../inspector-test.js"></script>
4 <script src="../debugger-test.js"></script>
5 <script src="../workspace-test.js"></script>
6 <script src="../isolated-filesystem-test.js"></script>
7 <script src="./persistence-test.js"></script>
8 <script>
9
10 function test()
11 {
12 // Pretend we are running under V8 front-end.
13 Runtime._queryParamsObject["v8only"] = true;
14
15 var content = [
16 '',
17 'var express = require("express");',
18 '//TODO'
19 ].join("\n");
20
21 var fsContent = WebInspector.Persistence._NodeShebang + content;
22 var nodeContent = WebInspector.Persistence._NodePrefix + content + WebInspec tor.Persistence._NodeSuffix;
23
24 // Add network UISourceCode.
25 var networkProject = WebInspector.NetworkProject.forTarget(WebInspector.targ etManager.mainTarget());
26 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(WebInspect or.targetManager.mainTarget());
27 var mainFrame = resourceTreeModel.mainFrame;
28 var contentProvider = new WebInspector.StaticContentProvider("http://127.0.0 .1:8000/nodejs.js", WebInspector.resourceTypes.Script, () => Promise.resolve(nod eContent));
29 networkProject.addFile(contentProvider, mainFrame, false);
30
31 // Add filesystem UISourceCode and mapping.
32 var fs = new InspectorTest.TestFileSystem("file:///var/www");
33 var fsEntry = fs.root.addFile("nodejs.js", fsContent);
34 fs.addFileMapping("http://127.0.0.1:8000", "/");
35 fs.reportCreated(function() { });
36
37 InspectorTest.waitForBinding("nodejs.js").then(onBindingCreated);
38
39 function onBindingCreated(binding)
40 {
41 InspectorTest.addResult("Binding created: " + binding);
42 editNetworkUISourceCode(binding);
43 }
44
45 function editNetworkUISourceCode(binding)
46 {
47 InspectorTest.addResult("\nRunning: Edit network uiSourceCode");
48 nodeContent = nodeContent.replace("//TODO", "network();\n//TODO");
49 InspectorTest.addSniffer(WebInspector.Persistence.prototype, "_contentSy ncedForTest", onSynced);
50 binding.network.addRevision(nodeContent);
51
52 function onSynced()
53 {
54 dumpBindingContent(binding);
55 changeFileSystem(binding);
56 }
57 }
58
59 function changeFileSystem(binding)
60 {
61 InspectorTest.addResult("\nRunning: Edit fileSystem uiSourceCode");
62 fsContent = fsContent.replace("//TODO", "filesystem();\n//TODO");
63 InspectorTest.addSniffer(WebInspector.Persistence.prototype, "_contentSy ncedForTest", onSynced);
64 fsEntry.setContent(fsContent);
65
66 function onSynced()
67 {
68 dumpBindingContent(binding);
69 InspectorTest.completeTest();
70 }
71 }
72
73 function dumpBindingContent(binding)
74 {
75 InspectorTest.addResult("Network:");
76 InspectorTest.addResult(indent(binding.network.workingCopy()));
77 InspectorTest.addResult("");
78 InspectorTest.addResult("FileSystem:");
79 InspectorTest.addResult(indent(binding.fileSystem.workingCopy()));
80 InspectorTest.addResult("");
81 }
82
83 function indent(content)
84 {
85 return content.split("\n").map(line => " " + line).join("\n");
86 }
87 };
88 </script>
89 </head>
90 <body onload="runTest()">
91 <p>Verify that syncing Node.js contents works fine.</p>
92 </body>
93 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698