--- a/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
@@ -144,20 +144,19 @@ add_task(async function() {
condition = () => PopupNotifications.getNotification("click-to-play-plugins", pluginBrowser);
await BrowserTestUtils.waitForCondition(condition, "part11: should have a click-to-play notification");
BrowserTestUtils.removeTab(pluginTab);
// causes appDisabled to be set
managerWindow = await new Promise(resolve => {
setAndUpdateBlocklist(gHttpTestRoot + "blockPluginHard.xml",
- () => {
- close_manager(managerWindow, function() {
- open_manager("addons://list/plugin", resolve);
- });
+ async () => {
+ await close_manager(managerWindow);
+ open_manager("addons://list/plugin", resolve);
}
);
});
pluginEl = get_addon_element(managerWindow, testPluginId);
pluginEl.parentNode.ensureElementIsVisible(pluginEl);
menu = managerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "state-menulist");
is(menu.disabled, true, "part12: state menu should be disabled");
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
@@ -148,65 +148,58 @@ function double_click_addon_element(aMan
var addon = get_addon_element(aManager, aId);
addon.parentNode.ensureElementIsVisible(addon);
EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 1 }, aManager);
EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 2 }, aManager);
}
// Tests simple forward and back navigation and that the right heading and
// category is selected
-add_test(function() {
- open_manager("addons://list/extension", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/extension", false, false);
+add_test(async function() {
+ let aManager = await open_manager("addons://list/extension");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension", false, false);
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
-
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_list(aManager, "addons://list/plugin", true, false);
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
- go_back();
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_list(aManager, "addons://list/plugin", true, false);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 3");
- is_in_list(aManager, "addons://list/extension", false, true);
+ go_back();
- go_forward();
+ aManager = await wait_for_view_load(aManager);
+ info("Part 3");
+ is_in_list(aManager, "addons://list/extension", false, true);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 4");
- is_in_list(aManager, "addons://list/plugin", true, false);
-
- go_back();
+ go_forward();
- wait_for_view_load(aManager, function(aManager) {
- info("Part 5");
- is_in_list(aManager, "addons://list/extension", false, true);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 4");
+ is_in_list(aManager, "addons://list/plugin", true, false);
- double_click_addon_element(aManager, "test1@tests.mozilla.org");
+ go_back();
- wait_for_view_load(aManager, function(aManager) {
- info("Part 6");
- is_in_detail(aManager, "addons://list/extension", true, false);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 5");
+ is_in_list(aManager, "addons://list/extension", false, true);
- go_back();
+ double_click_addon_element(aManager, "test1@tests.mozilla.org");
- wait_for_view_load(aManager, function(aManager) {
- info("Part 7");
- is_in_list(aManager, "addons://list/extension", false, true);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 6");
+ is_in_detail(aManager, "addons://list/extension", true, false);
+
+ go_back();
- close_manager(aManager, run_next_test);
- });
- });
- });
- });
- });
- });
- });
+ aManager = await wait_for_view_load(aManager);
+ info("Part 7");
+ is_in_list(aManager, "addons://list/extension", false, true);
+
+ close_manager(aManager, run_next_test);
});
// Tests that browsing to the add-ons manager from a website and going back works
add_test(function() {
function promiseManagerLoaded(manager) {
return new Promise(resolve => {
wait_for_manager_load(manager, resolve);
@@ -257,129 +250,115 @@ add_test(function() {
close_manager(manager, run_next_test);
})();
});
// Tests simple forward and back navigation and that the right heading and
// category is selected -- Keyboard navigation [Bug 565359]
// Only add the test if the backspace key navigates back and addon-manager
// loaded in a tab
-add_test(function() {
+add_test(async function() {
if (Services.prefs.getIntPref("browser.backspace_action") != 0) {
run_next_test();
return;
}
- open_manager("addons://list/extension", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/extension", false, false);
-
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
+ let aManager = await open_manager("addons://list/extension");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension", false, false);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_list(aManager, "addons://list/plugin", true, false);
-
- go_back_backspace();
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 3");
- is_in_list(aManager, "addons://list/extension", false, true);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_list(aManager, "addons://list/plugin", true, false);
- go_forward_backspace();
+ go_back_backspace();
- wait_for_view_load(aManager, function(aManager) {
- info("Part 4");
- is_in_list(aManager, "addons://list/plugin", true, false);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 3");
+ is_in_list(aManager, "addons://list/extension", false, true);
- go_back_backspace();
+ go_forward_backspace();
- wait_for_view_load(aManager, function(aManager) {
- info("Part 5");
- is_in_list(aManager, "addons://list/extension", false, true);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 4");
+ is_in_list(aManager, "addons://list/plugin", true, false);
- double_click_addon_element(aManager, "test1@tests.mozilla.org");
+ go_back_backspace();
- wait_for_view_load(aManager, function(aManager) {
- info("Part 6");
- is_in_detail(aManager, "addons://list/extension", true, false);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 5");
+ is_in_list(aManager, "addons://list/extension", false, true);
- go_back_backspace();
+ double_click_addon_element(aManager, "test1@tests.mozilla.org");
- wait_for_view_load(aManager, function(aManager) {
- info("Part 7");
- is_in_list(aManager, "addons://list/extension", false, true);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 6");
+ is_in_detail(aManager, "addons://list/extension", true, false);
+
+ go_back_backspace();
- close_manager(aManager, run_next_test);
- });
- });
- });
- });
- });
- });
- });
+ aManager = await wait_for_view_load(aManager);
+ info("Part 7");
+ is_in_list(aManager, "addons://list/extension", false, true);
+
+ close_manager(aManager, run_next_test);
});
// Tests that opening a custom first view only stores a single history entry
-add_test(function() {
- open_manager("addons://list/plugin", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/plugin", false, false);
+add_test(async function() {
+ let aManager = await open_manager("addons://list/plugin");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/plugin", false, false);
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-extension"), { }, aManager);
-
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_list(aManager, "addons://list/extension", true, false);
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-extension"), { }, aManager);
- go_back();
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_list(aManager, "addons://list/extension", true, false);
+
+ go_back();
- wait_for_view_load(aManager, function(aManager) {
- info("Part 3");
- is_in_list(aManager, "addons://list/plugin", false, true);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 3");
+ is_in_list(aManager, "addons://list/plugin", false, true);
- close_manager(aManager, run_next_test);
- });
- });
- });
+ close_manager(aManager, run_next_test);
});
// Tests that opening a view while the manager is already open adds a new
// history entry
-add_test(function() {
- open_manager("addons://list/extension", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/extension", false, false);
+add_test(async function() {
+ let aManager = await open_manager("addons://list/extension");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension", false, false);
- aManager.loadView("addons://list/plugin");
+ aManager.loadView("addons://list/plugin");
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_list(aManager, "addons://list/plugin", true, false);
-
- go_back();
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_list(aManager, "addons://list/plugin", true, false);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 3");
- is_in_list(aManager, "addons://list/extension", false, true);
+ go_back();
- go_forward();
+ aManager = await wait_for_view_load(aManager);
+ info("Part 3");
+ is_in_list(aManager, "addons://list/extension", false, true);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 4");
- is_in_list(aManager, "addons://list/plugin", true, false);
+ go_forward();
- close_manager(aManager, run_next_test);
- });
- });
- });
- });
+ aManager = await wait_for_view_load(aManager);
+ info("Part 4");
+ is_in_list(aManager, "addons://list/plugin", true, false);
+
+ close_manager(aManager, run_next_test);
});
function wait_for_page_show(browser) {
let promise = new Promise(resolve => {
let removeFunc;
let listener = () => {
removeFunc();
resolve();
@@ -388,351 +367,319 @@ function wait_for_page_show(browser) {
(event) => event.target.location == "http://example.com/",
false, false);
});
return promise;
}
// Tests than navigating to a website and then going back returns to the
// previous view
-add_test(function() {
+add_test(async function() {
- open_manager("addons://list/plugin", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/plugin", false, false);
+ let aManager = await open_manager("addons://list/plugin");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/plugin", false, false);
- gBrowser.loadURI("http://example.com/");
- wait_for_page_show(gBrowser.selectedBrowser).then(() => {
- info("Part 2");
+ gBrowser.loadURI("http://example.com/");
+ wait_for_page_show(gBrowser.selectedBrowser).then(() => {
+ info("Part 2");
- executeSoon(function() {
- ok(gBrowser.canGoBack, "Should be able to go back");
- ok(!gBrowser.canGoForward, "Should not be able to go forward");
+ executeSoon(function() {
+ ok(gBrowser.canGoBack, "Should be able to go back");
+ ok(!gBrowser.canGoForward, "Should not be able to go forward");
- go_back();
+ go_back();
- gBrowser.addEventListener("pageshow", function listener(event) {
- if (event.target.location != "about:addons")
- return;
- gBrowser.removeEventListener("pageshow", listener);
+ gBrowser.addEventListener("pageshow", async function listener(event) {
+ if (event.target.location != "about:addons")
+ return;
+ gBrowser.removeEventListener("pageshow", listener);
- wait_for_view_load(gBrowser.contentWindow.wrappedJSObject, function(aManager) {
- info("Part 3");
- is_in_list(aManager, "addons://list/plugin", false, true);
+ aManager = await wait_for_view_load(gBrowser.contentWindow.wrappedJSObject);
+ info("Part 3");
+ is_in_list(aManager, "addons://list/plugin", false, true);
- executeSoon(() => go_forward());
- wait_for_page_show(gBrowser.selectedBrowser).then(() => {
- info("Part 4");
+ executeSoon(() => go_forward());
+ wait_for_page_show(gBrowser.selectedBrowser).then(() => {
+ info("Part 4");
- executeSoon(function() {
- ok(gBrowser.canGoBack, "Should be able to go back");
- ok(!gBrowser.canGoForward, "Should not be able to go forward");
+ executeSoon(function() {
+ ok(gBrowser.canGoBack, "Should be able to go back");
+ ok(!gBrowser.canGoForward, "Should not be able to go forward");
- go_back();
+ go_back();
- gBrowser.addEventListener("pageshow", function listener(event) {
- if (event.target.location != "about:addons")
- return;
- gBrowser.removeEventListener("pageshow", listener);
- wait_for_view_load(gBrowser.contentWindow.wrappedJSObject, function(aManager) {
- info("Part 5");
- is_in_list(aManager, "addons://list/plugin", false, true);
+ gBrowser.addEventListener("pageshow", async function listener(event) {
+ if (event.target.location != "about:addons")
+ return;
+ gBrowser.removeEventListener("pageshow", listener);
+ aManager = await wait_for_view_load(gBrowser.contentWindow.wrappedJSObject);
+ info("Part 5");
+ is_in_list(aManager, "addons://list/plugin", false, true);
- close_manager(aManager, run_next_test);
- });
- });
- });
+ close_manager(aManager, run_next_test);
});
});
});
});
});
});
});
// Tests that refreshing a list view does not affect the history
-add_test(function() {
+add_test(async function() {
- open_manager("addons://list/extension", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/extension", false, false);
+ let aManager = await open_manager("addons://list/extension");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension", false, false);
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_list(aManager, "addons://list/plugin", true, false);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_list(aManager, "addons://list/plugin", true, false);
- gBrowser.reload();
- gBrowser.addEventListener("pageshow", function listener(event) {
- if (event.target.location != "about:addons")
- return;
- gBrowser.removeEventListener("pageshow", listener);
-
- wait_for_view_load(gBrowser.contentWindow.wrappedJSObject, function(aManager) {
- info("Part 3");
- is_in_list(aManager, "addons://list/plugin", true, false);
+ gBrowser.reload();
+ gBrowser.addEventListener("pageshow", async function listener(event) {
+ if (event.target.location != "about:addons")
+ return;
+ gBrowser.removeEventListener("pageshow", listener);
- go_back();
- wait_for_view_load(aManager, function(aManager) {
- info("Part 4");
- is_in_list(aManager, "addons://list/extension", false, true);
+ aManager = await wait_for_view_load(gBrowser.contentWindow.wrappedJSObject);
+ info("Part 3");
+ is_in_list(aManager, "addons://list/plugin", true, false);
- close_manager(aManager, run_next_test);
- });
- });
- });
- });
+ go_back();
+ aManager = await wait_for_view_load(aManager);
+ info("Part 4");
+ is_in_list(aManager, "addons://list/extension", false, true);
+
+ close_manager(aManager, run_next_test);
});
});
// Tests that refreshing a detail view does not affect the history
-add_test(function() {
+add_test(async function() {
- open_manager(null, function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/extension", false, false);
+ let aManager = await open_manager(null);
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension", false, false);
- double_click_addon_element(aManager, "test1@tests.mozilla.org");
+ double_click_addon_element(aManager, "test1@tests.mozilla.org");
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_detail(aManager, "addons://list/extension", true, false);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_detail(aManager, "addons://list/extension", true, false);
- gBrowser.reload();
- gBrowser.addEventListener("pageshow", function listener(event) {
- if (event.target.location != "about:addons")
- return;
- gBrowser.removeEventListener("pageshow", listener);
-
- wait_for_view_load(gBrowser.contentWindow.wrappedJSObject, function(aManager) {
- info("Part 3");
- is_in_detail(aManager, "addons://list/extension", true, false);
+ gBrowser.reload();
+ gBrowser.addEventListener("pageshow", async function listener(event) {
+ if (event.target.location != "about:addons")
+ return;
+ gBrowser.removeEventListener("pageshow", listener);
- go_back();
- wait_for_view_load(aManager, function(aManager) {
- info("Part 4");
- is_in_list(aManager, "addons://list/extension", false, true);
+ aManager = await wait_for_view_load(gBrowser.contentWindow.wrappedJSObject);
+ info("Part 3");
+ is_in_detail(aManager, "addons://list/extension", true, false);
- close_manager(aManager, run_next_test);
- });
- });
- });
- });
+ go_back();
+ aManager = await wait_for_view_load(aManager);
+ info("Part 4");
+ is_in_list(aManager, "addons://list/extension", false, true);
+
+ close_manager(aManager, run_next_test);
});
});
// Tests that removing an extension from the detail view goes back and doesn't
// allow you to go forward again.
-add_test(function() {
- open_manager("addons://list/extension", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/extension", false, false);
+add_test(async function() {
+ let aManager = await open_manager("addons://list/extension");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension", false, false);
- double_click_addon_element(aManager, "test1@tests.mozilla.org");
-
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_detail(aManager, "addons://list/extension", true, false);
+ double_click_addon_element(aManager, "test1@tests.mozilla.org");
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("detail-uninstall-btn"),
- { }, aManager);
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_detail(aManager, "addons://list/extension", true, false);
- wait_for_view_load(aManager, function() {
- // TODO until bug 590661 is fixed the back button will be enabled
- // when displaying in content
- is_in_list(aManager, "addons://list/extension", true, false);
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("detail-uninstall-btn"),
+ { }, aManager);
- close_manager(aManager, run_next_test);
- });
- });
- });
+ await wait_for_view_load(aManager);
+ is_in_list(aManager, "addons://list/extension", true, false);
+
+ close_manager(aManager, run_next_test);
});
// Tests that opening the manager opens the last view
-add_test(function() {
- open_manager("addons://list/plugin", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/plugin", false, false);
+add_test(async function() {
+ let aManager = await open_manager("addons://list/plugin");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/plugin", false, false);
- close_manager(aManager, function() {
- open_manager(null, function(aManager) {
- info("Part 2");
- is_in_list(aManager, "addons://list/plugin", false, false);
+ await close_manager(aManager);
+ aManager = await open_manager(null);
+ info("Part 2");
+ is_in_list(aManager, "addons://list/plugin", false, false);
- close_manager(aManager, run_next_test);
- });
- });
- });
+ close_manager(aManager, run_next_test);
});
// Tests that navigating the discovery page works when that was the first view
-add_test(function() {
- open_manager("addons://discover/", function(aManager) {
- info("1");
- is_in_discovery(aManager, MAIN_URL, false, false);
+add_test(async function() {
+ let aManager = await open_manager("addons://discover/");
+ info("1");
+ is_in_discovery(aManager, MAIN_URL, false, false);
+
+ clickLink(aManager, "link-good", function() {
+ info("2");
+ is_in_discovery(aManager, SECOND_URL, true, false);
+
+ waitForLoad(aManager, function() {
+ info("3");
+ is_in_discovery(aManager, MAIN_URL, false, true);
- clickLink(aManager, "link-good", function() {
- info("2");
- is_in_discovery(aManager, SECOND_URL, true, false);
+ waitForLoad(aManager, async function() {
+ is_in_discovery(aManager, SECOND_URL, true, false);
+
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
- waitForLoad(aManager, function() {
- info("3");
- is_in_discovery(aManager, MAIN_URL, false, true);
+ aManager = await wait_for_view_load(aManager);
+ is_in_list(aManager, "addons://list/plugin", true, false);
+
+ go_back();
+
+ aManager = await wait_for_view_load(aManager);
+ is_in_discovery(aManager, SECOND_URL, true, true);
+
+ go_back();
waitForLoad(aManager, function() {
- is_in_discovery(aManager, SECOND_URL, true, false);
-
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
-
- wait_for_view_load(aManager, function(aManager) {
- is_in_list(aManager, "addons://list/plugin", true, false);
-
- go_back();
-
- wait_for_view_load(aManager, function(aManager) {
- is_in_discovery(aManager, SECOND_URL, true, true);
+ is_in_discovery(aManager, MAIN_URL, false, true);
- go_back();
-
- waitForLoad(aManager, function() {
- is_in_discovery(aManager, MAIN_URL, false, true);
-
- close_manager(aManager, run_next_test);
- });
- });
- });
+ close_manager(aManager, run_next_test);
});
-
- go_forward();
});
- go_back();
+ go_forward();
});
+
+ go_back();
});
});
// Tests that navigating the discovery page works when that was the second view
-add_test(function() {
- open_manager("addons://list/plugin", function(aManager) {
- is_in_list(aManager, "addons://list/plugin", false, false);
+add_test(async function() {
+ let aManager = await open_manager("addons://list/plugin");
+ is_in_list(aManager, "addons://list/plugin", false, false);
+
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-discover"), { }, aManager);
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-discover"), { }, aManager);
+ aManager = await wait_for_view_load(aManager);
+ is_in_discovery(aManager, MAIN_URL, true, false);
- wait_for_view_load(aManager, function(aManager) {
- is_in_discovery(aManager, MAIN_URL, true, false);
+ clickLink(aManager, "link-good", function() {
+ is_in_discovery(aManager, SECOND_URL, true, false);
- clickLink(aManager, "link-good", function() {
+ waitForLoad(aManager, function() {
+ is_in_discovery(aManager, MAIN_URL, true, true);
+
+ waitForLoad(aManager, async function() {
is_in_discovery(aManager, SECOND_URL, true, false);
- waitForLoad(aManager, function() {
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
+
+ aManager = await wait_for_view_load(aManager);
+ is_in_list(aManager, "addons://list/plugin", true, false);
+
+ go_back();
+
+ aManager = await wait_for_view_load(aManager);
+ is_in_discovery(aManager, SECOND_URL, true, true);
+
+ go_back();
+
+ waitForLoad(aManager, async function() {
+ is_in_discovery(aManager, MAIN_URL, true, true);
+
+ go_back();
+
+ aManager = await wait_for_view_load(aManager);
+ is_in_list(aManager, "addons://list/plugin", false, true);
+
+ go_forward();
+
+ aManager = await wait_for_view_load(aManager);
is_in_discovery(aManager, MAIN_URL, true, true);
waitForLoad(aManager, function() {
- is_in_discovery(aManager, SECOND_URL, true, false);
-
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugin"), { }, aManager);
-
- wait_for_view_load(aManager, function(aManager) {
- is_in_list(aManager, "addons://list/plugin", true, false);
-
- go_back();
-
- wait_for_view_load(aManager, function(aManager) {
- is_in_discovery(aManager, SECOND_URL, true, true);
-
- go_back();
-
- waitForLoad(aManager, function() {
- is_in_discovery(aManager, MAIN_URL, true, true);
-
- go_back();
+ is_in_discovery(aManager, SECOND_URL, true, true);
- wait_for_view_load(aManager, function(aManager) {
- is_in_list(aManager, "addons://list/plugin", false, true);
-
- go_forward();
-
- wait_for_view_load(aManager, function(aManager) {
- is_in_discovery(aManager, MAIN_URL, true, true);
-
- waitForLoad(aManager, function() {
- is_in_discovery(aManager, SECOND_URL, true, true);
-
- close_manager(aManager, run_next_test);
- });
-
- go_forward();
- });
- });
- });
- });
- });
+ close_manager(aManager, run_next_test);
});
go_forward();
});
+ });
- go_back();
- });
+ go_forward();
});
+
+ go_back();
});
});
// Tests that refreshing the disicovery pane integrates properly with history
-add_test(function() {
- open_manager("addons://list/plugin", function(aManager) {
- is_in_list(aManager, "addons://list/plugin", false, false);
+add_test(async function() {
+ let aManager = await open_manager("addons://list/plugin");
+ is_in_list(aManager, "addons://list/plugin", false, false);
+
+ EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-discover"), { }, aManager);
+
+ aManager = await wait_for_view_load(aManager);
+ is_in_discovery(aManager, MAIN_URL, true, false);
+
+ clickLink(aManager, "link-good", function() {
+ is_in_discovery(aManager, SECOND_URL, true, false);
EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-discover"), { }, aManager);
- wait_for_view_load(aManager, function(aManager) {
+ waitForLoad(aManager, function() {
is_in_discovery(aManager, MAIN_URL, true, false);
- clickLink(aManager, "link-good", function() {
- is_in_discovery(aManager, SECOND_URL, true, false);
+ go_back();
+
+ waitForLoad(aManager, function() {
+ is_in_discovery(aManager, SECOND_URL, true, true);
- EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-discover"), { }, aManager);
+ go_back();
- waitForLoad(aManager, function() {
- is_in_discovery(aManager, MAIN_URL, true, false);
+ waitForLoad(aManager, async function() {
+ is_in_discovery(aManager, MAIN_URL, true, true);
go_back();
+ aManager = await wait_for_view_load(aManager);
+ is_in_list(aManager, "addons://list/plugin", false, true);
+
+ go_forward();
+
+ aManager = await wait_for_view_load(aManager);
+ is_in_discovery(aManager, MAIN_URL, true, true);
+
waitForLoad(aManager, function() {
is_in_discovery(aManager, SECOND_URL, true, true);
- go_back();
-
waitForLoad(aManager, function() {
- is_in_discovery(aManager, MAIN_URL, true, true);
-
- go_back();
-
- wait_for_view_load(aManager, function(aManager) {
- is_in_list(aManager, "addons://list/plugin", false, true);
-
- go_forward();
-
- wait_for_view_load(aManager, function(aManager) {
- is_in_discovery(aManager, MAIN_URL, true, true);
+ is_in_discovery(aManager, MAIN_URL, true, false);
- waitForLoad(aManager, function() {
- is_in_discovery(aManager, SECOND_URL, true, true);
-
- waitForLoad(aManager, function() {
- is_in_discovery(aManager, MAIN_URL, true, false);
+ close_manager(aManager, run_next_test);
+ });
+ go_forward();
+ });
- close_manager(aManager, run_next_test);
- });
- go_forward();
- });
-
- go_forward();
- });
- });
- });
- });
+ go_forward();
});
});
});
});
});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562854.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562854.js
@@ -36,94 +36,88 @@ function is_in_list(aManager, view) {
function is_in_detail(aManager, view) {
var doc = aManager.document;
is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category");
is(get_current_view(aManager).id, "detail-view", "Should be on the right view");
}
// Check that double-click does something.
-add_test(function() {
- open_manager("addons://list/extension", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/extension");
+add_test(async function() {
+ let aManager = await open_manager("addons://list/extension");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension");
- var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
- addon.parentNode.ensureElementIsVisible(addon);
- EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 1 }, aManager);
- EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 2 }, aManager);
+ var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
+ addon.parentNode.ensureElementIsVisible(addon);
+ EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 1 }, aManager);
+ EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 2 }, aManager);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_detail(aManager, "addons://list/extension");
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_detail(aManager, "addons://list/extension");
- close_manager(aManager, run_next_test);
- });
- });
+ close_manager(aManager, run_next_test);
});
// Check that double-click does nothing when over the disable button.
-add_test(function() {
- open_manager("addons://list/extension", function(aManager) {
- info("Part 1");
- is_in_list(aManager, "addons://list/extension");
+add_test(async function() {
+ let aManager = await open_manager("addons://list/extension");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension");
+
+ var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
+ addon.parentNode.ensureElementIsVisible(addon);
+ EventUtils.synthesizeMouseAtCenter(
+ aManager.document.getAnonymousElementByAttribute(addon, "anonid", "disable-btn"),
+ { clickCount: 1 },
+ aManager
+ );
+ // The disable button is replaced by the enable button when clicked on.
+ EventUtils.synthesizeMouseAtCenter(
+ aManager.document.getAnonymousElementByAttribute(addon, "anonid", "enable-btn"),
+ { clickCount: 2 },
+ aManager
+ );
+
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
+ is_in_list(aManager, "addons://list/extension");
+
+ close_manager(aManager, run_next_test);
+});
- var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
- addon.parentNode.ensureElementIsVisible(addon);
- EventUtils.synthesizeMouseAtCenter(
- aManager.document.getAnonymousElementByAttribute(addon, "anonid", "disable-btn"),
- { clickCount: 1 },
- aManager
- );
- // The disable button is replaced by the enable button when clicked on.
- EventUtils.synthesizeMouseAtCenter(
- aManager.document.getAnonymousElementByAttribute(addon, "anonid", "enable-btn"),
+// Check that double-click does nothing when over the undo button.
+add_test(async function() {
+ let aManager = await open_manager("addons://list/extension");
+ info("Part 1");
+ is_in_list(aManager, "addons://list/extension");
+
+ var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
+ addon.parentNode.ensureElementIsVisible(addon);
+ EventUtils.synthesizeMouseAtCenter(
+ aManager.document.getAnonymousElementByAttribute(addon, "anonid", "remove-btn"),
+ { clickCount: 1 },
+ aManager
+ );
+
+ // The undo button is removed when clicked on.
+ // We need to wait for the UI to catch up.
+ setTimeout(async function() {
+ var target = aManager.document.getAnonymousElementByAttribute(addon, "anonid", "undo-btn");
+ var rect = target.getBoundingClientRect();
+ var addonRect = addon.getBoundingClientRect();
+
+ EventUtils.synthesizeMouse(target, rect.width / 2, rect.height / 2, { clickCount: 1 }, aManager);
+ EventUtils.synthesizeMouse(addon,
+ rect.left - addonRect.left + rect.width / 2,
+ rect.top - addonRect.top + rect.height / 2,
{ clickCount: 2 },
aManager
);
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_list(aManager, "addons://list/extension");
-
- close_manager(aManager, run_next_test);
- });
- });
-});
-
-// Check that double-click does nothing when over the undo button.
-add_test(function() {
- open_manager("addons://list/extension", function(aManager) {
- info("Part 1");
+ aManager = await wait_for_view_load(aManager);
+ info("Part 2");
is_in_list(aManager, "addons://list/extension");
- var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
- addon.parentNode.ensureElementIsVisible(addon);
- EventUtils.synthesizeMouseAtCenter(
- aManager.document.getAnonymousElementByAttribute(addon, "anonid", "remove-btn"),
- { clickCount: 1 },
- aManager
- );
-
- // The undo button is removed when clicked on.
- // We need to wait for the UI to catch up.
- setTimeout(function() {
- var target = aManager.document.getAnonymousElementByAttribute(addon, "anonid", "undo-btn");
- var rect = target.getBoundingClientRect();
- var addonRect = addon.getBoundingClientRect();
-
- EventUtils.synthesizeMouse(target, rect.width / 2, rect.height / 2, { clickCount: 1 }, aManager);
- EventUtils.synthesizeMouse(addon,
- rect.left - addonRect.left + rect.width / 2,
- rect.top - addonRect.top + rect.height / 2,
- { clickCount: 2 },
- aManager
- );
-
- wait_for_view_load(aManager, function(aManager) {
- info("Part 2");
- is_in_list(aManager, "addons://list/extension");
-
- close_manager(aManager, run_next_test);
- });
- }, 0);
- });
+ close_manager(aManager, run_next_test);
+ }, 0);
});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562890.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562890.js
@@ -1,17 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Tests the Preferences button for addons in list view
*/
-function test() {
+async function test() {
requestLongerTimeout(2);
waitForExplicitFinish();
var addonPrefsURI = CHROMEROOT + "addon_prefs.xul";
var gProvider = new MockProvider();
gProvider.createAddons([{
@@ -21,33 +21,32 @@ function test() {
},
{
id: "test2@tests.mozilla.org",
name: "Test add-on 2",
description: "bar",
optionsURL: addonPrefsURI
}]);
- open_manager("addons://list/extension", function(aManager) {
- var addonList = aManager.document.getElementById("addon-list");
- for (var addonItem of addonList.childNodes) {
- if (addonItem.hasAttribute("name") &&
- addonItem.getAttribute("name") == "Test add-on 1")
- break;
- }
- var prefsBtn = aManager.document.getAnonymousElementByAttribute(addonItem,
- "anonid",
- "preferences-btn");
- is(prefsBtn.hidden, true, "Prefs button should be hidden for addon with no optionsURL set");
+ let aManager = await open_manager("addons://list/extension");
+ var addonList = aManager.document.getElementById("addon-list");
+ for (var addonItem of addonList.childNodes) {
+ if (addonItem.hasAttribute("name") &&
+ addonItem.getAttribute("name") == "Test add-on 1")
+ break;
+ }
+ var prefsBtn = aManager.document.getAnonymousElementByAttribute(addonItem,
+ "anonid",
+ "preferences-btn");
+ is(prefsBtn.hidden, true, "Prefs button should be hidden for addon with no optionsURL set");
- for (addonItem of addonList.childNodes) {
- if (addonItem.hasAttribute("name") &&
- addonItem.getAttribute("name") == "Test add-on 2")
- break;
- }
- prefsBtn = aManager.document.getAnonymousElementByAttribute(addonItem,
- "anonid",
- "preferences-btn");
- is(prefsBtn.hidden, true, "Prefs button should not be shown for addon with just an optionsURL set");
+ for (addonItem of addonList.childNodes) {
+ if (addonItem.hasAttribute("name") &&
+ addonItem.getAttribute("name") == "Test add-on 2")
+ break;
+ }
+ prefsBtn = aManager.document.getAnonymousElementByAttribute(addonItem,
+ "anonid",
+ "preferences-btn");
+ is(prefsBtn.hidden, true, "Prefs button should not be shown for addon with just an optionsURL set");
- close_manager(aManager, finish);
- });
+ close_manager(aManager, finish);
}
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562899.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562899.js
@@ -7,80 +7,74 @@
var tempScope = {};
ChromeUtils.import("resource://gre/modules/LightweightThemeManager.jsm", tempScope);
var LightweightThemeManager = tempScope.LightweightThemeManager;
var gManagerWindow;
var gCategoryUtilities;
-function test() {
+async function test() {
waitForExplicitFinish();
// Add a lightweight theme so at least one theme exists
LightweightThemeManager.currentTheme = {
id: "test",
name: "Test lightweight theme",
headerURL: "http://example.com/header.png"
};
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- LightweightThemeManager.forgetUsedTheme("test");
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ LightweightThemeManager.forgetUsedTheme("test");
+ finish();
}
// Tests that loading a second view before the first has not finished loading
// does not merge the results
-add_test(function() {
+add_test(async function() {
var themeCount = null;
var pluginCount = null;
var themeItem = gCategoryUtilities.get("theme");
var pluginItem = gCategoryUtilities.get("plugin");
var list = gManagerWindow.document.getElementById("addon-list");
- gCategoryUtilities.open(themeItem, function() {
- themeCount = list.childNodes.length;
- ok(themeCount > 0, "Test is useless if there are no themes");
-
- gCategoryUtilities.open(pluginItem, function() {
- pluginCount = list.childNodes.length;
- ok(pluginCount > 0, "Test is useless if there are no plugins");
+ await gCategoryUtilities.open(themeItem);
+ themeCount = list.childNodes.length;
+ ok(themeCount > 0, "Test is useless if there are no themes");
- gCategoryUtilities.open(themeItem);
-
- gCategoryUtilities.open(pluginItem, function() {
- is(list.childNodes.length, pluginCount, "Should only see the plugins");
+ await gCategoryUtilities.open(pluginItem);
+ pluginCount = list.childNodes.length;
+ ok(pluginCount > 0, "Test is useless if there are no plugins");
- var item = list.firstChild;
- while (item) {
- is(item.getAttribute("type"), "plugin", "All items should be plugins");
- item = item.nextSibling;
- }
+ gCategoryUtilities.open(themeItem);
+
+ await gCategoryUtilities.open(pluginItem);
+ is(list.childNodes.length, pluginCount, "Should only see the plugins");
- // Tests that switching to, from, to the same pane in quick succession
- // still only shows the right number of results
+ var item = list.firstChild;
+ while (item) {
+ is(item.getAttribute("type"), "plugin", "All items should be plugins");
+ item = item.nextSibling;
+ }
- gCategoryUtilities.open(themeItem);
- gCategoryUtilities.open(pluginItem);
- gCategoryUtilities.open(themeItem, function() {
- is(list.childNodes.length, themeCount, "Should only see the theme");
+ // Tests that switching to, from, to the same pane in quick succession
+ // still only shows the right number of results
- var item = list.firstChild;
- while (item) {
- is(item.getAttribute("type"), "theme", "All items should be theme");
- item = item.nextSibling;
- }
+ gCategoryUtilities.open(themeItem);
+ gCategoryUtilities.open(pluginItem);
+ await gCategoryUtilities.open(themeItem);
+ is(list.childNodes.length, themeCount, "Should only see the theme");
- run_next_test();
- });
- });
- });
- });
+ var item = list.firstChild;
+ while (item) {
+ is(item.getAttribute("type"), "theme", "All items should be theme");
+ item = item.nextSibling;
+ }
+
+ run_next_test();
});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562992.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562992.js
@@ -11,31 +11,29 @@
*/
var gManagerWindow;
var gProvider;
var gInstall;
const EXTENSION_NAME = "Wunderbar";
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
// Create a MockInstall with a MockAddon payload and add it to the provider,
// causing the onNewInstall event to fire, which in turn will cause a new
// "installing" item to appear in the list of extensions.
add_test(function() {
let addon = new MockAddon(undefined, EXTENSION_NAME, "extension", true);
gInstall = new MockInstall(undefined, undefined, addon);
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567137.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug567137.js
@@ -1,40 +1,35 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test that the selected category is persisted across loads of the manager
-function test() {
+async function test() {
waitForExplicitFinish();
- open_manager(null, function(aWindow) {
- let utils = new CategoryUtilities(aWindow);
+ let aWindow = await open_manager(null);
+ let utils = new CategoryUtilities(aWindow);
+
+ // Open the plugins category
+ utils.openType("plugin", async function() {
- // Open the plugins category
- utils.openType("plugin", function() {
+ // Re-open the manager
+ await close_manager(aWindow);
+ aWindow = await open_manager(null);
+ utils = new CategoryUtilities(aWindow);
+
+ is(utils.selectedCategory, "plugin", "Should have shown the plugins category");
+
+ // Open the extensions category
+ utils.openType("extension", async function() {
// Re-open the manager
- close_manager(aWindow, function() {
- open_manager(null, function(aWindow) {
- utils = new CategoryUtilities(aWindow);
-
- is(utils.selectedCategory, "plugin", "Should have shown the plugins category");
-
- // Open the extensions category
- utils.openType("extension", function() {
+ await close_manager(aWindow);
+ aWindow = await open_manager(null);
+ utils = new CategoryUtilities(aWindow);
- // Re-open the manager
- close_manager(aWindow, function() {
- open_manager(null, function(aWindow) {
- utils = new CategoryUtilities(aWindow);
-
- is(utils.selectedCategory, "extension", "Should have shown the extensions category");
- close_manager(aWindow, finish);
- });
- });
- });
- });
- });
+ is(utils.selectedCategory, "extension", "Should have shown the extensions category");
+ close_manager(aWindow, finish);
});
});
}
--- a/toolkit/mozapps/extensions/test/browser/browser_bug570760.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug570760.js
@@ -2,33 +2,32 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Bug 570760 - Make ctrl-f and / focus the search box in the add-ons manager
var gManagerWindow;
var focusCount = 0;
-function test() {
+async function test() {
waitForExplicitFinish();
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
- var searchBox = gManagerWindow.document.getElementById("header-search");
- function focusHandler() {
- searchBox.blur();
- focusCount++;
- }
- searchBox.addEventListener("focus", focusHandler);
- f_key_test();
- slash_key_test();
- searchBox.removeEventListener("focus", focusHandler);
- end_test();
- });
+ var searchBox = gManagerWindow.document.getElementById("header-search");
+ function focusHandler() {
+ searchBox.blur();
+ focusCount++;
+ }
+ searchBox.addEventListener("focus", focusHandler);
+ f_key_test();
+ slash_key_test();
+ searchBox.removeEventListener("focus", focusHandler);
+ end_test();
}
function end_test() {
close_manager(gManagerWindow, finish);
}
function f_key_test() {
EventUtils.synthesizeKey("f", { accelKey: true }, gManagerWindow);
--- a/toolkit/mozapps/extensions/test/browser/browser_bug572561.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug572561.js
@@ -31,32 +31,30 @@ var gTestInstallListener = {
},
onInstallFailed(aInstall) {
ok(false, "Did not expect onInstallFailed");
run_next_test();
}
};
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
function check_hidden(aExpectedHidden) {
var hidden = !gCategoryUtilities.isTypeVisible("locale");
is(hidden, aExpectedHidden, "Should have correct hidden state");
}
// Tests that a non-active install does not make the locale category show
@@ -65,35 +63,33 @@ add_test(function() {
gInstall = gProvider.createInstalls(gInstallProperties)[0];
gInstall.addTestListener(gTestInstallListener);
check_hidden(true);
run_next_test();
});
// Test that restarting the add-on manager with a non-active install
// does not cause the locale category to show
-add_test(function() {
- restart_manager(gManagerWindow, null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- check_hidden(true);
- run_next_test();
- });
+add_test(async function() {
+ let aWindow = await restart_manager(gManagerWindow, null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ check_hidden(true);
+ run_next_test();
});
// Test that installing the install shows the locale category
add_test(function() {
gInstall.install();
});
// Test that restarting the add-on manager does not cause the locale category
// to become hidden
-add_test(function() {
- restart_manager(gManagerWindow, null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- check_hidden(false);
+add_test(async function() {
+ let aWindow = await restart_manager(gManagerWindow, null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ check_hidden(false);
- gExpectedCancel = true;
- gInstall.cancel();
- });
+ gExpectedCancel = true;
+ gInstall.cancel();
});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug577990.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug577990.js
@@ -9,31 +9,30 @@ var gManagerWindow;
var gCategoryUtilities;
var gProvider;
var gInstall;
var gInstallProperties = [{
name: "Locale Category Test",
type: "locale"
}];
-function test() {
+async function test() {
try {
if (Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo).D2DEnabled) {
requestLongerTimeout(2);
}
} catch (e) {}
waitForExplicitFinish();
gProvider = new MockProvider();
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
}
function end_test() {
close_manager(gManagerWindow, finish);
}
function install_locale(aCallback) {
gInstall = gProvider.createInstalls(gInstallProperties)[0];
@@ -46,37 +45,34 @@ function install_locale(aCallback) {
gInstall.install();
}
function check_hidden(aExpectedHidden) {
var hidden = !gCategoryUtilities.isTypeVisible("locale");
is(hidden, !!aExpectedHidden, "Should have correct hidden state");
}
-function run_open_test(aTestSetup, aLoadHidden, aInitializedHidden, aSelected) {
+async function run_open_test(aTestSetup, aLoadHidden, aInitializedHidden, aSelected) {
function loadCallback(aManagerWindow) {
gManagerWindow = aManagerWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
check_hidden(aLoadHidden);
}
- function run() {
- open_manager(null, function() {
- check_hidden(aInitializedHidden);
- var selected = (gCategoryUtilities.selectedCategory == "locale");
- is(selected, !!aSelected, "Should have correct selected state");
+ async function run() {
+ await open_manager(null, null, loadCallback);
+ check_hidden(aInitializedHidden);
+ var selected = (gCategoryUtilities.selectedCategory == "locale");
+ is(selected, !!aSelected, "Should have correct selected state");
- run_next_test();
- }, loadCallback);
+ run_next_test();
}
- close_manager(gManagerWindow, function() {
- // Allow for asynchronous functions to run before the manager opens
- aTestSetup ? aTestSetup(run) : run();
- });
+ await close_manager(gManagerWindow);
+ aTestSetup ? aTestSetup(run) : run();
}
// Tests that the locale category is hidden when there are no locales installed
add_test(function() {
run_open_test(null, true, true);
});
@@ -112,20 +108,19 @@ add_test(function() {
// Tests that installing a locale when the Add-on Manager is closed, and then
// opening the Add-on Manager causes the locale category to be shown with an
// acceptable delay
add_test(function() {
run_open_test(install_locale, true, false);
});
// Tests that selection of the locale category persists
-add_test(function() {
- gCategoryUtilities.openType("locale", function() {
- run_open_test(null, false, false, true);
- });
+add_test(async function() {
+ await gCategoryUtilities.openType("locale");
+ run_open_test(null, false, false, true);
});
// Tests that cancelling the locale install and restarting the Add-on Manager
// causes the locale category to be hidden and not selected
add_test(function() {
gInstall.cancel();
run_open_test(null, false, true);
});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug586574.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug586574.js
@@ -22,36 +22,35 @@ var gResetToManual;
// Make sure we don't accidentally start a background update while the prefs
// are enabled.
disableBackgroundUpdateTimer();
registerCleanupFunction(() => {
enableBackgroundUpdateTimer();
});
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "addon 1",
version: "1.0",
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
}]);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
- gUtilsBtn = gManagerWindow.document.getElementById("header-utils-btn");
- gUtilsMenu = gManagerWindow.document.getElementById("utils-menu");
+ gUtilsBtn = gManagerWindow.document.getElementById("header-utils-btn");
+ gUtilsMenu = gManagerWindow.document.getElementById("utils-menu");
- run_next_test();
- });
+ run_next_test();
}
function end_test() {
close_manager(gManagerWindow, finish);
}
--- a/toolkit/mozapps/extensions/test/browser/browser_bug587970.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug587970.js
@@ -3,17 +3,17 @@
*/
/* eslint-disable mozilla/no-arbitrary-setTimeout */
// Bug 587970 - Provide ability "Update all now" within 'Available Updates' screen
var gManagerWindow;
var gProvider;
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "addon 1",
version: "1.0",
@@ -26,20 +26,19 @@ function test() {
}, {
id: "addon3@tests.mozilla.org",
name: "addon 3",
version: "3.0",
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
}]);
- open_manager("addons://updates/available", function(aWindow) {
- gManagerWindow = aWindow;
- run_next_test();
- });
+ let aWindow = await open_manager("addons://updates/available");
+ gManagerWindow = aWindow;
+ run_next_test();
}
function end_test() {
close_manager(gManagerWindow, finish);
}
--- a/toolkit/mozapps/extensions/test/browser/browser_bug590347.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug590347.js
@@ -9,34 +9,33 @@
var gProvider;
var gManagerWindow;
var gCategoryUtilities;
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
var gVersion = Services.appinfo.version;
// Opens the details view of an add-on
-function open_details(aId, aType, aCallback) {
+async function open_details(aId, aType, aCallback) {
requestLongerTimeout(2);
- gCategoryUtilities.openType(aType, function() {
- var list = gManagerWindow.document.getElementById("addon-list");
- var item = list.firstChild;
- while (item) {
- if ("mAddon" in item && item.mAddon.id == aId) {
- list.ensureElementIsVisible(item);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
- wait_for_view_load(gManagerWindow, aCallback);
- return;
- }
- item = item.nextSibling;
+ await gCategoryUtilities.openType(aType);
+ var list = gManagerWindow.document.getElementById("addon-list");
+ var item = list.firstChild;
+ while (item) {
+ if ("mAddon" in item && item.mAddon.id == aId) {
+ list.ensureElementIsVisible(item);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
+ wait_for_view_load(gManagerWindow, aCallback);
+ return;
}
- ok(false, "Should have found the add-on in the list");
- });
+ item = item.nextSibling;
+ }
+ ok(false, "Should have found the add-on in the list");
}
function get_list_view_warning_node() {
let item = gManagerWindow.document.getElementById("addon-list").firstChild;
let found = false;
while (item) {
if (item.mAddon.name == "Test add-on") {
found = true;
@@ -49,71 +48,67 @@ function get_list_view_warning_node() {
}
function get_detail_view_warning_node(aManagerWindow) {
if (aManagerWindow)
return aManagerWindow.document.getElementById("detail-warning");
return undefined;
}
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "Test add-on",
description: "A test add-on",
isCompatible: false,
blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED,
}]);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
// Check with compatibility checking enabled
-add_test(function() {
- gCategoryUtilities.openType("extension", function() {
- Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, true);
- let warning_node = get_list_view_warning_node();
- is_element_visible(warning_node, "Warning message should be visible");
- is(warning_node.textContent, "Test add-on is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
- run_next_test();
- });
+add_test(async function() {
+ await gCategoryUtilities.openType("extension");
+ Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, true);
+ let warning_node = get_list_view_warning_node();
+ is_element_visible(warning_node, "Warning message should be visible");
+ is(warning_node.textContent, "Test add-on is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
+ run_next_test();
});
add_test(function() {
open_details("addon1@tests.mozilla.org", "extension", function() {
let warning_node = get_detail_view_warning_node(gManagerWindow);
is_element_visible(warning_node, "Warning message should be visible");
is(warning_node.textContent, "Test add-on is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, false);
run_next_test();
});
});
// Check with compatibility checking disabled
-add_test(function() {
- gCategoryUtilities.openType("extension", function() {
- let warning_node = get_list_view_warning_node();
- is_element_visible(warning_node, "Warning message should be visible");
- is(warning_node.textContent, "Test add-on is known to cause security or stability issues.", "Warning message should be correct");
- run_next_test();
- });
+add_test(async function() {
+ await gCategoryUtilities.openType("extension");
+ let warning_node = get_list_view_warning_node();
+ is_element_visible(warning_node, "Warning message should be visible");
+ is(warning_node.textContent, "Test add-on is known to cause security or stability issues.", "Warning message should be correct");
+ run_next_test();
});
add_test(function() {
open_details("addon1@tests.mozilla.org", "extension", function() {
let warning_node = get_detail_view_warning_node(gManagerWindow);
is_element_visible(warning_node, "Warning message should be visible");
is(warning_node.textContent, "Test add-on is known to cause security or stability issues.", "Warning message should be correct");
run_next_test();
--- a/toolkit/mozapps/extensions/test/browser/browser_bug591465.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug591465.js
@@ -21,17 +21,17 @@ var gLWTheme = {
author: "Pixel Pusher",
homepageURL: "http://mochi.test:8888/data/index.html",
headerURL: "http://mochi.test:8888/data/header.png",
previewURL: "http://mochi.test:8888/data/preview.png",
iconURL: "http://mochi.test:8888/data/icon.png"
};
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "addon 1",
version: "1.0"
@@ -55,21 +55,20 @@ function test() {
id: "theme3@tests.mozilla.org",
name: "theme 3",
version: "1.0",
type: "theme",
permissions: 0
}]);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gContextMenu = aWindow.document.getElementById("addonitem-popup");
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gContextMenu = aWindow.document.getElementById("addonitem-popup");
+ run_next_test();
}
function end_test() {
close_manager(gManagerWindow, finish);
}
@@ -191,33 +190,32 @@ add_test(function() {
info("Opening context menu on disabled extension item");
el.parentNode.ensureElementIsVisible(el);
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
gManagerWindow.loadView("addons://list/theme");
- wait_for_view_load(gManagerWindow, function() {
- var el = get_addon_element(gManagerWindow, "theme1@tests.mozilla.org");
+ await wait_for_view_load(gManagerWindow);
+ var el = get_addon_element(gManagerWindow, "theme1@tests.mozilla.org");
- gContextMenu.addEventListener("popupshown", function() {
- check_contextmenu(true, true, false, false, false);
+ gContextMenu.addEventListener("popupshown", function() {
+ check_contextmenu(true, true, false, false, false);
- gContextMenu.hidePopup();
- run_next_test();
- }, {once: true});
+ gContextMenu.hidePopup();
+ run_next_test();
+ }, {once: true});
- info("Opening context menu on enabled theme item");
- el.parentNode.ensureElementIsVisible(el);
- EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
- EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
- });
+ info("Opening context menu on enabled theme item");
+ el.parentNode.ensureElementIsVisible(el);
+ EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
+ EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
add_test(function() {
var el = get_addon_element(gManagerWindow, "theme2@tests.mozilla.org");
gContextMenu.addEventListener("popupshown", function() {
check_contextmenu(true, false, false, false, false);
@@ -266,145 +264,131 @@ add_test(function() {
info("Opening context menu on disabled LW theme item");
el.parentNode.ensureElementIsVisible(el);
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
LightweightThemeManager.currentTheme = gLWTheme;
gManagerWindow.loadView("addons://detail/4@personas.mozilla.org");
- wait_for_view_load(gManagerWindow, function() {
-
- gContextMenu.addEventListener("popupshown", function() {
- check_contextmenu(true, true, false, true, false);
+ await wait_for_view_load(gManagerWindow);
+ gContextMenu.addEventListener("popupshown", function() {
+ check_contextmenu(true, true, false, true, false);
- gContextMenu.hidePopup();
- run_next_test();
- }, {once: true});
+ gContextMenu.hidePopup();
+ run_next_test();
+ }, {once: true});
- info("Opening context menu on enabled LW theme, in detail view");
- var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
- EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
- EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
- });
+ info("Opening context menu on enabled LW theme, in detail view");
+ var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
+ EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
+ EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
LightweightThemeManager.currentTheme = null;
gManagerWindow.loadView("addons://detail/4@personas.mozilla.org");
- wait_for_view_load(gManagerWindow, function() {
+ await wait_for_view_load(gManagerWindow);
+ gContextMenu.addEventListener("popupshown", async function() {
+ check_contextmenu(true, false, false, true, false);
- gContextMenu.addEventListener("popupshown", async function() {
- check_contextmenu(true, false, false, true, false);
-
- gContextMenu.hidePopup();
+ gContextMenu.hidePopup();
- let aAddon = await AddonManager.getAddonByID("4@personas.mozilla.org");
- aAddon.uninstall();
- run_next_test();
- }, {once: true});
+ let aAddon = await AddonManager.getAddonByID("4@personas.mozilla.org");
+ aAddon.uninstall();
+ run_next_test();
+ }, {once: true});
- info("Opening context menu on disabled LW theme, in detail view");
- var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
- EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
- EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
- });
+ info("Opening context menu on disabled LW theme, in detail view");
+ var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
+ EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
+ EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
gManagerWindow.loadView("addons://detail/addon1@tests.mozilla.org");
- wait_for_view_load(gManagerWindow, function() {
-
- gContextMenu.addEventListener("popupshown", function() {
- check_contextmenu(false, true, false, true, false);
+ await wait_for_view_load(gManagerWindow);
+ gContextMenu.addEventListener("popupshown", function() {
+ check_contextmenu(false, true, false, true, false);
- gContextMenu.hidePopup();
- run_next_test();
- }, {once: true});
+ gContextMenu.hidePopup();
+ run_next_test();
+ }, {once: true});
- info("Opening context menu on enabled extension, in detail view");
- var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
- EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
- EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
- });
+ info("Opening context menu on enabled extension, in detail view");
+ var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
+ EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
+ EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
gManagerWindow.loadView("addons://detail/addon2@tests.mozilla.org");
- wait_for_view_load(gManagerWindow, function() {
-
- gContextMenu.addEventListener("popupshown", function() {
- check_contextmenu(false, false, false, true, false);
+ await wait_for_view_load(gManagerWindow);
+ gContextMenu.addEventListener("popupshown", function() {
+ check_contextmenu(false, false, false, true, false);
- gContextMenu.hidePopup();
- run_next_test();
- }, {once: true});
+ gContextMenu.hidePopup();
+ run_next_test();
+ }, {once: true});
- info("Opening context menu on disabled extension, in detail view");
- var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
- EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
- EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
- });
+ info("Opening context menu on disabled extension, in detail view");
+ var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
+ EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
+ EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
gManagerWindow.loadView("addons://detail/theme1@tests.mozilla.org");
- wait_for_view_load(gManagerWindow, function() {
-
- gContextMenu.addEventListener("popupshown", function() {
- check_contextmenu(true, true, false, true, false);
+ await wait_for_view_load(gManagerWindow);
+ gContextMenu.addEventListener("popupshown", function() {
+ check_contextmenu(true, true, false, true, false);
- gContextMenu.hidePopup();
- run_next_test();
- }, {once: true});
+ gContextMenu.hidePopup();
+ run_next_test();
+ }, {once: true});
- info("Opening context menu on enabled theme, in detail view");
- var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
- EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
- EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
- });
+ info("Opening context menu on enabled theme, in detail view");
+ var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
+ EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
+ EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
gManagerWindow.loadView("addons://detail/theme2@tests.mozilla.org");
- wait_for_view_load(gManagerWindow, function() {
-
- gContextMenu.addEventListener("popupshown", function() {
- check_contextmenu(true, false, false, true, false);
+ await wait_for_view_load(gManagerWindow);
+ gContextMenu.addEventListener("popupshown", function() {
+ check_contextmenu(true, false, false, true, false);
- gContextMenu.hidePopup();
- run_next_test();
- }, {once: true});
+ gContextMenu.hidePopup();
+ run_next_test();
+ }, {once: true});
- info("Opening context menu on disabled theme, in detail view");
- var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
- EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
- EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
- });
+ info("Opening context menu on disabled theme, in detail view");
+ var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
+ EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
+ EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
gManagerWindow.loadView("addons://detail/theme3@tests.mozilla.org");
- wait_for_view_load(gManagerWindow, function() {
-
- gContextMenu.addEventListener("popupshown", function() {
- check_contextmenu(true, true, false, true, true);
+ await wait_for_view_load(gManagerWindow);
+ gContextMenu.addEventListener("popupshown", function() {
+ check_contextmenu(true, true, false, true, true);
- gContextMenu.hidePopup();
- run_next_test();
- }, {once: true});
+ gContextMenu.hidePopup();
+ run_next_test();
+ }, {once: true});
- info("Opening context menu with single menu item on enabled theme, in detail view");
- var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
- EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
- EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
- });
+ info("Opening context menu with single menu item on enabled theme, in detail view");
+ var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
+ EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
+ EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug591663.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug591663.js
@@ -25,30 +25,29 @@ var gAddonProperties = {
name: "Bug 591663 Mock Add-on",
type: "mock-addon"
};
var gExtensionProperties = {
name: "Bug 591663 Extension Install",
type: "extension"
};
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider(true, [{
id: "mock-addon",
name: "Mock Add-ons",
uiPriority: 4500,
flags: AddonManager.TYPE_UI_VIEW_LIST
}]);
- open_manager(VIEW_ID, function(aWindow) {
- gManagerWindow = aWindow;
- run_next_test();
- });
+ let aWindow = await open_manager(VIEW_ID);
+ gManagerWindow = aWindow;
+ run_next_test();
}
function end_test() {
close_manager(gManagerWindow, finish);
}
/**
* Check that the list view is as expected
@@ -100,22 +99,21 @@ add_test(function() {
run_next_test();
}
});
gItem.install();
});
// Test that restarting the manager does not change list
-add_test(function() {
- restart_manager(gManagerWindow, VIEW_ID, function(aManagerWindow) {
- gManagerWindow = aManagerWindow;
- check_list(gItem);
- run_next_test();
- });
+add_test(async function() {
+ let aManagerWindow = await restart_manager(gManagerWindow, VIEW_ID);
+ gManagerWindow = aManagerWindow;
+ check_list(gItem);
+ run_next_test();
});
// Test that onInstallCancelled removes install and shows empty notice
add_test(function() {
gItem.cancel();
gItem = null;
check_list(null);
run_next_test();
@@ -146,16 +144,15 @@ add_test(function() {
// Test that onExternalInstall properly hides empty notice and adds install to list
add_test(function() {
gItem = gProvider.createAddons([gAddonProperties])[0];
check_list(gItem);
run_next_test();
});
// Test that restarting the manager does not change list
-add_test(function() {
- restart_manager(gManagerWindow, VIEW_ID, function(aManagerWindow) {
- gManagerWindow = aManagerWindow;
- check_list(gItem);
- run_next_test();
- });
+add_test(async function() {
+ let aManagerWindow = await restart_manager(gManagerWindow, VIEW_ID);
+ gManagerWindow = aManagerWindow;
+ check_list(gItem);
+ run_next_test();
});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug618502.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug618502.js
@@ -12,33 +12,31 @@ function test() {
run_next_test();
}
function end_test() {
finish();
}
-add_test(function() {
- open_manager("addons://detail/foo", function(aManager) {
- gCategoryUtilities = new CategoryUtilities(aManager);
- is(gCategoryUtilities.selectedCategory, "discover", "Should fall back to the discovery pane");
+add_test(async function() {
+ let aManager = await open_manager("addons://detail/foo");
+ gCategoryUtilities = new CategoryUtilities(aManager);
+ is(gCategoryUtilities.selectedCategory, "discover", "Should fall back to the discovery pane");
- close_manager(aManager, run_next_test);
- });
+ close_manager(aManager, run_next_test);
});
// Also test that opening directly to an add-on that does exist doesn't break
// and selects the right category
-add_test(function() {
+add_test(async function() {
new MockProvider().createAddons([{
id: "addon1@tests.mozilla.org",
name: "addon 1",
version: "1.0"
}]);
- open_manager("addons://detail/addon1@tests.mozilla.org", function(aManager) {
- gCategoryUtilities = new CategoryUtilities(aManager);
- is(gCategoryUtilities.selectedCategory, "extension", "Should have selected the right category");
+ let aManager = await open_manager("addons://detail/addon1@tests.mozilla.org");
+ gCategoryUtilities = new CategoryUtilities(aManager);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should have selected the right category");
- close_manager(aManager, run_next_test);
- });
+ close_manager(aManager, run_next_test);
});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug679604.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug679604.js
@@ -1,27 +1,24 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Bug 679604 - Test that a XUL persisted category from an older version of
// Firefox doesn't break the add-ons manager when that category doesn't exist
-function test() {
+async function test() {
waitForExplicitFinish();
- open_manager(null, function(aWindow) {
- var categories = aWindow.document.getElementById("categories");
- categories.setAttribute("last-selected", "foo");
- aWindow.document.persist("categories", "last-selected");
-
- close_manager(aWindow, function() {
- Services.prefs.clearUserPref(PREF_UI_LASTCATEGORY);
+ let aWindow = await open_manager(null);
+ var categories = aWindow.document.getElementById("categories");
+ categories.setAttribute("last-selected", "foo");
+ aWindow.document.persist("categories", "last-selected");
- open_manager(null, function(aWindow) {
- is(new CategoryUtilities(aWindow).selectedCategory, "discover",
- "Should have loaded the right view");
+ await close_manager(aWindow);
+ Services.prefs.clearUserPref(PREF_UI_LASTCATEGORY);
- close_manager(aWindow, finish);
- });
- });
- });
+ aWindow = await open_manager(null);
+ is(new CategoryUtilities(aWindow).selectedCategory, "discover",
+ "Should have loaded the right view");
+
+ close_manager(aWindow, finish);
}
--- a/toolkit/mozapps/extensions/test/browser/browser_details.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_details.js
@@ -12,41 +12,40 @@ var gManagerWindow;
var gCategoryUtilities;
var gProvider;
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
var gVersion = Services.appinfo.version;
var gDate = new Date(2010, 7, 1);
var infoURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "unsigned-addons";
-function open_details(aId, aType, aCallback) {
+async function open_details(aId, aType, aCallback) {
requestLongerTimeout(2);
- gCategoryUtilities.openType(aType, function() {
- var list = gManagerWindow.document.getElementById("addon-list");
- var item = list.firstChild;
- while (item) {
- if ("mAddon" in item && item.mAddon.id == aId) {
- list.ensureElementIsVisible(item);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
- wait_for_view_load(gManagerWindow, aCallback);
- return;
- }
- item = item.nextSibling;
+ await gCategoryUtilities.openType(aType);
+ var list = gManagerWindow.document.getElementById("addon-list");
+ var item = list.firstChild;
+ while (item) {
+ if ("mAddon" in item && item.mAddon.id == aId) {
+ list.ensureElementIsVisible(item);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
+ wait_for_view_load(gManagerWindow, aCallback);
+ return;
}
- ok(false, "Should have found the add-on in the list");
- });
+ item = item.nextSibling;
+ }
+ ok(false, "Should have found the add-on in the list");
}
function get(aId) {
return gManagerWindow.document.getElementById(aId);
}
-function test() {
+async function test() {
requestLongerTimeout(2);
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
@@ -140,28 +139,26 @@ function test() {
isCompatible: false,
}, {
id: "addon12@tests.mozilla.org",
name: "Test add-on 12",
signedState: AddonManager.SIGNEDSTATE_SIGNED,
foreignInstall: true,
}]);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
// Opens and tests the details view for add-on 2
add_test(function() {
open_details("addon2@tests.mozilla.org", "extension", function() {
is(get("detail-name").textContent, "Test add-on 2", "Name should be correct");
is_element_visible(get("detail-version"), "Version should not be hidden");
is(get("detail-version").value, "2.2", "Version should be correct");
@@ -337,50 +334,46 @@ if (!AppConstants.MOZ_REQUIRE_SIGNING) {
is_element_hidden(get("detail-pending"), "Pending message should be hidden");
run_next_test();
});
});
}
// Opens and tests the details view for add-on 9 with signing required
-add_test(function() {
- close_manager(gManagerWindow, function() {
- Services.prefs.setBoolPref("xpinstall.signatures.required", true);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ await close_manager(gManagerWindow);
+ Services.prefs.setBoolPref("xpinstall.signatures.required", true);
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- open_details("addon9@tests.mozilla.org", "extension", function() {
- is(get("detail-name").textContent, "Test add-on 9", "Name should be correct");
+ open_details("addon9@tests.mozilla.org", "extension", async function() {
+ is(get("detail-name").textContent, "Test add-on 9", "Name should be correct");
- is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
- is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
- is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
- is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");
+ is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
+ is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
+ is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
+ is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");
- is_element_hidden(get("detail-warning"), "Warning message should be hidden");
- is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
- is_element_visible(get("detail-error"), "Error message should be visible");
- is(get("detail-error").textContent, "Test add-on 9 could not be verified for use in " + gApp + " and has been disabled.", "Error message should be correct");
- is_element_visible(get("detail-error-link"), "Error link should be visible");
- is(get("detail-error-link").value, "More Information", "Error link text should be correct");
- is(get("detail-error-link").href, infoURL, "Error link should be correct");
+ is_element_hidden(get("detail-warning"), "Warning message should be hidden");
+ is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
+ is_element_visible(get("detail-error"), "Error message should be visible");
+ is(get("detail-error").textContent, "Test add-on 9 could not be verified for use in " + gApp + " and has been disabled.", "Error message should be correct");
+ is_element_visible(get("detail-error-link"), "Error link should be visible");
+ is(get("detail-error-link").value, "More Information", "Error link text should be correct");
+ is(get("detail-error-link").href, infoURL, "Error link should be correct");
- close_manager(gManagerWindow, function() {
- Services.prefs.setBoolPref("xpinstall.signatures.required", false);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ await close_manager(gManagerWindow);
+ Services.prefs.setBoolPref("xpinstall.signatures.required", false);
+ aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
- });
- });
- });
+ run_next_test();
});
});
// These tests are only appropriate when signing can be turned off
if (!AppConstants.REQUIRE_SIGNING) {
// Opens and tests the details view for add-on 10
add_test(function() {
open_details("addon10@tests.mozilla.org", "extension", function() {
@@ -399,50 +392,46 @@ if (!AppConstants.REQUIRE_SIGNING) {
is_element_hidden(get("detail-pending"), "Pending message should be hidden");
run_next_test();
});
});
}
// Opens and tests the details view for add-on 10 with signing required
-add_test(function() {
- close_manager(gManagerWindow, function() {
- Services.prefs.setBoolPref("xpinstall.signatures.required", true);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ await close_manager(gManagerWindow);
+ Services.prefs.setBoolPref("xpinstall.signatures.required", true);
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- open_details("addon10@tests.mozilla.org", "extension", function() {
- is(get("detail-name").textContent, "Test add-on 10", "Name should be correct");
+ open_details("addon10@tests.mozilla.org", "extension", async function() {
+ is(get("detail-name").textContent, "Test add-on 10", "Name should be correct");
- is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
- is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
- is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
- is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");
+ is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
+ is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
+ is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
+ is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");
- is_element_hidden(get("detail-warning"), "Warning message should be hidden");
- is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
- is_element_visible(get("detail-error"), "Error message should be visible");
- is(get("detail-error").textContent, "Test add-on 10 could not be verified for use in " + gApp + " and has been disabled.", "Error message should be correct");
- is_element_visible(get("detail-error-link"), "Error link should be visible");
- is(get("detail-error-link").value, "More Information", "Error link text should be correct");
- is(get("detail-error-link").href, infoURL, "Error link should be correct");
+ is_element_hidden(get("detail-warning"), "Warning message should be hidden");
+ is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
+ is_element_visible(get("detail-error"), "Error message should be visible");
+ is(get("detail-error").textContent, "Test add-on 10 could not be verified for use in " + gApp + " and has been disabled.", "Error message should be correct");
+ is_element_visible(get("detail-error-link"), "Error link should be visible");
+ is(get("detail-error-link").value, "More Information", "Error link text should be correct");
+ is(get("detail-error-link").href, infoURL, "Error link should be correct");
- close_manager(gManagerWindow, function() {
- Services.prefs.setBoolPref("xpinstall.signatures.required", false);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ await close_manager(gManagerWindow);
+ Services.prefs.setBoolPref("xpinstall.signatures.required", false);
+ aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
- });
- });
- });
+ run_next_test();
});
});
// Opens and tests the details view for add-on 11
add_test(function() {
open_details("addon11@tests.mozilla.org", "extension", function() {
is(get("detail-name").textContent, "Test add-on 11", "Name should be correct");
@@ -458,48 +447,44 @@ add_test(function() {
is_element_hidden(get("detail-error-link"), "Error link should be hidden");
is_element_hidden(get("detail-pending"), "Pending message should be hidden");
run_next_test();
});
});
// Opens and tests the details view for add-on 11 with signing required
-add_test(function() {
- close_manager(gManagerWindow, function() {
- Services.prefs.setBoolPref("xpinstall.signatures.required", true);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ await close_manager(gManagerWindow);
+ Services.prefs.setBoolPref("xpinstall.signatures.required", true);
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- open_details("addon11@tests.mozilla.org", "extension", function() {
- is(get("detail-name").textContent, "Test add-on 11", "Name should be correct");
-
- is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
- is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
- is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
- is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");
+ open_details("addon11@tests.mozilla.org", "extension", async function() {
+ is(get("detail-name").textContent, "Test add-on 11", "Name should be correct");
- is_element_visible(get("detail-warning"), "Warning message should be visible");
- is(get("detail-warning").textContent, "Test add-on 11 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
- is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
- is_element_hidden(get("detail-error"), "Error message should be hidden");
- is_element_hidden(get("detail-error-link"), "Error link should be hidden");
+ is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
+ is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
+ is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
+ is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");
- close_manager(gManagerWindow, function() {
- Services.prefs.setBoolPref("xpinstall.signatures.required", false);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ is_element_visible(get("detail-warning"), "Warning message should be visible");
+ is(get("detail-warning").textContent, "Test add-on 11 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
+ is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
+ is_element_hidden(get("detail-error"), "Error message should be hidden");
+ is_element_hidden(get("detail-error-link"), "Error link should be hidden");
- run_next_test();
- });
- });
- });
- });
+ await close_manager(gManagerWindow);
+ Services.prefs.setBoolPref("xpinstall.signatures.required", false);
+ aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+
+ run_next_test();
});
});
// Opens and tests the details view for add-on 12
add_test(function() {
open_details("addon12@tests.mozilla.org", "extension", function() {
is(get("detail-name").textContent, "Test add-on 12", "Name should be correct");
@@ -514,47 +499,43 @@ add_test(function() {
is_element_hidden(get("detail-error-link"), "Error link should be hidden");
is_element_hidden(get("detail-pending"), "Pending message should be hidden");
run_next_test();
});
});
// Opens and tests the details view for add-on 12 with signing required
-add_test(function() {
- close_manager(gManagerWindow, function() {
- Services.prefs.setBoolPref("xpinstall.signatures.required", true);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ await close_manager(gManagerWindow);
+ Services.prefs.setBoolPref("xpinstall.signatures.required", true);
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- open_details("addon12@tests.mozilla.org", "extension", function() {
- is(get("detail-name").textContent, "Test add-on 12", "Name should be correct");
-
- is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
- is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
- is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
- is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");
+ open_details("addon12@tests.mozilla.org", "extension", async function() {
+ is(get("detail-name").textContent, "Test add-on 12", "Name should be correct");
- is_element_hidden(get("detail-warning"), "Warning message should be hidden");
- is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
- is_element_hidden(get("detail-error"), "Error message should be hidden");
- is_element_hidden(get("detail-error-link"), "Error link should be hidden");
+ is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
+ is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
+ is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
+ is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");
- close_manager(gManagerWindow, function() {
- Services.prefs.setBoolPref("xpinstall.signatures.required", false);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ is_element_hidden(get("detail-warning"), "Warning message should be hidden");
+ is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
+ is_element_hidden(get("detail-error"), "Error message should be hidden");
+ is_element_hidden(get("detail-error-link"), "Error link should be hidden");
- run_next_test();
- });
- });
- });
- });
+ await close_manager(gManagerWindow);
+ Services.prefs.setBoolPref("xpinstall.signatures.required", false);
+ aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+
+ run_next_test();
});
});
// Tests that upgrades with onExternalInstall apply immediately
add_test(function() {
open_details("addon1@tests.mozilla.org", "extension", function() {
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
--- a/toolkit/mozapps/extensions/test/browser/browser_discovery.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_discovery.js
@@ -175,427 +175,384 @@ function clickLink(aId, aCallback) {
EventUtils.sendMouseEvent({type: "click"}, link);
executeSoon(function() {
ok(isLoading(), "Clicking a link should show the loading pane");
});
}
// Tests that switching to the discovery view displays the right url
-add_test(function() {
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- gCategoryUtilities.openType("discover", async function() {
- var browser = gManagerWindow.document.getElementById("discover-browser");
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
+ 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);
- });
+ await testHash(browser, [true, true, true]);
+ close_manager(gManagerWindow, run_next_test);
- ok(isLoading(), "Should be loading at first");
- });
+ 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(function() {
+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);
- open_manager(null, async function(aWindow) {
- 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");
-
- await testHash(browser, [true, false, true]);
- close_manager(gManagerWindow, run_next_test);
- }, function(aWindow) {
+ let 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");
+
+ await testHash(browser, [true, false, true]);
+ close_manager(gManagerWindow, run_next_test);
});
// Tests that loading the add-ons manager with the discovery view as the initial
// view displays the right url
-add_test(function() {
+add_test(async function() {
Services.prefs.clearUserPref("extensions.addon2@tests.mozilla.org.getAddons.cache.enabled");
Services.prefs.setBoolPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled", false);
- open_manager(null, function(aWindow) {
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ await gCategoryUtilities.openType("extension");
+ await close_manager(gManagerWindow);
+ aWindow = await open_manager("addons://discover/", null, function(aWindow) {
gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- gCategoryUtilities.openType("extension", function() {
- close_manager(gManagerWindow, function() {
- open_manager("addons://discover/", async function(aWindow) {
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
+ 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");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- await testHash(browser, [true, true, false]);
- Services.prefs.clearUserPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled");
- close_manager(gManagerWindow, run_next_test);
- }, function(aWindow) {
- gManagerWindow = aWindow;
- ok(isLoading(), "Should be loading at first");
- });
- });
- });
- });
+ await testHash(browser, [true, true, false]);
+ Services.prefs.clearUserPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled");
+ close_manager(gManagerWindow, run_next_test);
});
// Tests that switching to the discovery view displays the right url
-add_test(function() {
+add_test(async function() {
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- gCategoryUtilities.openType("discover", function() {
- var browser = gManagerWindow.document.getElementById("discover-browser");
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
+ await gCategoryUtilities.openType("discover");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- is(getHash(browser), null, "Hash should not have been passed");
- close_manager(gManagerWindow, run_next_test);
- });
- });
+ is(getHash(browser), null, "Hash should not have been passed");
+ close_manager(gManagerWindow, run_next_test);
});
// Tests that loading the add-ons manager with the discovery view as the last
// selected view displays the right url
-add_test(function() {
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
+add_test(async function() {
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ 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");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- is(getHash(browser), null, "Hash should not have been passed");
- close_manager(gManagerWindow, run_next_test);
- });
+ is(getHash(browser), null, "Hash should not have been passed");
+ close_manager(gManagerWindow, run_next_test);
});
// Tests that loading the add-ons manager with the discovery view as the initial
// view displays the right url
-add_test(function() {
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- gCategoryUtilities.openType("extension", function() {
- close_manager(gManagerWindow, function() {
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
+add_test(async function() {
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ await gCategoryUtilities.openType("extension");
+ await close_manager(gManagerWindow);
+ aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ 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");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- is(getHash(browser), null, "Hash should not have been passed");
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
+ is(getHash(browser), null, "Hash should not have been passed");
+ close_manager(gManagerWindow, run_next_test);
});
// Tests that navigating to an insecure page fails
-add_test(function() {
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var browser = gManagerWindow.document.getElementById("discover-browser");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
+
+ 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");
- clickLink("link-http", function() {
- ok(isError(), "Should have shown the error page");
-
- gCategoryUtilities.openType("extension", function() {
- gCategoryUtilities.openType("discover", function() {
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
-
- close_manager(gManagerWindow, run_next_test);
- });
- ok(isLoading(), "Should start loading again");
- });
- });
+ close_manager(gManagerWindow, run_next_test);
+ ok(isLoading(), "Should start loading again");
});
});
// Tests that navigating to a different domain fails
-add_test(function() {
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var browser = gManagerWindow.document.getElementById("discover-browser");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
+
+ 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");
- clickLink("link-domain", function() {
- ok(isError(), "Should have shown the error page");
-
- gCategoryUtilities.openType("extension", function() {
- gCategoryUtilities.openType("discover", function() {
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
-
- close_manager(gManagerWindow, run_next_test);
- });
- ok(isLoading(), "Should start loading again");
- });
- });
+ close_manager(gManagerWindow, run_next_test);
+ ok(isLoading(), "Should start loading again");
});
});
// Tests that navigating to a missing page fails
-add_test(function() {
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var browser = gManagerWindow.document.getElementById("discover-browser");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
+
+ 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");
- clickLink("link-bad", function() {
- ok(isError(), "Should have shown the error page");
-
- gCategoryUtilities.openType("extension", function() {
- gCategoryUtilities.openType("discover", function() {
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
-
- close_manager(gManagerWindow, run_next_test);
- });
- ok(isLoading(), "Should start loading again");
- });
- });
+ 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(function() {
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var browser = gManagerWindow.document.getElementById("discover-browser");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
+
+ clickLink("link-good", async function() {
+ is(getURL(browser), "https://example.com/" + RELATIVE_DIR + "releaseNotes.xhtml", "Should have loaded the right url");
+
+ await gCategoryUtilities.openType("extension");
+ await gCategoryUtilities.openType("discover");
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- clickLink("link-good", function() {
- is(getURL(browser), "https://example.com/" + RELATIVE_DIR + "releaseNotes.xhtml", "Should have loaded the right url");
-
- gCategoryUtilities.openType("extension", function() {
- gCategoryUtilities.openType("discover", function() {
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
-
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
+ close_manager(gManagerWindow, run_next_test);
});
});
// Tests repeated navigation to the same page followed by a navigation to a
// different domain
-add_test(function() {
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- var browser = gManagerWindow.document.getElementById("discover-browser");
+ var count = 10;
+ function clickAgain(aCallback) {
+ if (count-- == 0)
+ aCallback();
+ else
+ clickLink("link-normal", clickAgain.bind(null, aCallback));
+ }
+
+ clickAgain(function() {
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- var count = 10;
- function clickAgain(aCallback) {
- if (count-- == 0)
- aCallback();
- else
- clickLink("link-normal", clickAgain.bind(null, aCallback));
- }
+ clickLink("link-domain", async function() {
+ ok(isError(), "Should have shown the error page");
- clickAgain(function() {
+ await gCategoryUtilities.openType("extension");
+ await gCategoryUtilities.openType("discover");
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- clickLink("link-domain", function() {
- ok(isError(), "Should have shown the error page");
-
- gCategoryUtilities.openType("extension", function() {
- gCategoryUtilities.openType("discover", function() {
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
-
- close_manager(gManagerWindow, run_next_test);
- });
- ok(isLoading(), "Should start loading again");
- });
- });
+ 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(function() {
+add_test(async function() {
Services.prefs.setCharPref(PREF_DISCOVERURL, TESTROOT + "discovery.html");
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var browser = gManagerWindow.document.getElementById("discover-browser");
- is(getURL(browser), TESTROOT + "discovery.html", "Should have loaded the right url");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), TESTROOT + "discovery.html", "Should have loaded the right url");
- clickLink("link-normal", function() {
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
+ clickLink("link-normal", function() {
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- clickLink("link-http", function() {
- is(getURL(browser), TESTROOT + "discovery.html", "Should have loaded the right url");
+ clickLink("link-http", function() {
+ is(getURL(browser), TESTROOT + "discovery.html", "Should have loaded the right url");
- close_manager(gManagerWindow, run_next_test);
- });
+ close_manager(gManagerWindow, run_next_test);
});
});
});
// Stopping the initial load should display the error page and then correctly
// reload when switching away and back again
-add_test(function() {
+add_test(async function() {
Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ 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);
+ var browser = gManagerWindow.document.getElementById("discover-browser");
- wait_for_view_load(gManagerWindow, function() {
- ok(isError(), "Should have shown the error page");
+ EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow);
- gCategoryUtilities.openType("extension", function() {
- EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ ok(isError(), "Should have shown the error page");
- wait_for_view_load(gManagerWindow, function() {
- ok(isError(), "Should have shown the error page");
+ await gCategoryUtilities.openType("extension");
+ EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow);
- gCategoryUtilities.openType("extension", function() {
- gCategoryUtilities.openType("discover", function() {
- is(getURL(browser), MAIN_URL, "Should have loaded the right url");
+ await wait_for_view_load(gManagerWindow);
+ ok(isError(), "Should have shown the error page");
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
+ await gCategoryUtilities.openType("extension");
+ await gCategoryUtilities.openType("discover");
+ is(getURL(browser), MAIN_URL, "Should have loaded the right url");
- ok(isLoading(), "Should be loading");
- // This will stop the real page load
- browser.stop();
- });
- });
+ close_manager(gManagerWindow, run_next_test);
- ok(isLoading(), "Should be loading");
- // This will actually stop the about:blank load
- browser.stop();
- });
+ 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(function() {
+add_test(async function() {
const url = "chrome://mochitests/content/" + RELATIVE_DIR + "addon_prefs.xul";
Services.prefs.setCharPref(PREF_DISCOVERURL, url);
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var browser = gManagerWindow.document.getElementById("discover-browser");
- is(getURL(browser), url, "Loading a chrome XUL file should work");
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), url, "Loading a chrome XUL file should work");
- restart_manager(gManagerWindow, "addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ aWindow = await restart_manager(gManagerWindow, "addons://discover/");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var browser = gManagerWindow.document.getElementById("discover-browser");
- is(getURL(browser), url, "Should be able to load the chrome XUL file a second time");
+ var 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);
- });
- });
+ close_manager(gManagerWindow, run_next_test);
});
// Bug 711693 - Send the compatibility mode when loading the Discovery pane
-add_test(function() {
+add_test(async function() {
info("Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'normal'");
Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL + "?mode=%COMPATIBILITY_MODE%");
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false);
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- var browser = gManagerWindow.document.getElementById("discover-browser");
- is(getURL(browser), MAIN_URL + "?mode=normal", "Should have loaded the right url");
- close_manager(gManagerWindow, run_next_test);
- });
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL + "?mode=normal", "Should have loaded the right url");
+ close_manager(gManagerWindow, run_next_test);
});
-add_test(function() {
+add_test(async function() {
info("Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'strict'");
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- var browser = gManagerWindow.document.getElementById("discover-browser");
- is(getURL(browser), MAIN_URL + "?mode=strict", "Should have loaded the right url");
- close_manager(gManagerWindow, run_next_test);
- });
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL + "?mode=strict", "Should have loaded the right url");
+ close_manager(gManagerWindow, run_next_test);
});
-add_test(function() {
+add_test(async function() {
info("Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'ignore'");
Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, false);
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
- var browser = gManagerWindow.document.getElementById("discover-browser");
- is(getURL(browser), MAIN_URL + "?mode=ignore", "Should have loaded the right url");
- close_manager(gManagerWindow, run_next_test);
- });
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
+ var browser = gManagerWindow.document.getElementById("discover-browser");
+ is(getURL(browser), MAIN_URL + "?mode=ignore", "Should have loaded the right url");
+ close_manager(gManagerWindow, run_next_test);
});
// Test for Bug 601442 - extensions.getAddons.showPane need to be update
// for the new addon manager.
-function bug_601442_test_elements(visible) {
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- if (visible)
- ok(gCategoryUtilities.isTypeVisible("discover"), "Discover category should be visible");
- else
- ok(!gCategoryUtilities.isTypeVisible("discover"), "Discover category should not be visible");
+async function bug_601442_test_elements(visible) {
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ if (visible)
+ ok(gCategoryUtilities.isTypeVisible("discover"), "Discover category should be visible");
+ else
+ ok(!gCategoryUtilities.isTypeVisible("discover"), "Discover category should not be visible");
- gManagerWindow.loadView("addons://list/dictionary");
- wait_for_view_load(gManagerWindow, function(aManager) {
- var button = aManager.document.getElementById("discover-button-install");
- if (visible)
- ok(!is_hidden(button), "Discover button should be visible!");
- else
- ok(is_hidden(button), "Discover button should not be visible!");
+ gManagerWindow.loadView("addons://list/dictionary");
+ let aManager = await wait_for_view_load(gManagerWindow);
+ var button = aManager.document.getElementById("discover-button-install");
+ if (visible)
+ ok(!is_hidden(button), "Discover button should be visible!");
+ else
+ ok(is_hidden(button), "Discover button should not be visible!");
- close_manager(gManagerWindow, run_next_test);
- });
- });
+ close_manager(gManagerWindow, run_next_test);
}
add_test(function() {
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false);
Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
bug_601442_test_elements(false);
});
add_test(function() {
@@ -611,34 +568,32 @@ add_test(function() {
add_test(function() {
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, true);
Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
bug_601442_test_elements(true);
});
// Test for Bug 1132971 - if extensions.getAddons.showPane is false,
// the extensions pane should show by default
-add_test(function() {
+add_test(async function() {
Services.prefs.clearUserPref(PREF_UI_LASTCATEGORY);
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(gCategoryUtilities.selectedCategory, "extension", "Should be showing the extension view");
- close_manager(gManagerWindow, run_next_test);
- Services.prefs.clearUserPref(PREF_DISCOVER_ENABLED);
- });
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should be showing the extension view");
+ close_manager(gManagerWindow, run_next_test);
+ Services.prefs.clearUserPref(PREF_DISCOVER_ENABLED);
});
// Test for Bug 1219495 - should show placeholder content when offline
-add_test(function() {
+add_test(async function() {
// set a URL to cause an error
Services.prefs.setCharPref(PREF_DISCOVERURL, "https://nocert.example.com/");
- open_manager("addons://discover/", function(aWindow) {
- gManagerWindow = aWindow;
+ let aWindow = await open_manager("addons://discover/");
+ gManagerWindow = aWindow;
- ok(isError(), "Should have shown the placeholder content");
+ ok(isError(), "Should have shown the placeholder content");
- close_manager(gManagerWindow, run_next_test);
- });
+ close_manager(gManagerWindow, run_next_test);
});
--- a/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
@@ -71,29 +71,27 @@ async function checkInstallConfirmation(
Assert.deepEqual(results.sort(), names.sort(), "Got expected installs");
is(notificationCount, names.length, `Saw ${names.length} addon-install-started notification`);
Services.obs.removeObserver(observer, "addon-install-started");
executeSoon(run_next_test);
}
-function test() {
+async function test() {
waitForExplicitFinish();
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
// Simulates dropping a URL onto the manager
add_test(function test_drop_url() {
var url = TESTROOT + "addons/browser_dragdrop1.xpi";
checkInstallConfirmation("Drag Drop test 1");
--- a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js
@@ -8,56 +8,52 @@ function test() {
waitForExplicitFinish();
run_next_test();
}
function end_test() {
finish();
}
-add_test(function() {
+add_test(async function() {
info("Testing compatibility checking warning");
info("Setting checkCompatibility to false");
AddonManager.checkCompatibility = false;
- open_manager("addons://list/extension", function(aWindow) {
- var hbox = aWindow.document.querySelector("#list-view hbox.global-warning-checkcompatibility");
- is_element_visible(hbox, "Check Compatibility warning hbox should be visible");
- var button = aWindow.document.querySelector("#list-view button.global-warning-checkcompatibility");
- is_element_visible(button, "Check Compatibility warning button should be visible");
+ let aWindow = await open_manager("addons://list/extension");
+ var hbox = aWindow.document.querySelector("#list-view hbox.global-warning-checkcompatibility");
+ is_element_visible(hbox, "Check Compatibility warning hbox should be visible");
+ var button = aWindow.document.querySelector("#list-view button.global-warning-checkcompatibility");
+ is_element_visible(button, "Check Compatibility warning button should be visible");
- info("Clicking 'Enable' button");
- EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
- is(AddonManager.checkCompatibility, true, "Check Compatibility pref should be cleared");
- is_element_hidden(hbox, "Check Compatibility warning hbox should be hidden");
- is_element_hidden(button, "Check Compatibility warning button should be hidden");
+ info("Clicking 'Enable' button");
+ EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
+ is(AddonManager.checkCompatibility, true, "Check Compatibility pref should be cleared");
+ is_element_hidden(hbox, "Check Compatibility warning hbox should be hidden");
+ is_element_hidden(button, "Check Compatibility warning button should be hidden");
- close_manager(aWindow, function() {
- run_next_test();
- });
- });
+ await close_manager(aWindow);
+ run_next_test();
});
-add_test(function() {
+add_test(async function() {
info("Testing update security checking warning");
var pref = "extensions.checkUpdateSecurity";
info("Setting " + pref + " pref to false");
Services.prefs.setBoolPref(pref, false);
- open_manager(null, function(aWindow) {
- var hbox = aWindow.document.querySelector("#list-view hbox.global-warning-updatesecurity");
- is_element_visible(hbox, "Check Update Security warning hbox should be visible");
- var button = aWindow.document.querySelector("#list-view button.global-warning-updatesecurity");
- is_element_visible(button, "Check Update Security warning button should be visible");
+ let aWindow = await open_manager(null);
+ var hbox = aWindow.document.querySelector("#list-view hbox.global-warning-updatesecurity");
+ is_element_visible(hbox, "Check Update Security warning hbox should be visible");
+ var button = aWindow.document.querySelector("#list-view button.global-warning-updatesecurity");
+ is_element_visible(button, "Check Update Security warning button should be visible");
- info("Clicking 'Enable' button");
- EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
- is(Services.prefs.prefHasUserValue(pref), false, "Check Update Security pref should be cleared");
- is_element_hidden(hbox, "Check Update Security warning hbox should be hidden");
- is_element_hidden(button, "Check Update Security warning button should be hidden");
+ info("Clicking 'Enable' button");
+ EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
+ is(Services.prefs.prefHasUserValue(pref), false, "Check Update Security pref should be cleared");
+ is_element_hidden(hbox, "Check Update Security warning hbox should be hidden");
+ is_element_hidden(button, "Check Update Security warning button should be hidden");
- close_manager(aWindow, function() {
- run_next_test();
- });
- });
+ await close_manager(aWindow);
+ run_next_test();
});
--- a/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js
@@ -4,39 +4,37 @@
// Tests manual updates, including the Available Updates pane
var gProvider;
var gManagerWindow;
var gCategoryUtilities;
var gAvailableCategory;
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "auto updating addon",
version: "1.0",
applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE
}]);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
add_test(function() {
gAvailableCategory = gManagerWindow.gCategories.get("addons://updates/available");
is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should initially be hidden");
gProvider.createAddons([{
@@ -50,52 +48,50 @@ add_test(function() {
}]);
is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should still be hidden");
run_next_test();
});
-add_test(function() {
+add_test(async function() {
let finished = 0;
function maybeRunNext() {
if (++finished == 2)
run_next_test();
}
gAvailableCategory.addEventListener("CategoryBadgeUpdated", function() {
is(gCategoryUtilities.isVisible(gAvailableCategory), true, "Available Updates category should now be visible");
is(gAvailableCategory.badgeCount, 1, "Badge for Available Updates should now be 1");
maybeRunNext();
}, {once: true});
- gCategoryUtilities.openType("extension", function() {
- gProvider.createInstalls([{
- name: "manually updating addon (new and improved!)",
- existingAddon: gProvider.addons[1],
- version: "1.1",
- releaseNotesURI: Services.io.newURI(TESTROOT + "thereIsNoFileHere.xhtml")
- }]);
+ await gCategoryUtilities.openType("extension");
+ gProvider.createInstalls([{
+ name: "manually updating addon (new and improved!)",
+ existingAddon: gProvider.addons[1],
+ version: "1.1",
+ releaseNotesURI: Services.io.newURI(TESTROOT + "thereIsNoFileHere.xhtml")
+ }]);
- var item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
- get_tooltip_info(item).then(({ version }) => {
- is(version, "1.0", "Should still show the old version in the tooltip");
- maybeRunNext();
- });
+ var item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
+ get_tooltip_info(item).then(({ version }) => {
+ is(version, "1.0", "Should still show the old version in the tooltip");
+ maybeRunNext();
});
});
-add_test(function() {
- wait_for_view_load(gManagerWindow, function() {
- 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();
- }, true);
+add_test(async function() {
+ 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;
@@ -189,35 +185,32 @@ add_test(function() {
installCompleted = true;
}
};
install.addTestListener(listener);
EventUtils.synthesizeMouseAtCenter(updateBtn, { }, gManagerWindow);
});
-add_test(function() {
+add_test(async function() {
is(gCategoryUtilities.isVisible(gAvailableCategory), true, "Available Updates category should still be visible");
is(gAvailableCategory.badgeCount, 0, "Badge for Available Updates should now be 0");
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should be hidden");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should be hidden");
- close_manager(gManagerWindow, function() {
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- gAvailableCategory = gManagerWindow.gCategories.get("addons://updates/available");
+ await close_manager(gManagerWindow);
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ gAvailableCategory = gManagerWindow.gCategories.get("addons://updates/available");
- is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should be hidden");
+ is(gCategoryUtilities.isVisible(gAvailableCategory), false, "Available Updates category should be hidden");
- run_next_test();
- });
- });
- });
+ run_next_test();
});
add_test(function() {
gAvailableCategory.addEventListener("CategoryBadgeUpdated", async function() {
is(gCategoryUtilities.isVisible(gAvailableCategory), true, "Available Updates category should now be visible");
is(gAvailableCategory.badgeCount, 1, "Badge for Available Updates should now be 1");
gAvailableCategory.addEventListener("CategoryBadgeUpdated", function() {
--- a/toolkit/mozapps/extensions/test/browser/browser_newaddon.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_newaddon.js
@@ -209,17 +209,16 @@ add_test(function() {
is(doc.getElementById("buttonDeck").selectedPanel, doc.getElementById("continuePanel"),
"Should be showing the right buttons");
let aAddon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
ok(!aAddon.seen, "Add-on should not have been marked as seen.");
gBrowser.selectedTab = aTab;
- waitForFocus(function() {
- ok(aAddon.seen, "Add-on should have been marked as seen after focusing the tab.");
+ await promiseFocus(aTab.linkedBrowser.contentWindow);
+ ok(aAddon.seen, "Add-on should have been marked as seen after focusing the tab.");
- gBrowser.removeTab(aTab);
+ gBrowser.removeTab(aTab);
- run_next_test();
- }, aTab.linkedBrowser.contentWindow);
+ run_next_test();
}, true);
});
--- a/toolkit/mozapps/extensions/test/browser/browser_plugin_enabled_state_locked.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_plugin_enabled_state_locked.js
@@ -68,24 +68,23 @@ function checkStateMenuDetail(locked) {
Assert.equal(Services.prefs.prefIsLocked(getTestPluginPref()), locked,
"Preference should be " + (locked === true ? "" : "un") + "locked.");
// open details menu
let details = gManagerWindow.document.getAnonymousElementByAttribute(gPluginElement, "anonid", "details-btn");
is_element_visible(details, "Details link should be visible.");
EventUtils.synthesizeMouseAtCenter(details, {}, gManagerWindow);
- return new Promise(resolve => {
- wait_for_view_load(gManagerWindow, function() {
- let menuList = gManagerWindow.document.getElementById("detail-state-menulist");
- is_element_visible(menuList, "Details state menu should be visible.");
- Assert.equal(menuList.disabled, locked,
- "Details state menu enabled state should be correct.");
- resolve();
- });
+ return new Promise(async resolve => {
+ await wait_for_view_load(gManagerWindow);
+ let menuList = gManagerWindow.document.getElementById("detail-state-menulist");
+ is_element_visible(menuList, "Details state menu should be visible.");
+ Assert.equal(menuList.disabled, locked,
+ "Details state menu enabled state should be correct.");
+ resolve();
});
}
add_task(async function initializeState() {
Services.prefs.setIntPref(getTestPluginPref(), Ci.nsIPluginTag.STATE_ENABLED);
Services.prefs.unlockPref(getTestPluginPref());
gManagerWindow = await open_manager();
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
--- a/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
@@ -1,30 +1,28 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests the detail view of plugins
var gManagerWindow;
-function test() {
+async function test() {
waitForExplicitFinish();
- open_manager("addons://list/plugin", function(aWindow) {
- gManagerWindow = aWindow;
+ let aWindow = await open_manager("addons://list/plugin");
+ gManagerWindow = aWindow;
- run_next_test();
- });
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
add_test(async function() {
let plugins = await AddonManager.getAddonsByTypes(["plugin"]);
let testPluginId;
for (let plugin of plugins) {
if (plugin.name == "Test Plug-in") {
testPluginId = plugin.id;
--- a/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
@@ -3,17 +3,17 @@
*/
// Tests the recent updates pane
var gProvider;
var gManagerWindow;
var gCategoryUtilities;
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "updated 6 hours ago",
version: "1.0",
@@ -26,43 +26,40 @@ function test() {
updateDate: new Date(Date.now() - (1000 * 5))
}, {
id: "addon3@tests.mozilla.org",
name: "updated 1 month ago",
version: "1.0",
updateDate: new Date(Date.now() - (1000 * 60 * 60 * 25 * 30))
}]);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
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", function() {
- wait_for_view_load(gManagerWindow, function() {
- 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();
- }, true);
+ utilsBtn.addEventListener("popupshown", async function() {
+ 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() {
@@ -104,21 +101,19 @@ add_test(function() {
// sorted by name, descending
EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
check_order(["addon1@tests.mozilla.org", "addon2@tests.mozilla.org"]);
run_next_test();
});
-add_test(function() {
- close_manager(gManagerWindow, function() {
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ await close_manager(gManagerWindow);
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var recentCat = gManagerWindow.gCategories.get("addons://updates/recent");
- is(gCategoryUtilities.isVisible(recentCat), true, "Recent Updates category should still be visible");
+ var recentCat = gManagerWindow.gCategories.get("addons://updates/recent");
+ is(gCategoryUtilities.isVisible(recentCat), true, "Recent Updates category should still be visible");
- run_next_test();
- });
- });
+ run_next_test();
});
--- a/toolkit/mozapps/extensions/test/browser/browser_sorting.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_sorting.js
@@ -3,17 +3,17 @@
*/
// Tests that sorting of add-ons works correctly
// (this test uses the list view, even though it no longer has sort buttons - see bug 623207)
var gManagerWindow;
var gProvider;
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
// enabledInstalled group
// * Enabled
// * Incompatible but enabled because compatibility checking is off
// * Waiting to be installed
@@ -186,26 +186,24 @@ function test() {
updateDate: new Date(2010, 4, 12, 0, 0, 0),
size: 56,
isActive: false,
appDisabled: true,
blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
}]);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
function set_order(aSortBy, aAscending) {
var list = gManagerWindow.document.getElementById("addon-list");
var elements = [];
var node = list.firstChild;
while (node) {
elements.push(node);
--- a/toolkit/mozapps/extensions/test/browser/browser_sorting_plugins.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_sorting_plugins.js
@@ -4,17 +4,17 @@
// Tests that sorting of plugins works correctly
// (this test checks that plugins with "ask to activate" state appear after those with
// "always activate" and before those with "never activate")
var gManagerWindow;
var gProvider;
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
// enabledInstalled group
// * Always activate
// * Ask to activate
// * Never activate
@@ -49,26 +49,24 @@ function test() {
id: "test5@tests.mozilla.org",
name: "3rd Party Plug-in",
description: "foo",
type: "plugin",
isActive: true,
userDisabled: false
}]);
- open_manager("addons://list/plugin", function(aWindow) {
- gManagerWindow = aWindow;
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/plugin");
+ gManagerWindow = aWindow;
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
function check_order(aExpectedOrder) {
var order = [];
var list = gManagerWindow.document.getElementById("addon-list");
var node = list.firstChild;
while (node) {
var id = node.getAttribute("value");
--- a/toolkit/mozapps/extensions/test/browser/browser_tabsettings.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_tabsettings.js
@@ -2,40 +2,38 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests various aspects of the details view
var gManagerWindow;
var gProvider;
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "tabsettings@tests.mozilla.org",
name: "Tab Settings",
version: "1",
optionsURL: CHROMEROOT + "addon_prefs.xul",
optionsType: AddonManager.OPTIONS_TYPE_TAB
}]);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
- run_next_test();
- });
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
add_test(function() {
var addon = get_addon_element(gManagerWindow, "tabsettings@tests.mozilla.org");
is(addon.mAddon.optionsType, AddonManager.OPTIONS_TYPE_TAB, "Options should be inline type");
addon.parentNode.ensureElementIsVisible(addon);
var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn");
--- a/toolkit/mozapps/extensions/test/browser/browser_types.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_types.js
@@ -44,411 +44,359 @@ function test() {
run_next_test();
}
function end_test() {
finish();
}
// Add a new type, open the manager and make sure it is in the right place
-add_test(function() {
+add_test(async function() {
AddonManagerPrivate.registerProvider(gProvider, gTypes);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.get("type2"), "Type 2 should be present");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.get("type2"), "Type 2 should be present");
+ ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
- is(gCategoryUtilities.get("type1").previousSibling.getAttribute("value"),
- "addons://list/extension", "Type 1 should be in the right place");
- is(gCategoryUtilities.get("type2").previousSibling.getAttribute("value"),
- "addons://list/theme", "Type 2 should be in the right place");
+ is(gCategoryUtilities.get("type1").previousSibling.getAttribute("value"),
+ "addons://list/extension", "Type 1 should be in the right place");
+ is(gCategoryUtilities.get("type2").previousSibling.getAttribute("value"),
+ "addons://list/theme", "Type 2 should be in the right place");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- ok(!gCategoryUtilities.isTypeVisible("type2"), "Type 2 should be hidden");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
+ ok(!gCategoryUtilities.isTypeVisible("type2"), "Type 2 should be hidden");
- run_next_test();
- });
+ run_next_test();
});
// Select the type, close the manager and remove it then open the manager and
// check we're back to the default view
-add_test(function() {
- gCategoryUtilities.openType("type1", function() {
- close_manager(gManagerWindow, function() {
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ await gCategoryUtilities.openType("type1");
+ await close_manager(gManagerWindow);
+ AddonManagerPrivate.unregisterProvider(gProvider);
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
- ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(gCategoryUtilities.selectedCategory, "discover", "Should be back to the default view");
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
+ ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
+ ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
+ is(gCategoryUtilities.selectedCategory, "discover", "Should be back to the default view");
+
+ close_manager(gManagerWindow, run_next_test);
});
// Add a type while the manager is still open and check it appears
-add_test(function() {
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
- ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
+ ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
+ ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
+ AddonManagerPrivate.registerProvider(gProvider, gTypes);
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.get("type2"), "Type 2 should be present");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.get("type2"), "Type 2 should be present");
+ ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
- is(gCategoryUtilities.get("type1").previousSibling.getAttribute("value"),
- "addons://list/extension", "Type 1 should be in the right place");
- is(gCategoryUtilities.get("type2").previousSibling.getAttribute("value"),
- "addons://list/theme", "Type 2 should be in the right place");
+ is(gCategoryUtilities.get("type1").previousSibling.getAttribute("value"),
+ "addons://list/extension", "Type 1 should be in the right place");
+ is(gCategoryUtilities.get("type2").previousSibling.getAttribute("value"),
+ "addons://list/theme", "Type 2 should be in the right place");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- ok(!gCategoryUtilities.isTypeVisible("type2"), "Type 2 should be hidden");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
+ ok(!gCategoryUtilities.isTypeVisible("type2"), "Type 2 should be hidden");
- run_next_test();
- });
+ run_next_test();
});
// Remove the type while it is beng viewed and check it is replaced with the
// default view
-add_test(function() {
- gCategoryUtilities.openType("type1", function() {
- gCategoryUtilities.openType("plugin", function() {
- go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "type1", "Should be showing the custom view");
- check_state(true, true);
-
- AddonManagerPrivate.unregisterProvider(gProvider);
+add_test(async function() {
+ await gCategoryUtilities.openType("type1");
+ await gCategoryUtilities.openType("plugin");
+ go_back(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "type1", "Should be showing the custom view");
+ check_state(true, true);
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
- ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
+ AddonManagerPrivate.unregisterProvider(gProvider);
- is(gCategoryUtilities.selectedCategory, "discover", "Should be back to the default view");
- check_state(true, true);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
+ ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
+ ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
- go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "Should be showing the extension view");
- check_state(false, true);
+ is(gCategoryUtilities.selectedCategory, "discover", "Should be back to the default view");
+ check_state(true, true);
- go_forward(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "discover", "Should be back to the default view");
- check_state(true, true);
+ go_back(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should be showing the extension view");
+ check_state(false, true);
- go_forward(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "plugin", "Should be back to the plugins view");
- check_state(true, false);
+ go_forward(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "discover", "Should be back to the default view");
+ check_state(true, true);
- go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "discover", "Should be back to the default view");
- check_state(true, true);
+ go_forward(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "plugin", "Should be back to the plugins view");
+ check_state(true, false);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
- });
- });
- });
+ go_back(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "discover", "Should be back to the default view");
+ check_state(true, true);
+
+ close_manager(gManagerWindow, run_next_test);
});
// Test that when going back to a now missing category we skip it
-add_test(function() {
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
+add_test(async function() {
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
+ AddonManagerPrivate.registerProvider(gProvider, gTypes);
- gCategoryUtilities.openType("type1", function() {
- gCategoryUtilities.openType("plugin", function() {
- AddonManagerPrivate.unregisterProvider(gProvider);
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+ await gCategoryUtilities.openType("type1");
+ await gCategoryUtilities.openType("plugin");
+ AddonManagerPrivate.unregisterProvider(gProvider);
- go_back(gManagerWindow);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "Should be back to the first view");
- check_state(false, true);
+ go_back(gManagerWindow);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should be back to the first view");
+ check_state(false, true);
+
+ close_manager(gManagerWindow, run_next_test);
});
// Test that when going forward to a now missing category we skip it
-add_test(function() {
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
+add_test(async function() {
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
+ AddonManagerPrivate.registerProvider(gProvider, gTypes);
- gCategoryUtilities.openType("type1", function() {
- gCategoryUtilities.openType("plugin", function() {
- go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "Should be back to the extension view");
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- AddonManagerPrivate.unregisterProvider(gProvider);
+ await gCategoryUtilities.openType("type1");
+ await gCategoryUtilities.openType("plugin");
+ go_back(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ go_back(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should be back to the extension view");
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_forward(gManagerWindow);
+ AddonManagerPrivate.unregisterProvider(gProvider);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "plugin", "Should be back to the plugin view");
- check_state(true, false);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+
+ go_forward(gManagerWindow);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
- });
- });
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "plugin", "Should be back to the plugin view");
+ check_state(true, false);
+
+ close_manager(gManagerWindow, run_next_test);
});
// Test that when going back to a now missing category and we can't go back any
// any further then we just display the default view
-add_test(function() {
+add_test(async function() {
AddonManagerPrivate.registerProvider(gProvider, gTypes);
- open_manager("addons://list/type1", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(gCategoryUtilities.selectedCategory, "type1", "Should be at the custom view");
+ let aWindow = await open_manager("addons://list/type1");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "type1", "Should be at the custom view");
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- gCategoryUtilities.openType("extension", function() {
- AddonManagerPrivate.unregisterProvider(gProvider);
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+ await gCategoryUtilities.openType("extension");
+ AddonManagerPrivate.unregisterProvider(gProvider);
- go_back(gManagerWindow);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "discover", "Should be at the default view");
- check_state(false, true);
+ go_back(gManagerWindow);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "discover", "Should be at the default view");
+ check_state(false, true);
+
+ close_manager(gManagerWindow, run_next_test);
});
// Test that when going forward to a now missing category and we can't go
// forward any further then we just display the default view
-add_test(function() {
+add_test(async function() {
AddonManagerPrivate.registerProvider(gProvider, gTypes);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- gCategoryUtilities.openType("type1", function() {
- go_back(gManagerWindow);
-
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "Should be at the extension view");
+ await gCategoryUtilities.openType("type1");
+ go_back(gManagerWindow);
- AddonManagerPrivate.unregisterProvider(gProvider);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should be at the extension view");
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+ AddonManagerPrivate.unregisterProvider(gProvider);
- go_forward(gManagerWindow);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "discover", "Should be at the default view");
- check_state(true, false);
+ go_forward(gManagerWindow);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "discover", "Should be at the default view");
+ check_state(true, false);
+
+ close_manager(gManagerWindow, run_next_test);
});
// Test that when going back we skip multiple missing categories
-add_test(function() {
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
+add_test(async function() {
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
+ AddonManagerPrivate.registerProvider(gProvider, gTypes);
- gCategoryUtilities.openType("type1", function() {
- gCategoryUtilities.openType("type3", function() {
- gCategoryUtilities.openType("plugin", function() {
- AddonManagerPrivate.unregisterProvider(gProvider);
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+ await gCategoryUtilities.openType("type1");
+ await gCategoryUtilities.openType("type3");
+ await gCategoryUtilities.openType("plugin");
+ AddonManagerPrivate.unregisterProvider(gProvider);
- go_back(gManagerWindow);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "Should be back to the first view");
- check_state(false, true);
+ go_back(gManagerWindow);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
- });
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should be back to the first view");
+ check_state(false, true);
+
+ close_manager(gManagerWindow, run_next_test);
});
// Test that when going forward we skip multiple missing categories
-add_test(function() {
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+add_test(async function() {
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
+ AddonManagerPrivate.registerProvider(gProvider, gTypes);
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- gCategoryUtilities.openType("type1", function() {
- gCategoryUtilities.openType("type3", function() {
- gCategoryUtilities.openType("plugin", function() {
- go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "Should be back to the extension view");
-
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+ await gCategoryUtilities.openType("type1");
+ await gCategoryUtilities.openType("type3");
+ await gCategoryUtilities.openType("plugin");
+ go_back(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ go_back(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ go_back(gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should be back to the extension view");
- go_forward(gManagerWindow);
+ AddonManagerPrivate.unregisterProvider(gProvider);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "plugin", "Should be back to the plugin view");
- check_state(true, false);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+
+ go_forward(gManagerWindow);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
- });
- });
- });
- });
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "plugin", "Should be back to the plugin view");
+ check_state(true, false);
+
+ close_manager(gManagerWindow, run_next_test);
});
// Test that when going back we skip all missing categories and when we can't go
// back any any further then we just display the default view
-add_test(function() {
+add_test(async function() {
AddonManagerPrivate.registerProvider(gProvider, gTypes);
- open_manager("addons://list/type1", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(gCategoryUtilities.selectedCategory, "type1", "Should be at the custom view");
+ let aWindow = await open_manager("addons://list/type1");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "type1", "Should be at the custom view");
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- gCategoryUtilities.openType("type3", function() {
- gCategoryUtilities.openType("extension", function() {
- AddonManagerPrivate.unregisterProvider(gProvider);
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+ await gCategoryUtilities.openType("type3");
+ await gCategoryUtilities.openType("extension");
+ AddonManagerPrivate.unregisterProvider(gProvider);
- go_back(gManagerWindow);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "discover", "Should be at the default view");
- check_state(false, true);
+ go_back(gManagerWindow);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "discover", "Should be at the default view");
+ check_state(false, true);
+
+ close_manager(gManagerWindow, run_next_test);
});
// Test that when going forward we skip all missing categories and when we can't
// go back any any further then we just display the default view
-add_test(function() {
+add_test(async function() {
AddonManagerPrivate.registerProvider(gProvider, gTypes);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
+ ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
+ ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- gCategoryUtilities.openType("type1", function() {
- gCategoryUtilities.openType("type3", function() {
- go_back(gManagerWindow);
+ await gCategoryUtilities.openType("type1");
+ await gCategoryUtilities.openType("type3");
+ go_back(gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- go_back(gManagerWindow);
-
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "Should be at the extension view");
+ await wait_for_view_load(gManagerWindow);
+ go_back(gManagerWindow);
- AddonManagerPrivate.unregisterProvider(gProvider);
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "Should be at the extension view");
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
+ AddonManagerPrivate.unregisterProvider(gProvider);
- go_forward(gManagerWindow);
+ ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "discover", "Should be at the default view");
- check_state(true, false);
+ go_forward(gManagerWindow);
- close_manager(gManagerWindow, run_next_test);
- });
- });
- });
- });
- });
- });
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "discover", "Should be at the default view");
+ check_state(true, false);
+
+ close_manager(gManagerWindow, run_next_test);
});
--- a/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
@@ -2,17 +2,17 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var gManagerWindow;
var gDocument;
var gCategoryUtilities;
var gProvider;
-function test() {
+async function test() {
requestLongerTimeout(2);
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon2@tests.mozilla.org",
name: "Uninstall doesn't need restart 1",
@@ -50,396 +50,380 @@ function test() {
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}, {
id: "addon9@tests.mozilla.org",
name: "Uninstall doesn't need restart 8",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}]);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gDocument = gManagerWindow.document;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gDocument = gManagerWindow.document;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
function get_item_in_list(aId, aList) {
var item = aList.firstChild;
while (item) {
if ("mAddon" in item && item.mAddon.id == aId) {
aList.ensureElementIsVisible(item);
return item;
}
item = item.nextSibling;
}
return null;
}
// Tests that uninstalling a restartless add-on from the list view can be undone
-add_test(function() {
+add_test(async function() {
var ID = "addon2@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", async function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ let aAddon = await AddonManager.getAddonByID(ID);
+ ok(aAddon.isActive, "Add-on should be active");
+ ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ 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");
+ ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
+ ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
+ isnot(button, null, "Should have an undo button");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- ok(aAddon.isActive, "Add-on should be active");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ ok(aAddon.isActive, "Add-on should be active");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- run_next_test();
- });
+ run_next_test();
});
// Tests that uninstalling a disabled restartless add-on from the list view can
// be undone and doesn't re-enable
-add_test(function() {
+add_test(async function() {
var ID = "addon2@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", async function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- let aAddon = await AddonManager.getAddonByID(ID);
- aAddon.userDisabled = true;
+ let aAddon = await AddonManager.getAddonByID(ID);
+ aAddon.userDisabled = true;
- ok(!aAddon.isActive, "Add-on should be inactive");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ ok(!aAddon.isActive, "Add-on should be inactive");
+ ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ 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");
+ ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
+ ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
+ isnot(button, null, "Should have an undo button");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ ok(!aAddon.isActive, "Add-on should be inactive");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- aAddon.userDisabled = false;
- ok(aAddon.isActive, "Add-on should be active");
+ aAddon.userDisabled = false;
+ ok(aAddon.isActive, "Add-on should be active");
- run_next_test();
- });
+ run_next_test();
});
// Tests that uninstalling a restartless add-on from the details view switches
// back to the list view and can be undone
-add_test(function() {
+add_test(async function() {
var ID = "addon2@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", async function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ let aAddon = await AddonManager.getAddonByID(ID);
+ ok(aAddon.isActive, "Add-on should be active");
+ ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
- var button = gDocument.getElementById("detail-uninstall-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getElementById("detail-uninstall-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- var 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");
+ var 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");
+ 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;
-
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
+ // Force XBL to apply
+ item.clientTop;
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
+ isnot(button, null, "Should have an undo button");
- // Force XBL to apply
- item.clientTop;
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- ok(aAddon.isActive, "Add-on should be active");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ // Force XBL to apply
+ item.clientTop;
- run_next_test();
- });
- });
- });
+ ok(aAddon.isActive, "Add-on should be active");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
+
+ run_next_test();
});
// Tests that uninstalling a restartless add-on from the details view switches
// back to the list view and can be undone and doesn't re-enable
-add_test(function() {
+add_test(async function() {
var ID = "addon2@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", async function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- let aAddon = await AddonManager.getAddonByID(ID);
- aAddon.userDisabled = true;
+ let aAddon = await AddonManager.getAddonByID(ID);
+ aAddon.userDisabled = true;
- ok(!aAddon.isActive, "Add-on should be inactive");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ ok(!aAddon.isActive, "Add-on should be inactive");
+ ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
+ await wait_for_view_load(gManagerWindow);
+ is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
- var button = gDocument.getElementById("detail-uninstall-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getElementById("detail-uninstall-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await wait_for_view_load(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- var 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");
+ var 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");
- // Force XBL to apply
- item.clientTop;
+ ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
+ ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
+ // Force XBL to apply
+ item.clientTop;
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
+ isnot(button, null, "Should have an undo button");
- // Force XBL to apply
- item.clientTop;
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ // Force XBL to apply
+ item.clientTop;
- aAddon.userDisabled = false;
- ok(aAddon.isActive, "Add-on should be active");
+ ok(!aAddon.isActive, "Add-on should be inactive");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- run_next_test();
- });
- });
- });
+ aAddon.userDisabled = false;
+ ok(aAddon.isActive, "Add-on should be active");
+
+ run_next_test();
});
// Tests that switching away from the list view finalises the uninstall of
// multiple restartless add-ons
-add_test(function() {
+add_test(async function() {
var ID = "addon2@tests.mozilla.org";
var ID2 = "addon6@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", async function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ let aAddon = await AddonManager.getAddonByID(ID);
+ ok(aAddon.isActive, "Add-on should be active");
+ ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- 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");
-
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
+ 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");
- item = get_item_in_list(ID2, list);
- isnot(item, null, "Should have found the add-on in the list");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
+ isnot(button, null, "Should have an undo button");
+
+ item = get_item_in_list(ID2, list);
+ isnot(item, null, "Should have found the add-on in the list");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
-
- gCategoryUtilities.openType("plugin", async function() {
- is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension");
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- let [aAddon, aAddon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
- is(aAddon, null, "Add-on should no longer be installed");
- is(aAddon2, null, "Second add-on should no longer be installed");
+ await gCategoryUtilities.openType("plugin");
+ is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension");
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ 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");
- var 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");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- run_next_test();
- });
- });
- });
+ var 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
// multiple restartless add-ons
-add_test(function() {
+add_test(async function() {
var ID = "addon4@tests.mozilla.org";
var ID2 = "addon8@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", async function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ let aAddon = await AddonManager.getAddonByID(ID);
+ ok(aAddon.isActive, "Add-on should be active");
+ ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ 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");
+ ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
+ ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
+ isnot(button, null, "Should have an undo button");
- item = get_item_in_list(ID2, list);
- isnot(item, null, "Should have found the add-on in the list");
+ item = get_item_in_list(ID2, list);
+ isnot(item, null, "Should have found the add-on in the list");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- close_manager(gManagerWindow, async function() {
- let [aAddon, aAddon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
- is(aAddon, null, "Add-on should no longer be installed");
- is(aAddon2, null, "Second add-on should no longer be installed");
+ await close_manager(gManagerWindow);
+ 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");
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gDocument = gManagerWindow.document;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var list = gDocument.getElementById("addon-list");
+ let aWindow = await open_manager(null);
+ gManagerWindow = aWindow;
+ gDocument = gManagerWindow.document;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ var list = gDocument.getElementById("addon-list");
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- var 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");
+ var 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();
- });
- });
- });
+ run_next_test();
});
--- a/toolkit/mozapps/extensions/test/browser/browser_updateid.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_updateid.js
@@ -3,63 +3,60 @@
*/
// Tests that updates that change an add-on's ID show up correctly in the UI
var gProvider;
var gManagerWindow;
var gCategoryUtilities;
-function test() {
+async function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "manually updating addon",
version: "1.0",
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
}]);
- open_manager("addons://list/extension", function(aWindow) {
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
+ let aWindow = await open_manager("addons://list/extension");
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
}
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
+async function end_test() {
+ await close_manager(gManagerWindow);
+ finish();
}
-add_test(function() {
- gCategoryUtilities.openType("extension", function() {
- gProvider.createInstalls([{
- name: "updated add-on",
- existingAddon: gProvider.addons[0],
- version: "2.0"
- }]);
- var newAddon = new MockAddon("addon2@tests.mozilla.org");
- newAddon.name = "updated add-on";
- newAddon.version = "2.0";
- newAddon.pendingOperations = AddonManager.PENDING_INSTALL;
- gProvider.installs[0]._addonToInstall = newAddon;
+add_test(async function() {
+ await gCategoryUtilities.openType("extension");
+ gProvider.createInstalls([{
+ name: "updated add-on",
+ existingAddon: gProvider.addons[0],
+ version: "2.0"
+ }]);
+ var newAddon = new MockAddon("addon2@tests.mozilla.org");
+ newAddon.name = "updated add-on";
+ newAddon.version = "2.0";
+ newAddon.pendingOperations = AddonManager.PENDING_INSTALL;
+ gProvider.installs[0]._addonToInstall = newAddon;
- var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
- var name = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "name");
- is(name.value, "manually updating addon", "Should show the old name in the list");
- get_tooltip_info(item).then(({ name, version }) => {
- is(name, "manually updating addon", "Should show the old name in the tooltip");
- is(version, "1.0", "Should still show the old version in the tooltip");
+ var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
+ var name = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "name");
+ is(name.value, "manually updating addon", "Should show the old name in the list");
+ get_tooltip_info(item).then(({ name, version }) => {
+ is(name, "manually updating addon", "Should show the old name in the tooltip");
+ is(version, "1.0", "Should still show the old version in the tooltip");
- var update = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "update-btn");
- is_element_visible(update, "Update button should be visible");
+ var update = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "update-btn");
+ is_element_visible(update, "Update button should be visible");
- item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
- is(item, null, "Should not show the new version in the list");
+ item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
+ is(item, null, "Should not show the new version in the list");
- run_next_test();
- });
+ run_next_test();
});
});
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -374,35 +374,32 @@ function wait_for_manager_load(aManagerW
});
return log_callback(p, aCallback);
}
function open_manager(aView, aCallback, aLoadCallback, aLongerTimeout) {
let p = new Promise((resolve, reject) => {
- function setup_manager(aManagerWindow) {
+ async function setup_manager(aManagerWindow) {
if (aLoadCallback)
log_exceptions(aLoadCallback, aManagerWindow);
if (aView)
aManagerWindow.loadView(aView);
ok(aManagerWindow != null, "Should have an add-ons manager window");
is(aManagerWindow.location, MANAGER_URI, "Should be displaying the correct UI");
- waitForFocus(function() {
- info("window has focus, waiting for manager load");
- wait_for_manager_load(aManagerWindow, function() {
- info("Manager waiting for view load");
- wait_for_view_load(aManagerWindow, function() {
- resolve(aManagerWindow);
- }, null, aLongerTimeout);
- });
- }, aManagerWindow);
+ await promiseFocus(aManagerWindow);
+ info("window has focus, waiting for manager load");
+ await wait_for_manager_load(aManagerWindow);
+ info("Manager waiting for view load");
+ await wait_for_view_load(aManagerWindow, null, null, aLongerTimeout);
+ resolve(aManagerWindow);
}
info("Loading manager window in tab");
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
Services.obs.removeObserver(observer, aTopic);
if (aSubject.location.href != MANAGER_URI) {
info("Ignoring load event for " + aSubject.location.href);
return;