| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| |
| <script> |
| |
| function test() |
| { |
| var MockProject = function() {} |
| MockProject.prototype.requestFileContent = function(uri, callback) |
| { |
| InspectorTest.addResult("Content is requested from SourceCodeProvider."); |
| setTimeout(callback.bind(null, "var x = 0;", false, "text/javascript"), 0); |
| } |
| |
| InspectorTest.runTestSuite([ |
| function testUISourceCode(next) |
| { |
| var uiSourceCode = new WebInspector.UISourceCode(new MockProject(), "uri", "originURL", "url", WebInspector.resourceTypes.Script, true); |
| function didRequestContent(callNumber, content, contentEncoded, mimeType) |
| { |
| InspectorTest.addResult("Callback " + callNumber + " is invoked."); |
| InspectorTest.assertEquals("text/javascript", mimeType); |
| InspectorTest.assertEquals("var x = 0;", content); |
| |
| if (callNumber === 3) { |
| // Check that sourceCodeProvider.requestContent won't be called anymore. |
| uiSourceCode.requestContent(function(content, contentEncoded, mimeType) |
| { |
| InspectorTest.assertEquals("text/javascript", mimeType); |
| InspectorTest.assertEquals("var x = 0;", content); |
| next(); |
| }); |
| } |
| } |
| // Check that all callbacks will be invoked. |
| uiSourceCode.requestContent(didRequestContent.bind(null, 1)); |
| uiSourceCode.requestContent(didRequestContent.bind(null, 2)); |
| uiSourceCode.requestContent(didRequestContent.bind(null, 3)); |
| } |
| ]); |
| }; |
| |
| </script> |
| |
| </head> |
| |
| <body onload="runTest()"> |
| <p>Tests UISourceCode class.</p> |
| </body> |
| </html> |