michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test that long strings can be expanded in the console output. michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: let tempScope = {}; michael@0: Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope); michael@0: let DebuggerServer = tempScope.DebuggerServer; michael@0: michael@0: let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a") + michael@0: "foobar"; michael@0: let initialString = michael@0: longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH); michael@0: michael@0: addTab("data:text/html;charset=utf8,test for bug 787981 - check that long strings can be expanded in the output."); michael@0: michael@0: let hud = null; michael@0: michael@0: gBrowser.selectedBrowser.addEventListener("load", function onLoad() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); michael@0: openConsole(null, performTest); michael@0: }, true); michael@0: michael@0: function performTest(aHud) michael@0: { michael@0: hud = aHud; michael@0: hud.jsterm.clearOutput(true); michael@0: hud.jsterm.execute("console.log('bazbaz', '" + longString +"', 'boom')"); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: name: "console.log output", michael@0: text: ["bazbaz", "boom", initialString], michael@0: noText: "foobar", michael@0: longString: true, michael@0: }], michael@0: }).then(onConsoleMessage); michael@0: } michael@0: michael@0: function onConsoleMessage([result]) michael@0: { michael@0: let clickable = result.longStrings[0]; michael@0: ok(clickable, "long string ellipsis is shown"); michael@0: michael@0: clickable.scrollIntoView(false); michael@0: michael@0: EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: name: "full string", michael@0: text: ["bazbaz", "boom", longString], michael@0: category: CATEGORY_WEBDEV, michael@0: longString: false, michael@0: }], michael@0: }).then(() => { michael@0: hud.jsterm.clearOutput(true); michael@0: hud.jsterm.execute("'" + longString +"'", onExecute); michael@0: }); michael@0: } michael@0: michael@0: function onExecute(msg) michael@0: { michael@0: isnot(msg.textContent.indexOf(initialString), -1, michael@0: "initial string is shown"); michael@0: is(msg.textContent.indexOf(longString), -1, michael@0: "full string is not shown"); michael@0: michael@0: let clickable = msg.querySelector(".longStringEllipsis"); michael@0: ok(clickable, "long string ellipsis is shown"); michael@0: michael@0: clickable.scrollIntoView(false); michael@0: michael@0: EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: name: "full string", michael@0: text: longString, michael@0: category: CATEGORY_OUTPUT, michael@0: longString: false, michael@0: }], michael@0: }).then(finishTest); michael@0: } michael@0: }