| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../../http/tests/inspector/console-test.js"></script> | 4 <script src="../../../http/tests/inspector/console-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function jumpToMe() | 7 function jumpToMe() |
| 8 { | 8 { |
| 9 var result = 12345; | 9 var result = 12345; |
| 10 return window.foo || result; | 10 return window.foo || result; |
| 11 } | 11 } |
| 12 | 12 |
| 13 function test() | 13 function test() |
| 14 { | 14 { |
| 15 var panel = WebInspector.panels.sources; | 15 var panel = UI.panels.sources; |
| 16 | 16 |
| 17 InspectorTest.runTestSuite([ | 17 InspectorTest.runTestSuite([ |
| 18 function testRevealFunctionDefinition(next) | 18 function testRevealFunctionDefinition(next) |
| 19 { | 19 { |
| 20 InspectorTest.addSniffer(panel, "showUISourceCode", showUISourceCode
Hook); | 20 InspectorTest.addSniffer(panel, "showUISourceCode", showUISourceCode
Hook); |
| 21 WebInspector.context.flavor(WebInspector.ExecutionContext).evaluate(
"jumpToMe", "", false, true, false, false, false, didGetFunction); | 21 UI.context.flavor(SDK.ExecutionContext).evaluate("jumpToMe", "", fal
se, true, false, false, false, didGetFunction); |
| 22 | 22 |
| 23 function didGetFunction(funcObject, exceptionDetails) | 23 function didGetFunction(funcObject, exceptionDetails) |
| 24 { | 24 { |
| 25 var error = !funcObject || !!exceptionDetails; | 25 var error = !funcObject || !!exceptionDetails; |
| 26 InspectorTest.assertTrue(!error); | 26 InspectorTest.assertTrue(!error); |
| 27 panel._showFunctionDefinition(funcObject); | 27 panel._showFunctionDefinition(funcObject); |
| 28 } | 28 } |
| 29 | 29 |
| 30 function showUISourceCodeHook(uiSourceCode, lineNumber, columnNumber
, forceShowInPanel) | 30 function showUISourceCodeHook(uiSourceCode, lineNumber, columnNumber
, forceShowInPanel) |
| 31 { | 31 { |
| 32 // lineNumber and columnNumber are 0-based | 32 // lineNumber and columnNumber are 0-based |
| 33 ++lineNumber; | 33 ++lineNumber; |
| 34 ++columnNumber; | 34 ++columnNumber; |
| 35 InspectorTest.addResult("Function location revealed: [" + lineNu
mber + ":" + columnNumber + "]"); | 35 InspectorTest.addResult("Function location revealed: [" + lineNu
mber + ":" + columnNumber + "]"); |
| 36 next(); | 36 next(); |
| 37 } | 37 } |
| 38 }, | 38 }, |
| 39 | 39 |
| 40 function testDumpFunctionDefinition(next) | 40 function testDumpFunctionDefinition(next) |
| 41 { | 41 { |
| 42 InspectorTest.addSniffer(WebInspector.ObjectPropertiesSection, "form
atObjectAsFunction", onConsoleMessagesReceived); | 42 InspectorTest.addSniffer(Components.ObjectPropertiesSection, "format
ObjectAsFunction", onConsoleMessagesReceived); |
| 43 WebInspector.ConsoleModel.evaluateCommandInConsole(WebInspector.cont
ext.flavor(WebInspector.ExecutionContext), "jumpToMe"); | 43 SDK.ConsoleModel.evaluateCommandInConsole(UI.context.flavor(SDK.Exec
utionContext), "jumpToMe"); |
| 44 | 44 |
| 45 function onConsoleMessagesReceived() | 45 function onConsoleMessagesReceived() |
| 46 { | 46 { |
| 47 InspectorTest.deprecatedRunAfterPendingDispatches(function() { | 47 InspectorTest.deprecatedRunAfterPendingDispatches(function() { |
| 48 var messages = []; | 48 var messages = []; |
| 49 InspectorTest.disableConsoleViewport(); | 49 InspectorTest.disableConsoleViewport(); |
| 50 var viewMessages = WebInspector.ConsoleView.instance()._visi
bleViewMessages; | 50 var viewMessages = Console.ConsoleView.instance()._visibleVi
ewMessages; |
| 51 for (var i = 0; i < viewMessages.length; ++i) { | 51 for (var i = 0; i < viewMessages.length; ++i) { |
| 52 var uiMessage = viewMessages[i]; | 52 var uiMessage = viewMessages[i]; |
| 53 var element = uiMessage.contentElement(); | 53 var element = uiMessage.contentElement(); |
| 54 messages.push(element.deepTextContent()); | 54 messages.push(element.deepTextContent()); |
| 55 } | 55 } |
| 56 InspectorTest.addResult(messages.join("\n")); | 56 InspectorTest.addResult(messages.join("\n")); |
| 57 next(); | 57 next(); |
| 58 }); | 58 }); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 ]); | 61 ]); |
| 62 } | 62 } |
| 63 | 63 |
| 64 </script> | 64 </script> |
| 65 </head> | 65 </head> |
| 66 | 66 |
| 67 <body onload="runTest()"> | 67 <body onload="runTest()"> |
| 68 <p> | 68 <p> |
| 69 Tests that "Show Function Definition" jumps to the correct location. | 69 Tests that "Show Function Definition" jumps to the correct location. |
| 70 </p> | 70 </p> |
| 71 | 71 |
| 72 </body> | 72 </body> |
| 73 </html> | 73 </html> |
| OLD | NEW |