| 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 | 4 |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function test() | 7 function test() |
| 8 { | 8 { |
| 9 var MockProject = function() {} | 9 var MockProject = class extends Workspace.ProjectStore { |
| 10 MockProject.prototype.requestFileContent = function(uri, callback) | 10 requestFileContent(uri, callback) { |
| 11 { | 11 InspectorTest.addResult("Content is requested from SourceCodeProvide
r."); |
| 12 InspectorTest.addResult("Content is requested from SourceCodeProvider.")
; | 12 setTimeout(callback.bind(null, "var x = 0;"), 0); |
| 13 setTimeout(callback.bind(null, "var x = 0;"), 0); | 13 } |
| 14 } | 14 |
| 15 MockProject.prototype.isServiceProject = function() { return false; }; | 15 mimeType() { |
| 16 MockProject.prototype.type = function() { return Workspace.projectTypes.Debu
gger; } | 16 return 'text/javascript'; |
| 17 MockProject.prototype.url = function() { return "mock://debugger-ui/"; } | 17 } |
| 18 |
| 19 isServiceProject() { |
| 20 return false; |
| 21 } |
| 22 |
| 23 type() { |
| 24 return Workspace.projectTypes.Debugger; |
| 25 } |
| 26 |
| 27 url() { |
| 28 return "mock://debugger-ui/"; |
| 29 } |
| 30 }; |
| 18 | 31 |
| 19 InspectorTest.runTestSuite([ | 32 InspectorTest.runTestSuite([ |
| 20 function testUISourceCode(next) | 33 function testUISourceCode(next) |
| 21 { | 34 { |
| 22 var uiSourceCode = new Workspace.UISourceCode(new MockProject(), "ur
l", Common.resourceTypes.Script); | 35 var uiSourceCode = new Workspace.UISourceCode(new MockProject(), "ur
l", Common.resourceTypes.Script); |
| 23 function didRequestContent(callNumber, content) | 36 function didRequestContent(callNumber, content) |
| 24 { | 37 { |
| 25 InspectorTest.addResult("Callback " + callNumber + " is invoked.
"); | 38 InspectorTest.addResult("Callback " + callNumber + " is invoked.
"); |
| 26 InspectorTest.assertEquals("text/javascript", Bindings.NetworkPr
oject.uiSourceCodeMimeType(uiSourceCode)); | 39 InspectorTest.assertEquals("text/javascript", uiSourceCode.mimeT
ype()); |
| 27 InspectorTest.assertEquals("var x = 0;", content); | 40 InspectorTest.assertEquals("var x = 0;", content); |
| 28 | 41 |
| 29 if (callNumber === 3) { | 42 if (callNumber === 3) { |
| 30 // Check that sourceCodeProvider.requestContent won't be cal
led anymore. | 43 // Check that sourceCodeProvider.requestContent won't be cal
led anymore. |
| 31 uiSourceCode.requestContent().then(function(content) | 44 uiSourceCode.requestContent().then(function(content) |
| 32 { | 45 { |
| 33 InspectorTest.assertEquals("text/javascript", Bindings.N
etworkProject.uiSourceCodeMimeType(uiSourceCode)); | 46 InspectorTest.assertEquals("text/javascript", uiSourceCo
de.mimeType()); |
| 34 InspectorTest.assertEquals("var x = 0;", content); | 47 InspectorTest.assertEquals("var x = 0;", content); |
| 35 next(); | 48 next(); |
| 36 }); | 49 }); |
| 37 } | 50 } |
| 38 } | 51 } |
| 39 // Check that all callbacks will be invoked. | 52 // Check that all callbacks will be invoked. |
| 40 uiSourceCode.requestContent().then(didRequestContent.bind(null, 1)); | 53 uiSourceCode.requestContent().then(didRequestContent.bind(null, 1)); |
| 41 uiSourceCode.requestContent().then(didRequestContent.bind(null, 2)); | 54 uiSourceCode.requestContent().then(didRequestContent.bind(null, 2)); |
| 42 uiSourceCode.requestContent().then(didRequestContent.bind(null, 3)); | 55 uiSourceCode.requestContent().then(didRequestContent.bind(null, 3)); |
| 43 } | 56 } |
| 44 ]); | 57 ]); |
| 45 }; | 58 }; |
| 46 | 59 |
| 47 </script> | 60 </script> |
| 48 | 61 |
| 49 </head> | 62 </head> |
| 50 | 63 |
| 51 <body onload="runTest()"> | 64 <body onload="runTest()"> |
| 52 <p>Tests UISourceCode class.</p> | 65 <p>Tests UISourceCode class.</p> |
| 53 </body> | 66 </body> |
| 54 </html> | 67 </html> |
| OLD | NEW |