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; };
16 MockProject
.prototype.type = function() { return WebInspector
.projectTypes
.Debugger
; }
18 InspectorTest
.runTestSuite([
19 function testUISourceCode(next
)
21 var uiSourceCode
= new WebInspector
.UISourceCode(new MockProject(), "parentPath", "name", "originURL", "url", WebInspector
.resourceTypes
.Script
);
22 function didRequestContent(callNumber
, content
)
24 InspectorTest
.addResult("Callback " + callNumber
+ " is invoked.");
25 InspectorTest
.assertEquals("text/javascript", WebInspector
.SourcesView
.uiSourceCodeHighlighterType(uiSourceCode
));
26 InspectorTest
.assertEquals("var x = 0;", content
);
28 if (callNumber
=== 3) {
29 // Check that sourceCodeProvider.requestContent won't be called anymore.
30 uiSourceCode
.requestContent(function(content
)
32 InspectorTest
.assertEquals("text/javascript", WebInspector
.SourcesView
.uiSourceCodeHighlighterType(uiSourceCode
));
33 InspectorTest
.assertEquals("var x = 0;", content
);
38 // Check that all callbacks will be invoked.
39 uiSourceCode
.requestContent(didRequestContent
.bind(null, 1));
40 uiSourceCode
.requestContent(didRequestContent
.bind(null, 2));
41 uiSourceCode
.requestContent(didRequestContent
.bind(null, 3));
50 <body onload=
"runTest()">
51 <p>Tests UISourceCode class.
</p>