b19f0ff9dbfe0fbd922db50cd1db158e81c29d7a
[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
17     InspectorTest.runTestSuite([
18         function testUISourceCode(next)
19         {
20             var uiSourceCode = new WebInspector.UISourceCode(new MockProject(), "parentPath", "name", "originURL", "url", WebInspector.resourceTypes.Script);
21             function didRequestContent(callNumber, content)
22             {
23                 InspectorTest.addResult("Callback " + callNumber + " is invoked.");
24                 InspectorTest.assertEquals("text/javascript", uiSourceCode.highlighterType());
25                 InspectorTest.assertEquals("var x = 0;", content);
26
27                 if (callNumber === 3) {
28                     // Check that sourceCodeProvider.requestContent won't be called anymore.
29                     uiSourceCode.requestContent(function(content)
30                     {
31                         InspectorTest.assertEquals("text/javascript", uiSourceCode.highlighterType());
32                         InspectorTest.assertEquals("var x = 0;", content);
33                         next();
34                     });
35                 }
36             }
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));
41         }
42     ]);
43 };
44
45 </script>
46
47 </head>
48
49 <body onload="runTest()">
50 <p>Tests UISourceCode class.</p>
51 </body>
52 </html>