| <html> |
| <head> |
| <script src="../inspector-test.js"></script> |
| <script src="../debugger-test.js"></script> |
| <script src="../isolated-filesystem-test.js"></script> |
| <script src="./persistence-test.js"></script> |
| <script> |
| |
| async function test() |
| { |
| var testMapping = InspectorTest.initializeTestMapping(); |
| // Pretend we are running under V8 front-end. |
| SDK.targetManager.mainTarget().setIsNodeJSForTest(); |
| |
| var content = [ |
| '', |
| '', |
| 'var express = require("express");', |
| '//TODO' |
| ].join("\n"); |
| |
| var fsContent = Persistence.Persistence._NodeShebang + content; |
| var nodeContent = Persistence.Persistence._NodePrefix + content + Persistence.Persistence._NodeSuffix; |
| |
| InspectorTest.addResult("Initial fileSystem content:"); |
| InspectorTest.addResult(indent(fsContent)); |
| InspectorTest.addResult("\n Initial network content:"); |
| InspectorTest.addResult(indent(nodeContent)); |
| |
| await InspectorTest.addScriptUISourceCode("http://127.0.0.1:8000/nodejs.js", nodeContent); |
| |
| // Add filesystem UISourceCode and mapping. |
| var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| var fsEntry = fs.root.addFile("nodejs.js", fsContent); |
| fs.reportCreated(function() { }); |
| |
| var binding; |
| testMapping.addBinding("nodejs.js"); |
| InspectorTest.waitForBinding("nodejs.js").then(onBindingCreated); |
| |
| function onBindingCreated(theBinding) |
| { |
| binding = theBinding; |
| InspectorTest.addResult("Binding created: " + binding); |
| InspectorTest.runTestSuite(testSuite); |
| } |
| |
| var testSuite = [ |
| function addNetworkUISourceCodeRevision(next) |
| { |
| var newContent = nodeContent.replace("//TODO", "network();\n//TODO"); |
| InspectorTest.addSniffer(Persistence.Persistence.prototype, "_contentSyncedForTest", onSynced); |
| binding.network.addRevision(newContent); |
| |
| function onSynced() |
| { |
| dumpBindingContent(); |
| next(); |
| } |
| }, |
| |
| function setNetworkUISourceCodeWorkingCopy(next) |
| { |
| var newContent = nodeContent.replace("//TODO", "workingCopy1();\n//TODO"); |
| InspectorTest.addSniffer(Persistence.Persistence.prototype, "_contentSyncedForTest", onSynced); |
| binding.network.setWorkingCopy(newContent); |
| |
| function onSynced() |
| { |
| dumpBindingContent(); |
| next(); |
| } |
| }, |
| |
| function changeFileSystemFile(next) |
| { |
| var newContent = fsContent.replace("//TODO", "filesystem();\n//TODO"); |
| InspectorTest.addSniffer(Persistence.Persistence.prototype, "_contentSyncedForTest", onSynced); |
| fsEntry.setContent(newContent); |
| |
| function onSynced() |
| { |
| dumpBindingContent(); |
| next(); |
| } |
| }, |
| |
| function setFileSystemUISourceCodeWorkingCopy(next) |
| { |
| var newContent = fsContent.replace("//TODO", "workingCopy2();\n//TODO"); |
| InspectorTest.addSniffer(Persistence.Persistence.prototype, "_contentSyncedForTest", onSynced); |
| binding.fileSystem.setWorkingCopy(newContent); |
| |
| function onSynced() |
| { |
| dumpBindingContent(); |
| next(); |
| } |
| }, |
| ]; |
| |
| function dumpBindingContent() |
| { |
| InspectorTest.addResult("Network:"); |
| InspectorTest.addResult(indent(binding.network.workingCopy())); |
| InspectorTest.addResult(""); |
| InspectorTest.addResult("FileSystem:"); |
| InspectorTest.addResult(indent(binding.fileSystem.workingCopy())); |
| InspectorTest.addResult(""); |
| } |
| |
| function indent(content) |
| { |
| return content.split("\n").map(line => " " + line).join("\n"); |
| } |
| }; |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Verify that syncing Node.js contents works fine.</p> |
| </body> |
| </html> |