Bug 1389251 - Fix browser_webconsole_context_menu_copy_entire_message.js so findMessage doesn't match on the wrong thing r=jdescottes
See
Bug 1389251 comment 29 for full explanation of why we do this.
Also replaces ok(lines.length, value) with is(lines.length, value)
MozReview-Commit-ID: D4C3Aum9sfQ
--- a/browser/base/content/test/pageinfo/browser_pageinfo_image_info.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_image_info.js
@@ -17,19 +17,18 @@ const URI =
"<img src='about:logo?b' height=200 width=250 alt=1>" +
"<img src='about:logo?b' height=100 width=150 alt=2 id='test-image'>";
function test() {
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- let uriToWaitFor = URI.replace(/ /g, "%20");
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false,
- uriToWaitFor).then(function() {
+ URI).then(function() {
var doc = gBrowser.contentDocumentAsCPOW;
var testImg = doc.getElementById("test-image");
var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
"mediaTab", getImageInfo(testImg));
pageInfo.addEventListener("load", function() {
pageInfo.onFinished.push(function() {
var pageInfoImg = pageInfo.document.getElementById("thepreviewimage");
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_context_menu_copy_entire_message.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_context_menu_copy_entire_message.js
@@ -12,17 +12,17 @@ const LOG_FORMAT_WITH_TIMESTAMP = /^[\d:
const LOG_FORMAT_WITHOUT_TIMESTAMP = /^.+ (\d+ )?.+:\d+$/;
// RegExp that validates copied text for stacktrace lines.
const TRACE_FORMAT = /^\t.+ .+:\d+:\d+$/;
const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
const TEST_URI = `data:text/html;charset=utf-8,<script>
window.logStuff = function () {
- console.log("simple text message");
+ console.log("simple " + "text message");
function wrapper() {
console.trace();
}
wrapper();
};
</script>`;
// Test the Copy menu item of the webconsole copies the expected clipboard text for
@@ -44,29 +44,29 @@ add_task(async function() {
info("Test copy menu item for the simple log");
let message = await waitFor(() => findMessage(hud, "simple text message"));
let clipboardText = await copyMessageContent(hud, message);
ok(true, "Clipboard text was found and saved");
info("Check copied text for simple log message");
let lines = clipboardText.split("\n");
- ok(lines.length, 2, "There are 2 lines in the copied text");
+ is(lines.length, 2, "There are 2 lines in the copied text");
is(lines[1], "", "The last line is an empty new line");
ok(LOG_FORMAT_WITH_TIMESTAMP.test(lines[0]),
"Log line has the right format:\n" + lines[0]);
info("Test copy menu item for the stack trace message");
message = await waitFor(() => findMessage(hud, "console.trace"));
clipboardText = await copyMessageContent(hud, message);
ok(true, "Clipboard text was found and saved");
info("Check copied text for stack trace message");
lines = clipboardText.split("\n");
- ok(lines.length, 4, "There are 4 lines in the copied text");
+ is(lines.length, 4, "There are 4 lines in the copied text");
is(lines[3], "", "The last line is an empty new line");
ok(LOG_FORMAT_WITH_TIMESTAMP.test(lines[0]),
"Log line has the right format:\n" + lines[0]);
ok(TRACE_FORMAT.test(lines[1]), "Stacktrace line has the right format:\n" + lines[1]);
ok(TRACE_FORMAT.test(lines[2]), "Stacktrace line has the right format:\n" + lines[2]);
info("Test copy menu item without timestamp");
@@ -76,29 +76,29 @@ add_task(async function() {
info("Test copy menu item for the simple log");
message = await waitFor(() => findMessage(hud, "simple text message"));
clipboardText = await copyMessageContent(hud, message);
ok(true, "Clipboard text was found and saved");
info("Check copied text for simple log message");
lines = clipboardText.split("\n");
- ok(lines.length, 2, "There are 2 lines in the copied text");
+ is(lines.length, 2, "There are 2 lines in the copied text");
is(lines[1], "", "The last line is an empty new line");
ok(LOG_FORMAT_WITHOUT_TIMESTAMP.test(lines[0]),
"Log line has the right format:\n" + lines[0]);
info("Test copy menu item for the stack trace message");
message = await waitFor(() => findMessage(hud, "console.trace"));
clipboardText = await copyMessageContent(hud, message);
ok(true, "Clipboard text was found and saved");
info("Check copied text for stack trace message");
lines = clipboardText.split("\n");
- ok(lines.length, 4, "There are 4 lines in the copied text");
+ is(lines.length, 4, "There are 4 lines in the copied text");
is(lines[3], "", "The last line is an empty new line");
ok(LOG_FORMAT_WITHOUT_TIMESTAMP.test(lines[0]),
"Log line has the right format:\n" + lines[0]);
ok(TRACE_FORMAT.test(lines[1]), "Stacktrace line has the right format:\n" + lines[1]);
ok(TRACE_FORMAT.test(lines[2]), "Stacktrace line has the right format:\n" + lines[2]);
observer.destroy();
Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP);