Bug 1454202: Part 2c - Manually fix issues in auto-rewrite. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Sat, 14 Apr 2018 23:36:48 -0700
changeset 782300 72d6733880fcab31bd75bdc1010fe95ffd793e10
parent 782299 e05fe21d83a151eb760011a0e946100aa06cf126
child 782301 3cc9f25284f08760026714c68ea726cc499c730c
child 782302 a1a4192def4aeaecf35f56db4ad2c964810e6536
child 782442 823dcf8466a773161add1c3a1eb28aab110ce578
push id106511
push usermaglione.k@gmail.com
push dateSun, 15 Apr 2018 06:46:19 +0000
reviewersaswan
bugs1454202
milestone61.0a1
Bug 1454202: Part 2c - Manually fix issues in auto-rewrite. r?aswan MozReview-Commit-ID: LfSiRnz2xkF
toolkit/mozapps/extensions/test/browser/browser_discovery.js
toolkit/mozapps/extensions/test/browser/browser_manualupdates.js
toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
--- a/toolkit/mozapps/extensions/test/browser/browser_discovery.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_discovery.js
@@ -186,28 +186,26 @@ add_test(async function() {
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
 
   await gCategoryUtilities.openType("discover");
   var browser = gManagerWindow.document.getElementById("discover-browser");
   is(getURL(browser), MAIN_URL, "Should have loaded the right url");
 
   await testHash(browser, [true, true, true]);
   close_manager(gManagerWindow, run_next_test);
-
-  ok(isLoading(), "Should be loading at first");
 });
 
 // Tests that loading the add-ons manager with the discovery view as the last
 // selected view displays the right url
 add_test(async function() {
   // Hide one of the test add-ons
   Services.prefs.setBoolPref("extensions.addon2@tests.mozilla.org.getAddons.cache.enabled", false);
   Services.prefs.setBoolPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled", true);
 
-  let aWindow = await open_manager(null, null, function(aWindow) {
+  await open_manager(null, null, function(aWindow) {
     gManagerWindow = aWindow;
     ok(isLoading(), "Should be loading at first");
   });
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
   is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
 
   var browser = gManagerWindow.document.getElementById("discover-browser");
   is(getURL(browser), MAIN_URL, "Should have loaded the right url");
@@ -305,17 +303,16 @@ add_test(async function() {
   clickLink("link-http", async function() {
     ok(isError(), "Should have shown the error page");
 
     await gCategoryUtilities.openType("extension");
     await gCategoryUtilities.openType("discover");
     is(getURL(browser), MAIN_URL, "Should have loaded the right url");
 
     close_manager(gManagerWindow, run_next_test);
-    ok(isLoading(), "Should start loading again");
   });
 });
 
 // Tests that navigating to a different domain fails
 add_test(async function() {
   let aWindow = await open_manager("addons://discover/");
   gManagerWindow = aWindow;
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
@@ -326,17 +323,16 @@ add_test(async function() {
   clickLink("link-domain", async function() {
     ok(isError(), "Should have shown the error page");
 
     await gCategoryUtilities.openType("extension");
     await gCategoryUtilities.openType("discover");
     is(getURL(browser), MAIN_URL, "Should have loaded the right url");
 
     close_manager(gManagerWindow, run_next_test);
-    ok(isLoading(), "Should start loading again");
   });
 });
 
 // Tests that navigating to a missing page fails
 add_test(async function() {
   let aWindow = await open_manager("addons://discover/");
   gManagerWindow = aWindow;
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
@@ -347,17 +343,16 @@ add_test(async function() {
   clickLink("link-bad", async function() {
     ok(isError(), "Should have shown the error page");
 
     await gCategoryUtilities.openType("extension");
     await gCategoryUtilities.openType("discover");
     is(getURL(browser), MAIN_URL, "Should have loaded the right url");
 
     close_manager(gManagerWindow, run_next_test);
-    ok(isLoading(), "Should start loading again");
   });
 });
 
 // Tests that navigating to a page on the same domain works
 add_test(async function() {
   let aWindow = await open_manager("addons://discover/");
   gManagerWindow = aWindow;
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
@@ -400,17 +395,16 @@ add_test(async function() {
     clickLink("link-domain", async function() {
       ok(isError(), "Should have shown the error page");
 
       await gCategoryUtilities.openType("extension");
       await gCategoryUtilities.openType("discover");
       is(getURL(browser), MAIN_URL, "Should have loaded the right url");
 
       close_manager(gManagerWindow, run_next_test);
-      ok(isLoading(), "Should start loading again");
     });
   });
 });
 
 // Loading an insecure main page should work if that is what the prefs say, should
 // also be able to navigate to a https page and back again
 add_test(async function() {
   Services.prefs.setCharPref(PREF_DISCOVERURL, TESTROOT + "discovery.html");
@@ -441,38 +435,40 @@ add_test(async function() {
   let aWindow = await open_manager("addons://list/extension");
   gManagerWindow = aWindow;
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
 
   var browser = gManagerWindow.document.getElementById("discover-browser");
 
   EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow);
 
+  Promise.resolve().then(() => {
+     ok(isLoading(), "Should be loading");
+     // This will actually stop the about:blank load
+     browser.stop();
+  });
   await wait_for_view_load(gManagerWindow);
   ok(isError(), "Should have shown the error page");
 
   await gCategoryUtilities.openType("extension");
   EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow);
 
+  Promise.resolve().then(() => {
+     ok(isLoading(), "Should be loading");
+     // This will actually stop the about:blank load
+     browser.stop();
+  });
   await wait_for_view_load(gManagerWindow);
   ok(isError(), "Should have shown the error page");
 
   await gCategoryUtilities.openType("extension");
   await gCategoryUtilities.openType("discover");
   is(getURL(browser), MAIN_URL, "Should have loaded the right url");
 
   close_manager(gManagerWindow, run_next_test);
-
-  ok(isLoading(), "Should be loading");
-  // This will stop the real page load
-  browser.stop();
-
-  ok(isLoading(), "Should be loading");
-  // This will actually stop the about:blank load
-  browser.stop();
 });
 
 // Test for Bug 703929 - Loading the discover view from a chrome XUL file fails when
 // the add-on manager is reopened.
 add_test(async function() {
   const url = "chrome://mochitests/content/" + RELATIVE_DIR + "addon_prefs.xul";
   Services.prefs.setCharPref(PREF_DISCOVERURL, url);
 
@@ -482,17 +478,17 @@ add_test(async function() {
 
   var browser = gManagerWindow.document.getElementById("discover-browser");
   is(getURL(browser), url, "Loading a chrome XUL file should work");
 
   aWindow = await restart_manager(gManagerWindow, "addons://discover/");
   gManagerWindow = aWindow;
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
 
-  var browser = gManagerWindow.document.getElementById("discover-browser");
+  browser = gManagerWindow.document.getElementById("discover-browser");
   is(getURL(browser), url, "Should be able to load the chrome XUL file a second time");
 
   close_manager(gManagerWindow, run_next_test);
 });
 
 // Bug 711693 - Send the compatibility mode when loading the Discovery pane
 add_test(async function() {
   info("Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'normal'");
--- a/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js
@@ -78,21 +78,23 @@ add_test(async function() {
   get_tooltip_info(item).then(({ version }) => {
     is(version, "1.0", "Should still show the old version in the tooltip");
     maybeRunNext();
   });
 });
 
 
 add_test(async function() {
+  Promise.resolve().then(() => {
+    EventUtils.synthesizeMouseAtCenter(gAvailableCategory, { }, gManagerWindow);
+  });
   await wait_for_view_load(gManagerWindow, null, true);
   is(gManagerWindow.document.getElementById("categories").selectedItem.value, "addons://updates/available", "Available Updates category should now be selected");
   is(gManagerWindow.gViewController.currentViewId, "addons://updates/available", "Available Updates view should be the current view");
   run_next_test();
-  EventUtils.synthesizeMouseAtCenter(gAvailableCategory, { }, gManagerWindow);
 });
 
 
 add_test(function() {
   var list = gManagerWindow.document.getElementById("updates-list");
   is(list.itemCount, 1, "Should be 1 available update listed");
   var item = list.firstChild;
   is(item.mAddon.id, "addon2@tests.mozilla.org", "Update item should be for the manually updating addon");
--- a/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
@@ -45,23 +45,25 @@ async function end_test() {
 
 add_test(function() {
   info("Checking menuitem for Recent Updates opens that pane");
   var recentCat = gManagerWindow.gCategories.get("addons://updates/recent");
   is(gCategoryUtilities.isVisible(recentCat), false, "Recent Updates category should initially be hidden");
 
   var utilsBtn = gManagerWindow.document.getElementById("header-utils-btn");
   utilsBtn.addEventListener("popupshown", async function() {
+    Promise.resolve().then(() => {
+      var menuitem = gManagerWindow.document.getElementById("utils-viewUpdates");
+      EventUtils.synthesizeMouse(menuitem, 2, 2, { }, gManagerWindow);
+    });
     await wait_for_view_load(gManagerWindow, null, true);
     is(gCategoryUtilities.isVisible(recentCat), true, "Recent Updates category should now be visible");
     is(gManagerWindow.document.getElementById("categories").selectedItem.value, "addons://updates/recent", "Recent Updates category should now be selected");
     is(gManagerWindow.gViewController.currentViewId, "addons://updates/recent", "Recent Updates view should be the current view");
     run_next_test();
-    var menuitem = gManagerWindow.document.getElementById("utils-viewUpdates");
-    EventUtils.synthesizeMouse(menuitem, 2, 2, { }, gManagerWindow);
   }, {once: true});
   EventUtils.synthesizeMouse(utilsBtn, 2, 2, { }, gManagerWindow);
 });
 
 
 add_test(function() {
   var updatesList = gManagerWindow.document.getElementById("updates-list");
   var sorters = gManagerWindow.document.getElementById("updates-sorters");
--- a/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
@@ -206,17 +206,17 @@ add_test(async function() {
   isnot(button, null, "Should have a remove button");
   ok(!button.disabled, "Button should not be disabled");
 
   EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
 
   await wait_for_view_load(gManagerWindow);
   is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
 
-  var item = get_item_in_list(ID, list);
+  item = get_item_in_list(ID, list);
   isnot(item, null, "Should have found the add-on in the list");
   is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
 
   ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
   ok(!aAddon.isActive, "Add-on should be inactive");
 
   // Force XBL to apply
   item.clientTop;
@@ -266,17 +266,17 @@ add_test(async function() {
   isnot(button, null, "Should have a remove button");
   ok(!button.disabled, "Button should not be disabled");
 
   EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
 
   await wait_for_view_load(gManagerWindow);
   is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
 
-  var item = get_item_in_list(ID, list);
+  item = get_item_in_list(ID, list);
   isnot(item, null, "Should have found the add-on in the list");
   is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
 
   ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
   ok(!aAddon.isActive, "Add-on should be inactive");
 
   // Force XBL to apply
   item.clientTop;
@@ -349,17 +349,17 @@ add_test(async function() {
 
   let [bAddon, bAddon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
   is(bAddon, null, "Add-on should no longer be installed");
   is(bAddon2, null, "Second add-on should no longer be installed");
 
   await gCategoryUtilities.openType("extension");
   is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
 
-  var item = get_item_in_list(ID, list);
+  item = get_item_in_list(ID, list);
   is(item, null, "Should not have found the add-on in the list");
   item = get_item_in_list(ID2, list);
   is(item, null, "Should not have found the second add-on in the list");
 
   run_next_test();
 });
 
 // Tests that closing the manager from the list view finalises the uninstall of
@@ -411,19 +411,19 @@ add_test(async function() {
   let [bAddon, bAddon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
   is(bAddon, null, "Add-on should no longer be installed");
   is(bAddon2, null, "Second add-on should no longer be installed");
 
   let aWindow = await open_manager(null);
   gManagerWindow = aWindow;
   gDocument = gManagerWindow.document;
   gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-  var list = gDocument.getElementById("addon-list");
+  list = gDocument.getElementById("addon-list");
 
   is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
 
-  var item = get_item_in_list(ID, list);
+  item = get_item_in_list(ID, list);
   is(item, null, "Should not have found the add-on in the list");
   item = get_item_in_list(ID2, list);
   is(item, null, "Should not have found the second add-on in the list");
 
   run_next_test();
 });