gecko-dev/devtools/client/webconsole/test/browser_output_longstring_expand.js
Alexandre Poirot a8c68f2955 Bug 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey
In prevision of Promise.jsm removal, use defer helper module instead of Promise.jsm
as that's the only one feature that DOM Promise don't support.

PART2: Substitutes promise.defer usages with defer
$ sed -i 's/promise.defer/defer/gI' $(egrep -lir "promise.defer\(\)" devtools)
  Reset modification to the following files as they are using deprecated syncable promises as we don't want to touch them.
  http://searchfox.org/mozilla-central/search?q=deprecated-sync-thenables&case=true&regexp=false&path=
$ git checkout devtools/client/debugger/test/mochitest/
$ git checkout devtools/shared/client/main.js
$ git checkout devtools/client/debugger/
$ git checkout devtools/server/main.js

MozReview-Commit-ID: DGN5ae68wtn

--HG--
extra : rebase_source : 57602d89b0bcc1c905bee7723e30f87fa434c6d9
2017-08-08 15:24:04 +02:00

86 lines
2.3 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that long strings can be expanded in the console output.
"use strict";
const TEST_URI = "data:text/html;charset=utf8,test for bug 787981 - check " +
"that long strings can be expanded in the output.";
add_task(function* () {
let { DebuggerServer } = require("devtools/server/main");
let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4))
.join("a") + "foobar";
let initialString =
longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
yield loadTab(TEST_URI);
let hud = yield openConsole();
hud.jsterm.clearOutput(true);
hud.jsterm.execute("console.log('bazbaz', '" + longString + "', 'boom')");
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
name: "console.log output",
text: ["bazbaz", "boom", initialString],
noText: "foobar",
longString: true,
}],
});
let clickable = result.longStrings[0];
ok(clickable, "long string ellipsis is shown");
clickable.scrollIntoView(false);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
yield waitForMessages({
webconsole: hud,
messages: [{
name: "full string",
text: ["bazbaz", "boom", longString],
category: CATEGORY_WEBDEV,
longString: false,
}],
});
hud.jsterm.clearOutput(true);
let msg = yield execute(hud, "'" + longString + "'");
isnot(msg.textContent.indexOf(initialString), -1,
"initial string is shown");
is(msg.textContent.indexOf(longString), -1,
"full string is not shown");
clickable = msg.querySelector(".longStringEllipsis");
ok(clickable, "long string ellipsis is shown");
clickable.scrollIntoView(false);
EventUtils.synthesizeMouse(clickable, 3, 4, {}, hud.iframeWindow);
yield waitForMessages({
webconsole: hud,
messages: [{
name: "full string",
text: longString,
category: CATEGORY_OUTPUT,
longString: false,
}],
});
});
function execute(hud, str) {
let deferred = defer();
hud.jsterm.execute(str, deferred.resolve);
return deferred.promise;
}