browser/devtools/webconsole/test/browser_output_longstring_expand.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/webconsole/test/browser_output_longstring_expand.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +// Test that long strings can be expanded in the console output.
     1.9 +
    1.10 +function test()
    1.11 +{
    1.12 +  waitForExplicitFinish();
    1.13 +
    1.14 +  let tempScope = {};
    1.15 +  Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope);
    1.16 +  let DebuggerServer = tempScope.DebuggerServer;
    1.17 +
    1.18 +  let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a") +
    1.19 +                   "foobar";
    1.20 +  let initialString =
    1.21 +    longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
    1.22 +
    1.23 +  addTab("data:text/html;charset=utf8,test for bug 787981 - check that long strings can be expanded in the output.");
    1.24 +
    1.25 +  let hud = null;
    1.26 +
    1.27 +  gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
    1.28 +    gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
    1.29 +    openConsole(null, performTest);
    1.30 +  }, true);
    1.31 +
    1.32 +  function performTest(aHud)
    1.33 +  {
    1.34 +    hud = aHud;
    1.35 +    hud.jsterm.clearOutput(true);
    1.36 +    hud.jsterm.execute("console.log('bazbaz', '" + longString +"', 'boom')");
    1.37 +
    1.38 +    waitForMessages({
    1.39 +      webconsole: hud,
    1.40 +      messages: [{
    1.41 +        name: "console.log output",
    1.42 +        text: ["bazbaz", "boom", initialString],
    1.43 +        noText: "foobar",
    1.44 +        longString: true,
    1.45 +      }],
    1.46 +    }).then(onConsoleMessage);
    1.47 +  }
    1.48 +
    1.49 +  function onConsoleMessage([result])
    1.50 +  {
    1.51 +    let clickable = result.longStrings[0];
    1.52 +    ok(clickable, "long string ellipsis is shown");
    1.53 +
    1.54 +    clickable.scrollIntoView(false);
    1.55 +
    1.56 +    EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
    1.57 +
    1.58 +    waitForMessages({
    1.59 +      webconsole: hud,
    1.60 +      messages: [{
    1.61 +        name: "full string",
    1.62 +        text: ["bazbaz", "boom", longString],
    1.63 +        category: CATEGORY_WEBDEV,
    1.64 +        longString: false,
    1.65 +      }],
    1.66 +    }).then(() => {
    1.67 +      hud.jsterm.clearOutput(true);
    1.68 +      hud.jsterm.execute("'" + longString +"'", onExecute);
    1.69 +    });
    1.70 +  }
    1.71 +
    1.72 +  function onExecute(msg)
    1.73 +  {
    1.74 +    isnot(msg.textContent.indexOf(initialString), -1,
    1.75 +        "initial string is shown");
    1.76 +    is(msg.textContent.indexOf(longString), -1,
    1.77 +        "full string is not shown");
    1.78 +
    1.79 +    let clickable = msg.querySelector(".longStringEllipsis");
    1.80 +    ok(clickable, "long string ellipsis is shown");
    1.81 +
    1.82 +    clickable.scrollIntoView(false);
    1.83 +
    1.84 +    EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow);
    1.85 +
    1.86 +    waitForMessages({
    1.87 +      webconsole: hud,
    1.88 +      messages: [{
    1.89 +        name: "full string",
    1.90 +        text: longString,
    1.91 +        category: CATEGORY_OUTPUT,
    1.92 +        longString: false,
    1.93 +      }],
    1.94 +    }).then(finishTest);
    1.95 +  }
    1.96 +}

mercurial