diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-06-26 16:09:08 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-06-26 16:09:08 -0400 |
commit | eda567b364a06e9e63efb865a6b1c73f1cb5232e (patch) | |
tree | 912ab15d877f733318e2c0394713bca33b830547 /toolkit/mozapps/extensions/test/browser/browser_select_update.js | |
parent | 80eb356d57fc310cdf812cae63de30d6e56c1788 (diff) | |
download | UXP-eda567b364a06e9e63efb865a6b1c73f1cb5232e.tar UXP-eda567b364a06e9e63efb865a6b1c73f1cb5232e.tar.gz UXP-eda567b364a06e9e63efb865a6b1c73f1cb5232e.tar.lz UXP-eda567b364a06e9e63efb865a6b1c73f1cb5232e.tar.xz UXP-eda567b364a06e9e63efb865a6b1c73f1cb5232e.zip |
[AllAM] Remove Mozilla Tests
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_select_update.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/browser/browser_select_update.js | 181 |
1 files changed, 0 insertions, 181 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_select_update.js b/toolkit/mozapps/extensions/test/browser/browser_select_update.js deleted file mode 100644 index 58f1de687..000000000 --- a/toolkit/mozapps/extensions/test/browser/browser_select_update.js +++ /dev/null @@ -1,181 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// Tests the update part of the post-app-update dialog - -var gProvider; -var gWin; - -function waitForView(aView, aCallback) { - var view = gWin.document.getElementById(aView); - if (view.parentNode.selectedPanel == view) { - aCallback(); - return; - } - - view.addEventListener("ViewChanged", function() { - view.removeEventListener("ViewChanged", arguments.callee, false); - aCallback(); - }, false); -} - -function waitForClose(aCallback) { - gWin.addEventListener("unload", function() { - gWin.removeEventListener("unload", arguments.callee, false); - - aCallback(); - }, false); -} - -/** - * Creates 4 test add-ons. Two are disabled and two enabled. - */ -function setupUI(aFailDownloads, aFailInstalls, aCallback) { - if (gProvider) - gProvider.unregister(); - - gProvider = new MockProvider(); - - for (var i = 1; i < 5; i++) { - var addon = new MockAddon("test" + i + "@tests.mozilla.org", - "Test Add-on " + i, "extension"); - addon.version = "1.0"; - addon.userDisabled = (i > 2); - addon.appDisabled = false; - addon.isActive = !addon.userDisabled && !addon.appDisabled; - - addon.findUpdates = function(aListener, aReason, aAppVersion, aPlatformVersion) { - var newAddon = new MockAddon(this.id, this.name, "extension"); - newAddon.version = "2.0"; - var install = new MockInstall(this.name, this.type, newAddon); - install.existingAddon = this; - - install.install = function() { - this.state = AddonManager.STATE_DOWNLOADING; - this.callListeners("onDownloadStarted"); - - var self = this; - executeSoon(function() { - if (aFailDownloads) { - self.state = AddonManager.STATE_DOWNLOAD_FAILED; - self.callListeners("onDownloadFailed"); - return; - } - - self.type = self._type; - self.addon = new MockAddon(self.existingAddon.id, self.name, self.type); - self.addon.version = self.version; - self.addon.pendingOperations = AddonManager.PENDING_INSTALL; - self.addon.install = self; - - self.existingAddon.pendingUpgrade = self.addon; - self.existingAddon.pendingOperations |= AddonManager.PENDING_UPGRADE; - - self.state = AddonManager.STATE_DOWNLOADED; - self.callListeners("onDownloadEnded"); - - self.state = AddonManager.STATE_INSTALLING; - self.callListeners("onInstallStarted"); - - if (aFailInstalls) { - self.state = AddonManager.STATE_INSTALL_FAILED; - self.callListeners("onInstallFailed"); - return; - } - - self.state = AddonManager.STATE_INSTALLED; - self.callListeners("onInstallEnded"); - }); - } - - aListener.onUpdateAvailable(this, install); - - aListener.onUpdateFinished(this, AddonManager.UPDATE_STATUS_NO_ERROR); - }; - - gProvider.addAddon(addon); - } - - gWin = Services.ww.openWindow(null, - "chrome://mozapps/content/extensions/selectAddons.xul", - "", - "chrome,centerscreen,dialog,titlebar", - null); - waitForFocus(function() { - waitForView("select", function() { - var row = gWin.document.getElementById("select-rows").firstChild.nextSibling; - while (row) { - if (!row.id || row.id.indexOf("@tests.mozilla.org") < 0) { - // not a test add-on - row = row.nextSibling; - continue; - } - - if (row.id == "test2@tests.mozilla.org" || - row.id == "test4@tests.mozilla.org") { - row.disable(); - } - else { - row.keep(); - } - row = row.nextSibling; - } - - waitForView("confirm", function() { - waitForView("update", aCallback); - EventUtils.synthesizeMouseAtCenter(gWin.document.getElementById("next"), {}, gWin); - }); - EventUtils.synthesizeMouseAtCenter(gWin.document.getElementById("next"), {}, gWin); - }); - }, gWin); -} - -function test() { - waitForExplicitFinish(); - run_next_test(); -} - -function end_test() { - finish(); -} - -// Test for working updates -add_test(function working_test() { - setupUI(false, false, function() { - waitForClose(function() { - is(gWin.document.getElementById("update-progress").value, 2, "Should have finished 2 downloads"); - run_next_test(); - }); - - EventUtils.synthesizeMouseAtCenter(gWin.document.getElementById("next"), {}, gWin); - }); -}); - -// Test for failed updates -add_test(function working_test() { - setupUI(true, false, function() { - waitForView("errors", function() { - is(gWin.document.getElementById("update-progress").value, 2, "Should have finished 2 downloads"); - gWin.close(); - - run_next_test(); - }); - - EventUtils.synthesizeMouseAtCenter(gWin.document.getElementById("next"), {}, gWin); - }); -}); - -// Test for failed updates -add_test(function working_test() { - setupUI(false, true, function() { - waitForView("errors", function() { - is(gWin.document.getElementById("update-progress").value, 2, "Should have finished 2 downloads"); - gWin.close(); - - run_next_test(); - }); - - EventUtils.synthesizeMouseAtCenter(gWin.document.getElementById("next"), {}, gWin); - }); -}); |