Bug 1505132 - Add test for backward compatibility warnings in about:debugging;r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 18 Feb 2019 09:12:39 +0000
changeset 459758 933c04b2755f1203ba842e34b84274d2c90d49f5
parent 459757 4274148772f96f5450f998247dec7d9e14ffe67e
child 459759 903ca27a7aed2b613d1815566b981ef0a3575f08
push id35572
push usercbrindusan@mozilla.com
push dateMon, 18 Feb 2019 21:43:34 +0000
treeherdermozilla-central@c590fd06f7cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke
bugs1505132
milestone67.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 1505132 - Add test for backward compatibility warnings in about:debugging;r=daisuke Depends on D18985 Differential Revision: https://phabricator.services.mozilla.com/D18987
devtools/client/aboutdebugging-new/src/components/CompatibilityWarning.js
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_runtime_compatibility_warning.js
--- a/devtools/client/aboutdebugging-new/src/components/CompatibilityWarning.js
+++ b/devtools/client/aboutdebugging-new/src/components/CompatibilityWarning.js
@@ -29,20 +29,25 @@ class CompatibilityWarning extends PureC
   render() {
     const { localID, localVersion, minVersion, runtimeID, runtimeVersion, status } =
       this.props.compatibilityReport;
 
     if (status === COMPATIBILITY_STATUS.COMPATIBLE) {
       return null;
     }
 
-    const localizationId = status === COMPATIBILITY_STATUS.TOO_OLD ?
+    const isTooOld = status === COMPATIBILITY_STATUS.TOO_OLD;
+    const localizationId = isTooOld ?
       "about-debugging-runtime-version-too-old" :
       "about-debugging-runtime-version-too-recent";
 
+    const statusClassName = isTooOld ?
+      "js-compatibility-warning-too-old" :
+      "js-compatibility-warning-too-recent";
+
     return Message(
       {
         level: MESSAGE_LEVEL.WARNING,
       },
       Localized(
         {
           id: localizationId,
           a: dom.a({
@@ -51,17 +56,19 @@ class CompatibilityWarning extends PureC
           }),
           $localID: localID,
           $localVersion: localVersion,
           $minVersion: minVersion,
           $runtimeID: runtimeID,
           $runtimeVersion: runtimeVersion,
         },
         dom.p(
-          {},
+          {
+            className: `js-compatibility-warning ${statusClassName}`,
+          },
           localizationId,
         ),
       )
     );
   }
 }
 
 module.exports = CompatibilityWarning;
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -56,16 +56,17 @@ skip-if = (os == 'linux' && bits == 32) 
 [browser_aboutdebugging_devtoolstoolbox_reload.js]
 [browser_aboutdebugging_devtoolstoolbox_shortcuts.js]
 skip-if = (os == "win" && ccov) # Bug 1521349
 [browser_aboutdebugging_devtoolstoolbox_tooltip_markupview.js]
 [browser_aboutdebugging_navigate.js]
 [browser_aboutdebugging_persist_connection.js]
 [browser_aboutdebugging_profiler_dialog.js]
 [browser_aboutdebugging_routes.js]
+[browser_aboutdebugging_runtime_compatibility_warning.js]
 [browser_aboutdebugging_runtime_remote_runtime_buttons.js]
 [browser_aboutdebugging_runtime_usbclient_closed.js]
 [browser_aboutdebugging_select_network_runtime.js]
 [browser_aboutdebugging_select_page_with_serviceworker.js]
 [browser_aboutdebugging_serviceworker_fetch_flag.js]
 [browser_aboutdebugging_serviceworker_multie10s.js]
 [browser_aboutdebugging_serviceworker_not_compatible.js]
 [browser_aboutdebugging_serviceworker_push.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_runtime_compatibility_warning.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const COMPATIBLE_RUNTIME = "Compatible Runtime";
+const COMPATIBLE_DEVICE = "Compatible Device";
+const OLD_RUNTIME = "Old Runtime";
+const OLD_DEVICE = "Old Device";
+const RECENT_RUNTIME = "Recent Runtime";
+const RECENT_DEVICE = "Recent Device";
+
+add_task(async function() {
+  const { COMPATIBILITY_STATUS } =
+        require("devtools/client/shared/remote-debugging/version-checker");
+  const { COMPATIBLE, TOO_OLD, TOO_RECENT } = COMPATIBILITY_STATUS;
+
+  info("Create three mocked runtimes, with different compatibility reports");
+  const mocks = new Mocks();
+  createRuntimeWithReport(mocks, COMPATIBLE_RUNTIME, COMPATIBLE_DEVICE, COMPATIBLE);
+  createRuntimeWithReport(mocks, OLD_RUNTIME, OLD_DEVICE, TOO_OLD);
+  createRuntimeWithReport(mocks, RECENT_RUNTIME, RECENT_DEVICE, TOO_RECENT);
+
+  const { document, tab } = await openAboutDebugging();
+  mocks.emitUSBUpdate();
+
+  info("Connect to all runtimes");
+  await connectToRuntime(COMPATIBLE_DEVICE, document);
+  await connectToRuntime(OLD_DEVICE, document);
+  await connectToRuntime(RECENT_DEVICE, document);
+
+  info("Select the compatible runtime and check that no warning is displayed");
+  await selectRuntime(COMPATIBLE_DEVICE, COMPATIBLE_RUNTIME, document);
+  ok(!document.querySelector(".js-compatibility-warning"),
+    "Compatibility warning is not displayed");
+
+  info("Select the old runtime and check that the too-old warning is displayed");
+  await selectRuntime(OLD_DEVICE, OLD_RUNTIME, document);
+  ok(document.querySelector(".js-compatibility-warning-too-old"),
+    "Expected compatibility warning is displayed (too-old)");
+
+  info("Select the recent runtime and check that the too-recent warning is displayed");
+  await selectRuntime(RECENT_DEVICE, RECENT_RUNTIME, document);
+  ok(document.querySelector(".js-compatibility-warning-too-recent"),
+    "Expected compatibility warning is displayed (too-recent)");
+
+  await removeTab(tab);
+});
+
+function createRuntimeWithReport(mocks, name, deviceName, status) {
+  const runtimeId = [name, deviceName].join("-");
+  const compatibleUsbClient = mocks.createUSBRuntime(runtimeId, { deviceName, name });
+  const report = { status };
+  compatibleUsbClient.checkVersionCompatibility = () => report;
+}