Bug 1551490 - Fix failures when browser_update_checkForUpdate run with HTML about:addons enabled. r=aswan, a=test-only
authorLuca Greco <lgreco@mozilla.com>
Tue, 28 May 2019 22:02:28 +0000
changeset 536897 607906b633a7be3e2919ceba7c4c0d8ca3c007c7
parent 536896 32caceae9cac46abf47f1f19ec5ce00a228aba99
child 536898 0cc06358290da5c2b93e6407e7eeb6d4ff49b1d6
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, test-only
bugs1551490
milestone68.0
Bug 1551490 - Fix failures when browser_update_checkForUpdate run with HTML about:addons enabled. r=aswan, a=test-only Depends on D31778 Differential Revision: https://phabricator.services.mozilla.com/D31779
browser/base/content/test/webextensions/browser_update_checkForUpdates.js
browser/base/content/test/webextensions/browser_update_findUpdates.js
browser/base/content/test/webextensions/head.js
--- a/browser/base/content/test/webextensions/browser_update_checkForUpdates.js
+++ b/browser/base/content/test/webextensions/browser_update_checkForUpdates.js
@@ -8,10 +8,34 @@ function checkAll(win) {
         resolve();
       },
     };
     Services.obs.addObserver(observer, "EM-update-check-finished");
   });
 }
 
 // Test "Check for Updates" with both auto-update settings
-add_task(() => interactiveUpdateTest(true, checkAll));
-add_task(() => interactiveUpdateTest(false, checkAll));
+async function test_check_for_updates() {
+  info("Test 'Check for Updates' with auto-update true");
+  await interactiveUpdateTest(true, checkAll);
+  info("Test 'Check for Updates' with auto-update false");
+  await interactiveUpdateTest(false, checkAll);
+}
+
+add_task(async function test_xul_aboutaddons() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.htmlaboutaddons.enabled", false]],
+  });
+
+  await test_check_for_updates();
+
+  await SpecialPowers.popPrefEnv();
+});
+
+add_task(async function test_html_aboutaddons() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.htmlaboutaddons.enabled", true]],
+  });
+
+  await test_check_for_updates();
+
+  await SpecialPowers.popPrefEnv();
+});
--- a/browser/base/content/test/webextensions/browser_update_findUpdates.js
+++ b/browser/base/content/test/webextensions/browser_update_findUpdates.js
@@ -1,8 +1,32 @@
 // Invoke an invidual extension's "Find Updates" menu item
 function checkOne(win, addon) {
   win.gViewController.doCommand("cmd_findItemUpdates", addon);
 }
 
 // Test "Find Updates" with both auto-update settings
-add_task(() => interactiveUpdateTest(true, checkOne));
-add_task(() => interactiveUpdateTest(false, checkOne));
+async function test_find_updates() {
+  info("Test 'Find Updates' with auto-update true");
+  await interactiveUpdateTest(true, checkOne);
+  info("Test 'Find Updates' with auto-update false");
+  await interactiveUpdateTest(false, checkOne);
+}
+
+add_task(async function test_xul_aboutaddons() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.htmlaboutaddons.enabled", false]],
+  });
+
+  await test_find_updates();
+
+  await SpecialPowers.popPrefEnv();
+});
+
+add_task(async function test_html_aboutaddons() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.htmlaboutaddons.enabled", true]],
+  });
+
+  await test_find_updates();
+
+  await SpecialPowers.popPrefEnv();
+});
--- a/browser/base/content/test/webextensions/head.js
+++ b/browser/base/content/test/webextensions/head.js
@@ -414,23 +414,35 @@ async function interactiveUpdateTest(aut
       });
     }
 
     let promise = checkFn(win, addon);
 
     if (manualUpdatePromise) {
       await manualUpdatePromise;
 
-      let list = win.document.getElementById("addon-list");
-
-      // Make sure we have XBL bindings
-      list.clientHeight;
-
-      let item = list.itemChildren.find(_item => _item.value == ID);
-      EventUtils.synthesizeMouseAtCenter(item._updateBtn, {}, win);
+      if (win.useHtmlViews) {
+        // about:addons is using the new HTML views.
+        const availableUpdates = win.document.getElementById("updates-manualUpdatesFound-btn");
+        availableUpdates.click();
+        let doc = win.getHtmlBrowser().contentDocument;
+        let card = await BrowserTestUtils.waitForCondition(() => {
+         return doc.querySelector(`addon-card[addon-id="${ID}"]`);
+        }, `Wait addon card for "${ID}"`);
+        let updateBtn = card.querySelector('panel-item[action="install-update"]');
+        ok(updateBtn, `Found update button for "${ID}"`);
+        updateBtn.click();
+      } else {
+        // about:addons is still using the legacy XUL views.
+        let list = win.document.getElementById("addon-list");
+        // Make sure we have XBL bindings
+        list.clientHeight;
+        let item = list.itemChildren.find(_item => _item.value == ID);
+        EventUtils.synthesizeMouseAtCenter(item._updateBtn, {}, win);
+      }
     }
 
     return {promise};
   }
 
   // Navigate away from the starting page to force about:addons to load
   // in a new tab during the tests below.
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "about:robots");