Bug 1307925 - Localize and explicitely test Navigation message; r=Honza.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 05 Mar 2018 10:15:24 +0100
changeset 461566 8b4c82584d6b33a563abd453c743fff5f5a5b191
parent 461565 55b683e679b0056b216b25a6274bbdc1f90e5a28
child 461567 874144c920a083165e041ef9dd2045286dfd96ae
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1307925
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1307925 - Localize and explicitely test Navigation message; r=Honza. The message is now localized, with the URL as a parameter. browser_webconsole_persist was modified to explicitely wait for the Navigation message to be logged. MozReview-Commit-ID: L0hsrkYsl16
devtools/client/locales/en-US/webconsole.properties
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_persist.js
devtools/client/webconsole/new-console-output/utils/messages.js
--- a/devtools/client/locales/en-US/webconsole.properties
+++ b/devtools/client/locales/en-US/webconsole.properties
@@ -322,8 +322,13 @@ webconsole.filteredMessages.label=#1 ite
 # Label used as the text of the "Reset filters" button in the "filtered messages" bar.
 # It resets the default filters of the console to their original values.
 webconsole.resetFiltersButton.label=Reset filters
 
 # LOCALIZATION NOTE (webconsole.enablePersistentLogs.label)
 webconsole.enablePersistentLogs.label=Persist Logs
 # LOCALIZATION NOTE (webconsole.enablePersistentLogs.tooltip)
 webconsole.enablePersistentLogs.tooltip=If you enable this option the output will not be cleared each time you navigate to a new page
+
+# LOCALIZATION NOTE (webconsole.navigated): this string is used in the console when the
+# current inspected page is navigated to a new location.
+# Parameters: %S is the new URL.
+webconsole.navigated=Navigated to %S
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_persist.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_persist.js
@@ -15,20 +15,21 @@ const TEST_URI = "http://example.com/bro
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("devtools.webconsole.persistlog");
 });
 
 add_task(async function () {
   info("Testing that messages disappear on a refresh if logs aren't persisted");
   let hud = await openNewTabAndConsole(TEST_URI);
 
-  await ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
-    content.wrappedJSObject.doLogs(5);
+  const INITIAL_LOGS_NUMBER = 5;
+  await ContentTask.spawn(gBrowser.selectedBrowser, INITIAL_LOGS_NUMBER, (count) => {
+    content.wrappedJSObject.doLogs(count);
   });
-  await waitFor(() => findMessages(hud, "").length === 5);
+  await waitFor(() => findMessages(hud, "").length === INITIAL_LOGS_NUMBER);
   ok(true, "Messages showed up initially");
 
   await refreshTab();
   await waitFor(() => findMessages(hud, "").length === 0);
   ok(true, "Messages disappeared");
 
   await closeToolbox();
 });
@@ -36,19 +37,23 @@ add_task(async function () {
 add_task(async function () {
   info("Testing that messages persist on a refresh if logs are persisted");
 
   let hud = await openNewTabAndConsole(TEST_URI);
 
   hud.ui.outputNode.querySelector(".webconsole-filterbar-primary .filter-checkbox")
     .click();
 
-  await ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
-    content.wrappedJSObject.doLogs(5);
+  const INITIAL_LOGS_NUMBER = 5;
+  await ContentTask.spawn(gBrowser.selectedBrowser, INITIAL_LOGS_NUMBER, (count) => {
+    content.wrappedJSObject.doLogs(count);
   });
-  await waitFor(() => findMessages(hud, "").length === 5);
+  await waitFor(() => findMessages(hud, "").length === INITIAL_LOGS_NUMBER);
   ok(true, "Messages showed up initially");
 
-  await refreshTab();
-  await waitFor(() => findMessages(hud, "").length === 6);
+  const onNavigatedMessage = waitForMessage(hud, "Navigated to");
+  refreshTab();
+  await onNavigatedMessage;
 
-  ok(findMessage(hud, "Navigated"), "Navigated message appeared");
+  ok(true, "Navigation message appeared as expected");
+  is(findMessages(hud, "").length, INITIAL_LOGS_NUMBER + 1,
+    "Messages logged before navigation are still visible");
 });
--- a/devtools/client/webconsole/new-console-output/utils/messages.js
+++ b/devtools/client/webconsole/new-console-output/utils/messages.js
@@ -171,17 +171,17 @@ function transformConsoleAPICallPacket(p
 }
 
 function transformNavigationMessagePacket(packet) {
   let { message } = packet;
   return new ConsoleMessage({
     source: MESSAGE_SOURCE.CONSOLE_API,
     type: MESSAGE_TYPE.LOG,
     level: MESSAGE_LEVEL.LOG,
-    messageText: "Navigated to " + message.url,
+    messageText: l10n.getFormatStr("webconsole.navigated", [message.url]),
     timeStamp: message.timeStamp
   });
 }
 
 function transformLogMessagePacket(packet) {
   let {
     message,
     timeStamp,