Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger-ui / show-function-definition.html
blobe1646c6a7296028900af26a4c511000ba3987790
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>
7 function jumpToMe()
9 var result = 12345;
10 return window.foo || result;
13 function test()
15 var panel = WebInspector.panels.sources;
17 InspectorTest.runTestSuite([
18 function testRevealFunctionDefinition(next)
20 InspectorTest.addSniffer(panel, "showUISourceCode", showUISourceCodeHook);
21 WebInspector.context.flavor(WebInspector.ExecutionContext).evaluate("jumpToMe", "", false, true, false, false, didGetFunction);
23 function didGetFunction(funcObject, wasThrown)
25 var error = !funcObject || wasThrown;
26 InspectorTest.assertTrue(!error);
27 panel._showFunctionDefinition(funcObject);
30 function showUISourceCodeHook(uiSourceCode, lineNumber, columnNumber, forceShowInPanel)
32 // lineNumber and columnNumber are 0-based
33 ++lineNumber;
34 ++columnNumber;
35 InspectorTest.addResult("Function location revealed: [" + lineNumber + ":" + columnNumber + "]");
36 next();
40 function testDumpFunctionDefinition(next)
42 InspectorTest.addSniffer(WebInspector.ObjectPropertiesSection, "formatObjectAsFunction", onConsoleMessagesReceived);
43 WebInspector.ConsoleModel.evaluateCommandInConsole(WebInspector.context.flavor(WebInspector.ExecutionContext), "jumpToMe");
45 function onConsoleMessagesReceived()
47 InspectorTest.runAfterPendingDispatches(function() {
48 var messages = [];
49 InspectorTest.disableConsoleViewport();
50 var viewMessages = WebInspector.ConsolePanel._view()._visibleViewMessages;
51 for (var i = 0; i < viewMessages.length; ++i) {
52 var uiMessage = viewMessages[i];
53 var element = uiMessage.contentElement();
54 messages.push(element.deepTextContent());
56 InspectorTest.addResult(messages.join("\n"));
57 next();
58 });
61 ]);
64 </script>
65 </head>
67 <body onload="runTest()">
68 <p>
69 Tests that "Show Function Definition" jumps to the correct location.
70 </p>
72 </body>
73 </html>