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.

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

mercurial