diff --git a/toolkit/components/console/hudservice/HUDService.jsm b/toolkit/components/console/hudservice/HUDService.jsm index 6f02c0b6ff9..464a448e92a 100644 --- a/toolkit/components/console/hudservice/HUDService.jsm +++ b/toolkit/components/console/hudservice/HUDService.jsm @@ -215,6 +215,9 @@ const MINIMUM_PAGE_HEIGHT = 50; // The default console height, as a ratio from the content window inner height. const DEFAULT_CONSOLE_HEIGHT = 0.33; +// Constant used when checking the typeof objects. +const TYPEOF_FUNCTION = "function"; + const ERRORS = { LOG_MESSAGE_MISSING_ARGS: "Missing arguments: aMessage, aConsoleNode and aMessageNode are required.", CANNOT_GET_HUD: "Cannot getHeads Up Display with provided ID", @@ -3682,6 +3685,11 @@ function JSTermHelper(aJSTerm) aJSTerm.console.error(HUDService.getStr("helperFuncUnsupportedTypeError")); return; } + else if (typeof aObject === TYPEOF_FUNCTION) { + aJSTerm.writeOutput(aObject + "\n", CATEGORY_OUTPUT, SEVERITY_LOG); + return; + } + let output = []; let pairs = namesAndValuesOf(unwrap(aObject)); diff --git a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_jsterm.js b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_jsterm.js index 13edf4b4af4..c71e8ab5a90 100644 --- a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_jsterm.js +++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_jsterm.js @@ -23,6 +23,7 @@ * Julian Viereck * Patrick Walton * Rob Campbell + * Mihai Șucan * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -145,5 +146,12 @@ function testJSTerm() let label = jsterm.outputNode.querySelector(".webconsole-msg-output"); is(label.textContent.trim(), '0: "h"\n 1: "i"', 'pprint("hi") worked'); + // check that pprint(function) shows function source, bug 618344 + jsterm.clearOutput(); + jsterm.execute("pprint(print)"); + label = jsterm.outputNode.querySelector(".webconsole-msg-output"); + isnot(label.textContent.indexOf("SEVERITY_LOG"), -1, + "pprint(function) shows function source"); + finishTest(); }