Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / show-function-definition.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/console-test.js"></script>
5 <script>
6
7 function jumpToMe()
8 {
9     var result = 12345;
10     return window.foo || result;
11 }
12
13 function test()
14 {
15     var panel = WebInspector.panels.sources;
16
17     InspectorTest.runTestSuite([
18         function testRevealFunctionDefinition(next)
19         {
20             InspectorTest.addSniffer(panel, "showUISourceCode", showUISourceCodeHook);
21             WebInspector.context.flavor(WebInspector.ExecutionContext).evaluate("jumpToMe", "", false, true, false, false, didGetFunction);
22
23             function didGetFunction(funcObject, wasThrown)
24             {
25                 var error = !funcObject || wasThrown;
26                 InspectorTest.assertTrue(!error);
27                 panel._showFunctionDefinition(funcObject);
28             }
29
30             function showUISourceCodeHook(uiSourceCode, lineNumber, columnNumber, forceShowInPanel)
31             {
32                 // lineNumber and columnNumber are 0-based
33                 ++lineNumber;
34                 ++columnNumber;
35                 InspectorTest.addResult("Function location revealed: [" + lineNumber + ":" + columnNumber + "]");
36                 next();
37             }
38         },
39
40         function testDumpFunctionDefinition(next)
41         {
42             InspectorTest.waitUntilNthMessageReceived(2, onConsoleMessagesReceived);
43             WebInspector.ConsoleModel.evaluateCommandInConsole(WebInspector.context.flavor(WebInspector.ExecutionContext), "jumpToMe");
44
45             function onConsoleMessagesReceived()
46             {
47                 var messages = [];
48                 InspectorTest.disableConsoleViewport();
49                 var viewMessages = WebInspector.ConsolePanel._view()._visibleViewMessages;
50                 for (var i = 0; i < viewMessages.length; ++i) {
51                     var uiMessage = viewMessages[i];
52                     var element = uiMessage.contentElement();
53                     messages.push(element.textContent);
54                 }
55
56                 InspectorTest.addResult(messages.join("\n"));
57
58                 next();
59             }
60         }
61     ]);
62 }
63
64 </script>
65 </head>
66
67 <body onload="runTest()">
68 <p>
69 Tests that "Show Function Definition" jumps to the correct location.
70 </p>
71
72 </body>
73 </html>