OLD | NEW |
(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 InspectorTest.addResult("Initial fileSystem content:"); |
| 25 InspectorTest.addResult(indent(fsContent)); |
| 26 InspectorTest.addResult("\n Initial network content:"); |
| 27 InspectorTest.addResult(indent(nodeContent)); |
| 28 |
| 29 // Add network UISourceCode. |
| 30 var networkProject = WebInspector.NetworkProject.forTarget(WebInspector.targ
etManager.mainTarget()); |
| 31 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(WebInspect
or.targetManager.mainTarget()); |
| 32 var mainFrame = resourceTreeModel.mainFrame; |
| 33 var contentProvider = new WebInspector.StaticContentProvider("http://127.0.0
.1:8000/nodejs.js", WebInspector.resourceTypes.Script, () => Promise.resolve(nod
eContent)); |
| 34 networkProject.addFile(contentProvider, mainFrame, false); |
| 35 |
| 36 // Add filesystem UISourceCode and mapping. |
| 37 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 38 var fsEntry = fs.root.addFile("nodejs.js", fsContent); |
| 39 fs.addFileMapping("http://127.0.0.1:8000", "/"); |
| 40 fs.reportCreated(function() { }); |
| 41 |
| 42 InspectorTest.waitForBinding("nodejs.js").then(onBindingCreated); |
| 43 |
| 44 function onBindingCreated(binding) |
| 45 { |
| 46 InspectorTest.addResult("Binding created: " + binding); |
| 47 editNetworkUISourceCode(binding); |
| 48 } |
| 49 |
| 50 function editNetworkUISourceCode(binding) |
| 51 { |
| 52 InspectorTest.addResult("\nRunning: Edit network uiSourceCode"); |
| 53 nodeContent = nodeContent.replace("//TODO", "network();\n//TODO"); |
| 54 InspectorTest.addSniffer(WebInspector.Persistence.prototype, "_contentSy
ncedForTest", onSynced); |
| 55 binding.network.addRevision(nodeContent); |
| 56 |
| 57 function onSynced() |
| 58 { |
| 59 dumpBindingContent(binding); |
| 60 changeFileSystem(binding); |
| 61 } |
| 62 } |
| 63 |
| 64 function changeFileSystem(binding) |
| 65 { |
| 66 InspectorTest.addResult("\nRunning: Edit fileSystem uiSourceCode"); |
| 67 fsContent = fsContent.replace("//TODO", "filesystem();\n//TODO"); |
| 68 InspectorTest.addSniffer(WebInspector.Persistence.prototype, "_contentSy
ncedForTest", onSynced); |
| 69 fsEntry.setContent(fsContent); |
| 70 |
| 71 function onSynced() |
| 72 { |
| 73 dumpBindingContent(binding); |
| 74 InspectorTest.completeTest(); |
| 75 } |
| 76 } |
| 77 |
| 78 function dumpBindingContent(binding) |
| 79 { |
| 80 InspectorTest.addResult("Network:"); |
| 81 InspectorTest.addResult(indent(binding.network.workingCopy())); |
| 82 InspectorTest.addResult(""); |
| 83 InspectorTest.addResult("FileSystem:"); |
| 84 InspectorTest.addResult(indent(binding.fileSystem.workingCopy())); |
| 85 InspectorTest.addResult(""); |
| 86 } |
| 87 |
| 88 function indent(content) |
| 89 { |
| 90 return content.split("\n").map(line => " " + line).join("\n"); |
| 91 } |
| 92 }; |
| 93 </script> |
| 94 </head> |
| 95 <body onload="runTest()"> |
| 96 <p>Verify that syncing Node.js contents works fine.</p> |
| 97 </body> |
| 98 </html> |
OLD | NEW |