| 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 src="./resources/foo.js"></script> | 8 <script src="./resources/foo.js"></script> |
| 9 <script> | 9 <script> |
| 10 | 10 |
| 11 function test() | 11 function test() |
| 12 { | 12 { |
| 13 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | 13 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 14 var fsEntry = InspectorTest.addFooJSFile(fs); | 14 var fsEntry = InspectorTest.addFooJSFile(fs); |
| 15 var networkSourceFrame, fileSystemSourceFrame; | 15 var networkSourceFrame, fileSystemSourceFrame; |
| 16 | 16 |
| 17 InspectorTest.runTestSuite([ | 17 InspectorTest.runTestSuite([ |
| 18 function addFileSystem(next) | 18 function addFileSystem(next) |
| 19 { | 19 { |
| 20 fs.reportCreated(next); | 20 fs.reportCreated(next); |
| 21 }, | 21 }, |
| 22 | 22 |
| 23 function openNetworkTab(next) | 23 function openNetworkTab(next) |
| 24 { | 24 { |
| 25 InspectorTest.waitForUISourceCode("foo.js", WebInspector.projectType
s.Network) | 25 InspectorTest.waitForUISourceCode("foo.js", Workspace.projectTypes.N
etwork) |
| 26 .then(code => InspectorTest.showUISourceCodePromise(code)) | 26 .then(code => InspectorTest.showUISourceCodePromise(code)) |
| 27 .then(onNetworkTab); | 27 .then(onNetworkTab); |
| 28 | 28 |
| 29 function onNetworkTab(sourceFrame) | 29 function onNetworkTab(sourceFrame) |
| 30 { | 30 { |
| 31 networkSourceFrame = sourceFrame; | 31 networkSourceFrame = sourceFrame; |
| 32 dumpSourceFrame(networkSourceFrame); | 32 dumpSourceFrame(networkSourceFrame); |
| 33 next(); | 33 next(); |
| 34 } | 34 } |
| 35 }, | 35 }, |
| 36 | 36 |
| 37 function openFileSystemTab(next) | 37 function openFileSystemTab(next) |
| 38 { | 38 { |
| 39 InspectorTest.waitForUISourceCode("foo.js", WebInspector.projectType
s.FileSystem) | 39 InspectorTest.waitForUISourceCode("foo.js", Workspace.projectTypes.F
ileSystem) |
| 40 .then(onFileSystemSourceCode) | 40 .then(onFileSystemSourceCode) |
| 41 .then(onFileSystemTab); | 41 .then(onFileSystemTab); |
| 42 | 42 |
| 43 function onFileSystemSourceCode(code) | 43 function onFileSystemSourceCode(code) |
| 44 { | 44 { |
| 45 code.setWorkingCopy("\n\nwindow.foo = ()=>'foo2';"); | 45 code.setWorkingCopy("\n\nwindow.foo = ()=>'foo2';"); |
| 46 return InspectorTest.showUISourceCodePromise(code); | 46 return InspectorTest.showUISourceCodePromise(code); |
| 47 } | 47 } |
| 48 | 48 |
| 49 function onFileSystemTab(sourceFrame) | 49 function onFileSystemTab(sourceFrame) |
| 50 { | 50 { |
| 51 fileSystemSourceFrame = sourceFrame; | 51 fileSystemSourceFrame = sourceFrame; |
| 52 fileSystemSourceFrame.setSelection(new WebInspector.TextRange(2,
0, 2, 5)); | 52 fileSystemSourceFrame.setSelection(new Common.TextRange(2, 0, 2,
5)); |
| 53 fileSystemSourceFrame.scrollToLine(2); | 53 fileSystemSourceFrame.scrollToLine(2); |
| 54 dumpSourceFrame(fileSystemSourceFrame); | 54 dumpSourceFrame(fileSystemSourceFrame); |
| 55 dumpEditorTabs(); | 55 dumpEditorTabs(); |
| 56 next(); | 56 next(); |
| 57 } | 57 } |
| 58 }, | 58 }, |
| 59 | 59 |
| 60 function addFileMapping(next) | 60 function addFileMapping(next) |
| 61 { | 61 { |
| 62 InspectorTest.waitForBinding("foo.js").then(onBindingCreated); | 62 InspectorTest.waitForBinding("foo.js").then(onBindingCreated); |
| 63 WebInspector.fileSystemMapping.addFileMapping(fs.fileSystemPath, "ht
tp://127.0.0.1:8000", "/"); | 63 Workspace.fileSystemMapping.addFileMapping(fs.fileSystemPath, "http:
//127.0.0.1:8000", "/"); |
| 64 | 64 |
| 65 function onBindingCreated() | 65 function onBindingCreated() |
| 66 { | 66 { |
| 67 dumpEditorTabs(); | 67 dumpEditorTabs(); |
| 68 dumpSourceFrame(networkSourceFrame); | 68 dumpSourceFrame(networkSourceFrame); |
| 69 next(); | 69 next(); |
| 70 } | 70 } |
| 71 }, | 71 }, |
| 72 | 72 |
| 73 function removeFileMapping(next) | 73 function removeFileMapping(next) |
| 74 { | 74 { |
| 75 WebInspector.persistence.addEventListener(WebInspector.Persistence.E
vents.BindingRemoved, onBindingRemoved); | 75 Persistence.persistence.addEventListener(Persistence.Persistence.Eve
nts.BindingRemoved, onBindingRemoved); |
| 76 WebInspector.fileSystemMapping.removeFileMapping(fs.fileSystemPath,
"http://127.0.0.1:8000", "/"); | 76 Workspace.fileSystemMapping.removeFileMapping(fs.fileSystemPath, "ht
tp://127.0.0.1:8000", "/"); |
| 77 | 77 |
| 78 function onBindingRemoved(event) | 78 function onBindingRemoved(event) |
| 79 { | 79 { |
| 80 var binding = event.data; | 80 var binding = event.data; |
| 81 if (binding.network.name() !== "foo.js") | 81 if (binding.network.name() !== "foo.js") |
| 82 return | 82 return |
| 83 WebInspector.persistence.removeEventListener(WebInspector.Persis
tence.Events.BindingRemoved, onBindingRemoved); | 83 Persistence.persistence.removeEventListener(Persistence.Persiste
nce.Events.BindingRemoved, onBindingRemoved); |
| 84 dumpEditorTabs(); | 84 dumpEditorTabs(); |
| 85 dumpSourceFrame(fileSystemSourceFrame); | 85 dumpSourceFrame(fileSystemSourceFrame); |
| 86 next(); | 86 next(); |
| 87 } | 87 } |
| 88 }, | 88 }, |
| 89 ]); | 89 ]); |
| 90 | 90 |
| 91 function dumpEditorTabs() | 91 function dumpEditorTabs() |
| 92 { | 92 { |
| 93 var editorContainer = WebInspector.panels.sources._sourcesView._editorCo
ntainer; | 93 var editorContainer = UI.panels.sources._sourcesView._editorContainer; |
| 94 var openedUISourceCodes = editorContainer._tabIds.keysArray(); | 94 var openedUISourceCodes = editorContainer._tabIds.keysArray(); |
| 95 openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url())); | 95 openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url())); |
| 96 InspectorTest.addResult("Opened tabs: "); | 96 InspectorTest.addResult("Opened tabs: "); |
| 97 for (code of openedUISourceCodes) | 97 for (code of openedUISourceCodes) |
| 98 InspectorTest.addResult(" " + code.url()); | 98 InspectorTest.addResult(" " + code.url()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 function dumpSourceFrame(sourceFrame) | 101 function dumpSourceFrame(sourceFrame) |
| 102 { | 102 { |
| 103 InspectorTest.addResult("SourceFrame: " + sourceFrame._url); | 103 InspectorTest.addResult("SourceFrame: " + sourceFrame._url); |
| 104 InspectorTest.addResult(" selection: " + sourceFrame.selection()); | 104 InspectorTest.addResult(" selection: " + sourceFrame.selection()); |
| 105 InspectorTest.addResult(" firstVisibleLine: " + sourceFrame.textEdito
r.firstVisibleLine()); | 105 InspectorTest.addResult(" firstVisibleLine: " + sourceFrame.textEdito
r.firstVisibleLine()); |
| 106 InspectorTest.addResult(" isDirty: " + sourceFrame.uiSourceCode().isD
irty()); | 106 InspectorTest.addResult(" isDirty: " + sourceFrame.uiSourceCode().isD
irty()); |
| 107 } | 107 } |
| 108 }; | 108 }; |
| 109 </script> | 109 </script> |
| 110 </head> | 110 </head> |
| 111 <body onload="runTest()"> | 111 <body onload="runTest()"> |
| 112 <p>Verify that tabs get merged and split when binding is added and removed.</p> | 112 <p>Verify that tabs get merged and split when binding is added and removed.</p> |
| 113 </body> | 113 </body> |
| 114 </html> | 114 </html> |
| OLD | NEW |