summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/browser/browser_bug596336.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_bug596336.js')
-rw-r--r--toolkit/mozapps/extensions/test/browser/browser_bug596336.js190
1 files changed, 107 insertions, 83 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug596336.js b/toolkit/mozapps/extensions/test/browser/browser_bug596336.js
index ec32e376f..935820613 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug596336.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug596336.js
@@ -8,12 +8,19 @@
var gManagerWindow;
var gCategoryUtilities;
-add_task(function* test() {
+function test() {
waitForExplicitFinish();
- gManagerWindow = yield open_manager("addons://list/extension");
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-});
+ open_manager("addons://list/extension", function(aWindow) {
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
+ });
+}
+
+function end_test() {
+ close_manager(gManagerWindow, finish);
+}
function get_list_item_count() {
return get_test_items_in_list(gManagerWindow).length;
@@ -27,130 +34,147 @@ function get_class_node(parent, cls) {
return parent.ownerDocument.getAnonymousElementByAttribute(parent, "class", cls);
}
-function install_addon(aXpi) {
- return new Promise(resolve => {
- AddonManager.getInstallForURL(TESTROOT + "addons/" + aXpi + ".xpi",
- function(aInstall) {
- aInstall.addListener({
- onInstallEnded: function(aInstall) {
- resolve();
- }
- });
- aInstall.install();
- }, "application/x-xpinstall");
- });
+function install_addon(aXpi, aCallback) {
+ AddonManager.getInstallForURL(TESTROOT + "addons/" + aXpi + ".xpi",
+ function(aInstall) {
+ aInstall.addListener({
+ onInstallEnded: function(aInstall) {
+ executeSoon(aCallback);
+ }
+ });
+ aInstall.install();
+ }, "application/x-xpinstall");
}
-var check_addon = Task.async(function*(aAddon, aVersion) {
+function check_addon(aAddon, version) {
is(get_list_item_count(), 1, "Should be one item in the list");
- is(aAddon.version, aVersion, "Add-on should have the right version");
+ is(aAddon.version, version, "Add-on should have the right version");
- let item = get_addon_element(gManagerWindow, "bug596336-1@tests.mozilla.org");
+ let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
ok(!!item, "Should see the add-on in the list");
// Force XBL to apply
item.clientTop;
- let { version } = yield get_tooltip_info(item);
- is(version, aVersion, "Version should be correct");
+ is(get_node(item, "version").value, version, "Version should be correct");
if (aAddon.userDisabled)
is_element_visible(get_class_node(item, "disabled-postfix"), "Disabled postfix should be hidden");
else
is_element_hidden(get_class_node(item, "disabled-postfix"), "Disabled postfix should be hidden");
-});
+}
// Install version 1 then upgrade to version 2 with the manager open
-add_task(function*() {
- yield install_addon("browser_bug596336_1");
- let [aAddon] = yield promiseAddonsByIDs(["bug596336-1@tests.mozilla.org"]);
- yield check_addon(aAddon, "1.0");
- ok(!aAddon.userDisabled, "Add-on should not be disabled");
+add_test(function() {
+ install_addon("browser_bug596336_1", function() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
+ check_addon(aAddon, "1.0");
+ ok(!aAddon.userDisabled, "Add-on should not be disabled");
+
+ install_addon("browser_bug596336_2", function() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
+ check_addon(aAddon, "2.0");
+ ok(!aAddon.userDisabled, "Add-on should not be disabled");
- yield install_addon("browser_bug596336_2");
- [aAddon] = yield promiseAddonsByIDs(["bug596336-1@tests.mozilla.org"]);
- yield check_addon(aAddon, "2.0");
- ok(!aAddon.userDisabled, "Add-on should not be disabled");
+ aAddon.uninstall();
- aAddon.uninstall();
+ is(get_list_item_count(), 0, "Should be no items in the list");
- is(get_list_item_count(), 0, "Should be no items in the list");
+ run_next_test();
+ });
+ });
+ });
+ });
});
// Install version 1 mark it as disabled then upgrade to version 2 with the
// manager open
-add_task(function*() {
- yield install_addon("browser_bug596336_1");
- let [aAddon] = yield promiseAddonsByIDs(["bug596336-1@tests.mozilla.org"]);
- aAddon.userDisabled = true;
- yield check_addon(aAddon, "1.0");
- ok(aAddon.userDisabled, "Add-on should be disabled");
+add_test(function() {
+ install_addon("browser_bug596336_1", function() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
+ aAddon.userDisabled = true;
+ check_addon(aAddon, "1.0");
+ ok(aAddon.userDisabled, "Add-on should be disabled");
+
+ install_addon("browser_bug596336_2", function() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
+ check_addon(aAddon, "2.0");
+ ok(aAddon.userDisabled, "Add-on should be disabled");
- yield install_addon("browser_bug596336_2");
- [aAddon] = yield promiseAddonsByIDs(["bug596336-1@tests.mozilla.org"]);
- yield check_addon(aAddon, "2.0");
- ok(aAddon.userDisabled, "Add-on should be disabled");
+ aAddon.uninstall();
- aAddon.uninstall();
+ is(get_list_item_count(), 0, "Should be no items in the list");
- is(get_list_item_count(), 0, "Should be no items in the list");
+ run_next_test();
+ });
+ });
+ });
+ });
});
// Install version 1 click the remove button and then upgrade to version 2 with
// the manager open
-add_task(function*() {
- yield install_addon("browser_bug596336_1");
- let [aAddon] = yield promiseAddonsByIDs(["bug596336-1@tests.mozilla.org"]);
- yield check_addon(aAddon, "1.0");
- ok(!aAddon.userDisabled, "Add-on should not be disabled");
+add_test(function() {
+ install_addon("browser_bug596336_1", function() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
+ check_addon(aAddon, "1.0");
+ ok(!aAddon.userDisabled, "Add-on should not be disabled");
- let item = get_addon_element(gManagerWindow, "bug596336-1@tests.mozilla.org");
- EventUtils.synthesizeMouseAtCenter(get_node(item, "remove-btn"), { }, gManagerWindow);
+ let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
+ EventUtils.synthesizeMouseAtCenter(get_node(item, "remove-btn"), { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
- is_element_visible(get_class_node(item, "pending"), "Pending message should be visible");
+ ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
+ is_element_visible(get_class_node(item, "pending"), "Pending message should be visible");
- yield install_addon("browser_bug596336_2");
- [aAddon] = yield promiseAddonsByIDs(["bug596336-1@tests.mozilla.org"]);
- yield check_addon(aAddon, "2.0");
- ok(!aAddon.userDisabled, "Add-on should not be disabled");
+ install_addon("browser_bug596336_2", function() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
+ check_addon(aAddon, "2.0");
+ ok(!aAddon.userDisabled, "Add-on should not be disabled");
- aAddon.uninstall();
+ aAddon.uninstall();
- is(get_list_item_count(), 0, "Should be no items in the list");
+ is(get_list_item_count(), 0, "Should be no items in the list");
+
+ run_next_test();
+ });
+ });
+ });
+ });
});
// Install version 1, disable it, click the remove button and then upgrade to
// version 2 with the manager open
-add_task(function*() {
- yield install_addon("browser_bug596336_1");
- let [aAddon] = yield promiseAddonsByIDs(["bug596336-1@tests.mozilla.org"]);
- aAddon.userDisabled = true;
- yield check_addon(aAddon, "1.0");
- ok(aAddon.userDisabled, "Add-on should be disabled");
+add_test(function() {
+ install_addon("browser_bug596336_1", function() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
+ aAddon.userDisabled = true;
+ check_addon(aAddon, "1.0");
+ ok(aAddon.userDisabled, "Add-on should be disabled");
- let item = get_addon_element(gManagerWindow, "bug596336-1@tests.mozilla.org");
- EventUtils.synthesizeMouseAtCenter(get_node(item, "remove-btn"), { }, gManagerWindow);
+ let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
+ EventUtils.synthesizeMouseAtCenter(get_node(item, "remove-btn"), { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
- is_element_visible(get_class_node(item, "pending"), "Pending message should be visible");
+ ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
+ is_element_visible(get_class_node(item, "pending"), "Pending message should be visible");
- yield install_addon("browser_bug596336_2");
- [aAddon] = yield promiseAddonsByIDs(["bug596336-1@tests.mozilla.org"]);
- yield check_addon(aAddon, "2.0");
- ok(aAddon.userDisabled, "Add-on should be disabled");
+ install_addon("browser_bug596336_2", function() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
+ check_addon(aAddon, "2.0");
+ ok(aAddon.userDisabled, "Add-on should be disabled");
- aAddon.uninstall();
+ aAddon.uninstall();
- is(get_list_item_count(), 0, "Should be no items in the list");
-});
+ is(get_list_item_count(), 0, "Should be no items in the list");
-add_task(function end_test() {
- close_manager(gManagerWindow, finish);
+ run_next_test();
+ });
+ });
+ });
+ });
});