| OLD | NEW |
| 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="../workspace-test.js"></script> | 5 <script src="../workspace-test.js"></script> |
| 6 <script src="../isolated-filesystem-test.js"></script> | 6 <script src="../isolated-filesystem-test.js"></script> |
| 7 <script src="./persistence-test.js"></script> | 7 <script src="./persistence-test.js"></script> |
| 8 <script> | 8 <script> |
| 9 | 9 |
| 10 function test() | 10 function test() |
| 11 { | 11 { |
| 12 // Pretend we are running under V8 front-end. | 12 // Pretend we are running under V8 front-end. |
| 13 WebInspector.targetManager.mainTarget().setIsNodeJSForTest(); | 13 SDK.targetManager.mainTarget().setIsNodeJSForTest(); |
| 14 | 14 |
| 15 var content = [ | 15 var content = [ |
| 16 '', | 16 '', |
| 17 'var express = require("express");', | 17 'var express = require("express");', |
| 18 '//TODO' | 18 '//TODO' |
| 19 ].join("\n"); | 19 ].join("\n"); |
| 20 | 20 |
| 21 var fsContent = WebInspector.Persistence._NodeShebang + content; | 21 var fsContent = Persistence.Persistence._NodeShebang + content; |
| 22 var nodeContent = WebInspector.Persistence._NodePrefix + content + WebInspec
tor.Persistence._NodeSuffix; | 22 var nodeContent = Persistence.Persistence._NodePrefix + content + Persistenc
e.Persistence._NodeSuffix; |
| 23 | 23 |
| 24 InspectorTest.addResult("Initial fileSystem content:"); | 24 InspectorTest.addResult("Initial fileSystem content:"); |
| 25 InspectorTest.addResult(indent(fsContent)); | 25 InspectorTest.addResult(indent(fsContent)); |
| 26 InspectorTest.addResult("\n Initial network content:"); | 26 InspectorTest.addResult("\n Initial network content:"); |
| 27 InspectorTest.addResult(indent(nodeContent)); | 27 InspectorTest.addResult(indent(nodeContent)); |
| 28 | 28 |
| 29 // Add network UISourceCode. | 29 // Add network UISourceCode. |
| 30 var networkProject = WebInspector.NetworkProject.forTarget(WebInspector.targ
etManager.mainTarget()); | 30 var networkProject = Bindings.NetworkProject.forTarget(SDK.targetManager.mai
nTarget()); |
| 31 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(WebInspect
or.targetManager.mainTarget()); | 31 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(SDK.targetManager.m
ainTarget()); |
| 32 var mainFrame = resourceTreeModel.mainFrame; | 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)); | 33 var contentProvider = new Common.StaticContentProvider("http://127.0.0.1:800
0/nodejs.js", Common.resourceTypes.Script, () => Promise.resolve(nodeContent)); |
| 34 networkProject.addFile(contentProvider, mainFrame, false); | 34 networkProject.addFile(contentProvider, mainFrame, false); |
| 35 | 35 |
| 36 // Add filesystem UISourceCode and mapping. | 36 // Add filesystem UISourceCode and mapping. |
| 37 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | 37 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 38 var fsEntry = fs.root.addFile("nodejs.js", fsContent); | 38 var fsEntry = fs.root.addFile("nodejs.js", fsContent); |
| 39 fs.addFileMapping("http://127.0.0.1:8000", "/"); | 39 fs.addFileMapping("http://127.0.0.1:8000", "/"); |
| 40 fs.reportCreated(function() { }); | 40 fs.reportCreated(function() { }); |
| 41 | 41 |
| 42 InspectorTest.waitForBinding("nodejs.js").then(onBindingCreated); | 42 InspectorTest.waitForBinding("nodejs.js").then(onBindingCreated); |
| 43 | 43 |
| 44 function onBindingCreated(binding) | 44 function onBindingCreated(binding) |
| 45 { | 45 { |
| 46 InspectorTest.addResult("Binding created: " + binding); | 46 InspectorTest.addResult("Binding created: " + binding); |
| 47 editNetworkUISourceCode(binding); | 47 editNetworkUISourceCode(binding); |
| 48 } | 48 } |
| 49 | 49 |
| 50 function editNetworkUISourceCode(binding) | 50 function editNetworkUISourceCode(binding) |
| 51 { | 51 { |
| 52 InspectorTest.addResult("\nRunning: Edit network uiSourceCode"); | 52 InspectorTest.addResult("\nRunning: Edit network uiSourceCode"); |
| 53 nodeContent = nodeContent.replace("//TODO", "network();\n//TODO"); | 53 nodeContent = nodeContent.replace("//TODO", "network();\n//TODO"); |
| 54 InspectorTest.addSniffer(WebInspector.Persistence.prototype, "_contentSy
ncedForTest", onSynced); | 54 InspectorTest.addSniffer(Persistence.Persistence.prototype, "_contentSyn
cedForTest", onSynced); |
| 55 binding.network.addRevision(nodeContent); | 55 binding.network.addRevision(nodeContent); |
| 56 | 56 |
| 57 function onSynced() | 57 function onSynced() |
| 58 { | 58 { |
| 59 dumpBindingContent(binding); | 59 dumpBindingContent(binding); |
| 60 changeFileSystem(binding); | 60 changeFileSystem(binding); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 function changeFileSystem(binding) | 64 function changeFileSystem(binding) |
| 65 { | 65 { |
| 66 InspectorTest.addResult("\nRunning: Edit fileSystem uiSourceCode"); | 66 InspectorTest.addResult("\nRunning: Edit fileSystem uiSourceCode"); |
| 67 fsContent = fsContent.replace("//TODO", "filesystem();\n//TODO"); | 67 fsContent = fsContent.replace("//TODO", "filesystem();\n//TODO"); |
| 68 InspectorTest.addSniffer(WebInspector.Persistence.prototype, "_contentSy
ncedForTest", onSynced); | 68 InspectorTest.addSniffer(Persistence.Persistence.prototype, "_contentSyn
cedForTest", onSynced); |
| 69 fsEntry.setContent(fsContent); | 69 fsEntry.setContent(fsContent); |
| 70 | 70 |
| 71 function onSynced() | 71 function onSynced() |
| 72 { | 72 { |
| 73 dumpBindingContent(binding); | 73 dumpBindingContent(binding); |
| 74 InspectorTest.completeTest(); | 74 InspectorTest.completeTest(); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 function dumpBindingContent(binding) | 78 function dumpBindingContent(binding) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 89 { | 89 { |
| 90 return content.split("\n").map(line => " " + line).join("\n"); | 90 return content.split("\n").map(line => " " + line).join("\n"); |
| 91 } | 91 } |
| 92 }; | 92 }; |
| 93 </script> | 93 </script> |
| 94 </head> | 94 </head> |
| 95 <body onload="runTest()"> | 95 <body onload="runTest()"> |
| 96 <p>Verify that syncing Node.js contents works fine.</p> | 96 <p>Verify that syncing Node.js contents works fine.</p> |
| 97 </body> | 97 </body> |
| 98 </html> | 98 </html> |
| OLD | NEW |