| <html> |
| <head> |
| <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| <script src="../../../http/tests/inspector/console-test.js"></script> |
| <script> |
| |
| function jumpToMe() |
| { |
| var result = 12345; |
| return window.foo || result; |
| } |
| |
| function test() |
| { |
| var panel = UI.panels.sources; |
| |
| InspectorTest.runTestSuite([ |
| function testRevealFunctionDefinition(next) |
| { |
| InspectorTest.addSniffer(panel, "showUISourceCode", showUISourceCodeHook); |
| UI.context.flavor(SDK.ExecutionContext).evaluate({expression: "jumpToMe", silent:true}).then(didGetFunction); |
| |
| function didGetFunction(result) |
| { |
| var error = !result.object || !!result.exceptionDetails; |
| InspectorTest.assertTrue(!error); |
| panel._showFunctionDefinition(result.object); |
| } |
| |
| function showUISourceCodeHook(uiSourceCode, lineNumber, columnNumber, forceShowInPanel) |
| { |
| // lineNumber and columnNumber are 0-based |
| ++lineNumber; |
| ++columnNumber; |
| InspectorTest.addResult("Function location revealed: [" + lineNumber + ":" + columnNumber + "]"); |
| next(); |
| } |
| }, |
| |
| function testDumpFunctionDefinition(next) |
| { |
| InspectorTest.addSniffer(ObjectUI.ObjectPropertiesSection, "formatObjectAsFunction", onConsoleMessagesReceived); |
| var consoleView = Console.ConsoleView.instance(); |
| consoleView._prompt._appendCommand("jumpToMe", true); |
| |
| function onConsoleMessagesReceived() |
| { |
| InspectorTest.deprecatedRunAfterPendingDispatches(function() { |
| var messages = []; |
| InspectorTest.disableConsoleViewport(); |
| var viewMessages = Console.ConsoleView.instance()._visibleViewMessages; |
| for (var i = 0; i < viewMessages.length; ++i) { |
| var uiMessage = viewMessages[i]; |
| var element = uiMessage.contentElement(); |
| messages.push(element.deepTextContent()); |
| } |
| InspectorTest.addResult(messages.join("\n")); |
| next(); |
| }); |
| } |
| } |
| ]); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| Tests that "Show Function Definition" jumps to the correct location. |
| </p> |
| |
| </body> |
| </html> |