Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / ui-source-code.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4
5 <script>
6
7 function test()
8 {
9     var MockProject = function() {}
10     MockProject.prototype.requestFileContent = function(uri, callback)
11     {
12         InspectorTest.addResult("Content is requested from SourceCodeProvider.");
13         setTimeout(callback.bind(null, "var x = 0;"), 0);
14     }
15     MockProject.prototype.isServiceProject = function() { return false; };
16     MockProject.prototype.type = function() { return WebInspector.projectTypes.Debugger; }
17
18     InspectorTest.runTestSuite([
19         function testUISourceCode(next)
20         {
21             var uiSourceCode = new WebInspector.UISourceCode(new MockProject(), "parentPath", "name", "originURL", "url", WebInspector.resourceTypes.Script);
22             function didRequestContent(callNumber, content)
23             {
24                 InspectorTest.addResult("Callback " + callNumber + " is invoked.");
25                 InspectorTest.assertEquals("text/javascript", uiSourceCode.highlighterType());
26                 InspectorTest.assertEquals("var x = 0;", content);
27
28                 if (callNumber === 3) {
29                     // Check that sourceCodeProvider.requestContent won't be called anymore.
30                     uiSourceCode.requestContent(function(content)
31                     {
32                         InspectorTest.assertEquals("text/javascript", uiSourceCode.highlighterType());
33                         InspectorTest.assertEquals("var x = 0;", content);
34                         next();
35                     });
36                 }
37             }
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));
42         }
43     ]);
44 };
45
46 </script>
47
48 </head>
49
50 <body onload="runTest()">
51 <p>Tests UISourceCode class.</p>
52 </body>
53 </html>