| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../http/tests/inspector/sources-test.js"></script> | 4 <script src="../http/tests/inspector/sources-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 function test() | 6 function test() |
| 7 { | 7 { |
| 8 var mockProjectId = 0; | 8 var mockProjectId = 0; |
| 9 function createMockProject() | 9 function createMockProject() |
| 10 { | 10 { |
| 11 var workspace = new Workspace.Workspace(); | 11 var workspace = new Workspace.Workspace(); |
| 12 var project = new Bindings.ContentProviderBasedProject(workspace, "mockP
roject:" + (++mockProjectId)); | 12 var project = new Bindings.ContentProviderBasedProject(workspace, "mockP
roject:" + (++mockProjectId)); |
| 13 project.requestFileContent = function(uri, callback) | 13 project.requestFileContent = function(uri, callback) |
| 14 { | 14 { |
| 15 callback("<script content>"); | 15 callback("<script content>"); |
| 16 } | 16 } |
| 17 project.setFileContent = function(uri, newContent, callback) | 17 project.setFileContent = function(uri, newContent, callback) |
| 18 { | 18 { |
| 19 } | 19 } |
| 20 return project; | 20 return project; |
| 21 } | 21 } |
| 22 | 22 |
| 23 function dumpUISourceCodeWithRevisions(uiSourceCode) | 23 function dumpUISourceCodeWithRevisions(uiSourceCode) |
| 24 { | 24 { |
| 25 var content = uiSourceCode._content; | 25 var content = uiSourceCode._content; |
| 26 var revisionsString = ""; | 26 var revisionsString = ""; |
| 27 for (var i = 0; i < uiSourceCode.history.length; ++i) { | 27 var history = uiSourceCode.history(); |
| 28 var revision = uiSourceCode.history[i]; | 28 for (var i = 0; i < history.length; ++i) { |
| 29 var revision = history[i]; |
| 29 if (i !== 0) | 30 if (i !== 0) |
| 30 revisionsString += ", "; | 31 revisionsString += ", "; |
| 31 revisionsString += "'" + revision.content + "'"; | 32 revisionsString += "'" + revision.content + "'"; |
| 32 } | 33 } |
| 33 InspectorTest.addResult("UISourceCode content: " + content); | 34 InspectorTest.addResult("UISourceCode content: " + content); |
| 34 InspectorTest.addResult(" revisions: " + revisionsString); | 35 InspectorTest.addResult(" revisions: " + revisionsString); |
| 35 } | 36 } |
| 36 | 37 |
| 37 InspectorTest.runTestSuite([ | 38 InspectorTest.runTestSuite([ |
| 38 function testAddRevisionsRevertToOriginal(next) | 39 function testAddRevisionsRevertToOriginal(next) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 uiSourceCode.commitWorkingCopy(function() { }); | 96 uiSourceCode.commitWorkingCopy(function() { }); |
| 96 | 97 |
| 97 InspectorTest.addResult("First revision added."); | 98 InspectorTest.addResult("First revision added."); |
| 98 dumpUISourceCodeWithRevisions(uiSourceCode); | 99 dumpUISourceCodeWithRevisions(uiSourceCode); |
| 99 uiSourceCode.setWorkingCopy("content3"); | 100 uiSourceCode.setWorkingCopy("content3"); |
| 100 uiSourceCode.setWorkingCopy("content4"); | 101 uiSourceCode.setWorkingCopy("content4"); |
| 101 uiSourceCode.commitWorkingCopy(function() { }); | 102 uiSourceCode.commitWorkingCopy(function() { }); |
| 102 | 103 |
| 103 InspectorTest.addResult("Second revision added."); | 104 InspectorTest.addResult("Second revision added."); |
| 104 dumpUISourceCodeWithRevisions(uiSourceCode); | 105 dumpUISourceCodeWithRevisions(uiSourceCode); |
| 105 uiSourceCode.history[0].revertToThis().then(onReverted); | 106 uiSourceCode.history()[0].revertToThis().then(onReverted); |
| 106 | 107 |
| 107 function onReverted() | 108 function onReverted() |
| 108 { | 109 { |
| 109 InspectorTest.addResult("Reverted to previous revision."); | 110 InspectorTest.addResult("Reverted to previous revision."); |
| 110 dumpUISourceCodeWithRevisions(uiSourceCode); | 111 dumpUISourceCodeWithRevisions(uiSourceCode); |
| 111 next(); | 112 next(); |
| 112 } | 113 } |
| 113 }, | 114 }, |
| 114 | 115 |
| 115 function testRequestContentAddRevisionsRevertToOriginal(next) | 116 function testRequestContentAddRevisionsRevertToOriginal(next) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 uiSourceCode.commitWorkingCopy(function() { }); | 191 uiSourceCode.commitWorkingCopy(function() { }); |
| 191 | 192 |
| 192 InspectorTest.addResult("First revision added."); | 193 InspectorTest.addResult("First revision added."); |
| 193 dumpUISourceCodeWithRevisions(uiSourceCode); | 194 dumpUISourceCodeWithRevisions(uiSourceCode); |
| 194 uiSourceCode.setWorkingCopy("content3"); | 195 uiSourceCode.setWorkingCopy("content3"); |
| 195 uiSourceCode.setWorkingCopy("content4"); | 196 uiSourceCode.setWorkingCopy("content4"); |
| 196 uiSourceCode.commitWorkingCopy(function() { }); | 197 uiSourceCode.commitWorkingCopy(function() { }); |
| 197 | 198 |
| 198 InspectorTest.addResult("Second revision added."); | 199 InspectorTest.addResult("Second revision added."); |
| 199 dumpUISourceCodeWithRevisions(uiSourceCode); | 200 dumpUISourceCodeWithRevisions(uiSourceCode); |
| 200 uiSourceCode.history[0].revertToThis().then(onReverted); | 201 uiSourceCode.history()[0].revertToThis().then(onReverted); |
| 201 | 202 |
| 202 function onReverted() | 203 function onReverted() |
| 203 { | 204 { |
| 204 InspectorTest.addResult("Reverted to previous revision."); | 205 InspectorTest.addResult("Reverted to previous revision."); |
| 205 dumpUISourceCodeWithRevisions(uiSourceCode); | 206 dumpUISourceCodeWithRevisions(uiSourceCode); |
| 206 next(); | 207 next(); |
| 207 } | 208 } |
| 208 } | 209 } |
| 209 }, | 210 }, |
| 210 ]); | 211 ]); |
| 211 } | 212 } |
| 212 </script> | 213 </script> |
| 213 </head> | 214 </head> |
| 214 <body onload="runTest()"> | 215 <body onload="runTest()"> |
| 215 <p>Tests revision support in UISourceCode.</p> | 216 <p>Tests revision support in UISourceCode.</p> |
| 216 <a href="https://bugs.webkit.org/show_bug.cgi?id=97669">Bug 97669</a> | 217 <a href="https://bugs.webkit.org/show_bug.cgi?id=97669">Bug 97669</a> |
| 217 </body> | 218 </body> |
| 218 </html> | 219 </html> |
| OLD | NEW |