3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
9 var MockProject = function() {}
10 MockProject.prototype.requestFileContent = function(uri, callback)
12 InspectorTest.addResult("Content is requested from SourceCodeProvider.");
13 setTimeout(callback.bind(null, "var x = 0;"), 0);
15 MockProject.prototype.isServiceProject = function() { return false; };
17 InspectorTest.runTestSuite([
18 function testUISourceCode(next)
20 var uiSourceCode = new WebInspector.UISourceCode(new MockProject(), "parentPath", "name", "originURL", "url", WebInspector.resourceTypes.Script);
21 function didRequestContent(callNumber, content)
23 InspectorTest.addResult("Callback " + callNumber + " is invoked.");
24 InspectorTest.assertEquals("text/javascript", uiSourceCode.highlighterType());
25 InspectorTest.assertEquals("var x = 0;", content);
27 if (callNumber === 3) {
28 // Check that sourceCodeProvider.requestContent won't be called anymore.
29 uiSourceCode.requestContent(function(content)
31 InspectorTest.assertEquals("text/javascript", uiSourceCode.highlighterType());
32 InspectorTest.assertEquals("var x = 0;", content);
37 // Check that all callbacks will be invoked.
38 uiSourceCode.requestContent(didRequestContent.bind(null, 1));
39 uiSourceCode.requestContent(didRequestContent.bind(null, 2));
40 uiSourceCode.requestContent(didRequestContent.bind(null, 3));
49 <body onload="runTest()">
50 <p>Tests UISourceCode class.</p>