browser/devtools/webconsole/test/browser_output_longstring_expand.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 2 /* Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 4
michael@0 5 // Test that long strings can be expanded in the console output.
michael@0 6
michael@0 7 function test()
michael@0 8 {
michael@0 9 waitForExplicitFinish();
michael@0 10
michael@0 11 let tempScope = {};
michael@0 12 Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope);
michael@0 13 let DebuggerServer = tempScope.DebuggerServer;
michael@0 14
michael@0 15 let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a") +
michael@0 16 "foobar";
michael@0 17 let initialString =
michael@0 18 longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
michael@0 19
michael@0 20 addTab("data:text/html;charset=utf8,test for bug 787981 - check that long strings can be expanded in the output.");
michael@0 21
michael@0 22 let hud = null;
michael@0 23
michael@0 24 gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
michael@0 25 gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
michael@0 26 openConsole(null, performTest);
michael@0 27 }, true);
michael@0 28
michael@0 29 function performTest(aHud)
michael@0 30 {
michael@0 31 hud = aHud;
michael@0 32 hud.jsterm.clearOutput(true);
michael@0 33 hud.jsterm.execute("console.log('bazbaz', '" + longString +"', 'boom')");
michael@0 34
michael@0 35 waitForMessages({
michael@0 36 webconsole: hud,
michael@0 37 messages: [{
michael@0 38 name: "console.log output",
michael@0 39 text: ["bazbaz", "boom", initialString],
michael@0 40 noText: "foobar",
michael@0 41 longString: true,
michael@0 42 }],
michael@0 43 }).then(onConsoleMessage);
michael@0 44 }
michael@0 45
michael@0 46 function onConsoleMessage([result])
michael@0 47 {
michael@0 48 let clickable = result.longStrings[0];
michael@0 49 ok(clickable, "long string ellipsis is shown");
michael@0 50
michael@0 51 clickable.scrollIntoView(false);
michael@0 52
michael@0 53 EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
michael@0 54
michael@0 55 waitForMessages({
michael@0 56 webconsole: hud,
michael@0 57 messages: [{
michael@0 58 name: "full string",
michael@0 59 text: ["bazbaz", "boom", longString],
michael@0 60 category: CATEGORY_WEBDEV,
michael@0 61 longString: false,
michael@0 62 }],
michael@0 63 }).then(() => {
michael@0 64 hud.jsterm.clearOutput(true);
michael@0 65 hud.jsterm.execute("'" + longString +"'", onExecute);
michael@0 66 });
michael@0 67 }
michael@0 68
michael@0 69 function onExecute(msg)
michael@0 70 {
michael@0 71 isnot(msg.textContent.indexOf(initialString), -1,
michael@0 72 "initial string is shown");
michael@0 73 is(msg.textContent.indexOf(longString), -1,
michael@0 74 "full string is not shown");
michael@0 75
michael@0 76 let clickable = msg.querySelector(".longStringEllipsis");
michael@0 77 ok(clickable, "long string ellipsis is shown");
michael@0 78
michael@0 79 clickable.scrollIntoView(false);
michael@0 80
michael@0 81 EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow);
michael@0 82
michael@0 83 waitForMessages({
michael@0 84 webconsole: hud,
michael@0 85 messages: [{
michael@0 86 name: "full string",
michael@0 87 text: longString,
michael@0 88 category: CATEGORY_OUTPUT,
michael@0 89 longString: false,
michael@0 90 }],
michael@0 91 }).then(finishTest);
michael@0 92 }
michael@0 93 }

mercurial