summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-06-26 16:09:08 -0400
committerMatt A. Tobin <email@mattatobin.com>2018-06-26 16:09:08 -0400
commiteda567b364a06e9e63efb865a6b1c73f1cb5232e (patch)
tree912ab15d877f733318e2c0394713bca33b830547 /toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js
parent80eb356d57fc310cdf812cae63de30d6e56c1788 (diff)
downloadUXP-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/webextensions/test/xpcshell/test_provider_shutdown.js')
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js99
1 files changed, 0 insertions, 99 deletions
diff --git a/toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js b/toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js
deleted file mode 100644
index d210eb81d..000000000
--- a/toolkit/mozapps/webextensions/test/xpcshell/test_provider_shutdown.js
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Verify that we report shutdown status for Addon Manager providers
-// and AddonRepository correctly.
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
-// Make a mock AddonRepository that just lets us hang shutdown.
-// Needs two promises - one to let us know that AM has called shutdown,
-// and one for us to let AM know that shutdown is done.
-function mockAddonProvider(aName) {
- let mockProvider = {
- donePromise: null,
- doneResolve: null,
- doneReject: null,
- shutdownPromise: null,
- shutdownResolve: null,
-
- get name() {
- return aName;
- },
-
- shutdown() {
- this.shutdownResolve();
- return this.donePromise;
- },
- };
- mockProvider.donePromise = new Promise((resolve, reject) => {
- mockProvider.doneResolve = resolve;
- mockProvider.doneReject = reject;
- });
- mockProvider.shutdownPromise = new Promise((resolve, reject) => {
- mockProvider.shutdownResolve = resolve;
- });
- return mockProvider;
-}
-
-function run_test() {
- run_next_test();
-}
-
-// Helper to find a particular shutdown blocker's status in the JSON blob
-function findInStatus(aStatus, aName) {
- for (let {name, state} of aStatus.state) {
- if (name == aName) {
- return state;
- }
- }
- return null;
-}
-
-/*
- * Make sure we report correctly when an add-on provider or AddonRepository block shutdown
- */
-add_task(function* blockRepoShutdown() {
- // Reach into the AddonManager scope and inject our mock AddonRepository
- let realAddonRepo = AMscope.AddonRepository;
- // the mock provider behaves enough like AddonRepository for the purpose of this test
- let mockRepo = mockAddonProvider("Mock repo");
- AMscope.AddonRepository = mockRepo;
-
- let mockProvider = mockAddonProvider("Mock provider");
-
- startupManager();
- AddonManagerPrivate.registerProvider(mockProvider);
-
- // Start shutting the manager down
- let managerDown = promiseShutdownManager();
-
- // Wait for manager to call provider shutdown.
- yield mockProvider.shutdownPromise;
- // check AsyncShutdown state
- let status = MockAsyncShutdown.status();
- equal(findInStatus(status[0], "Mock provider"), "(none)");
- equal(status[1].name, "AddonRepository: async shutdown");
- equal(status[1].state, "pending");
- // let the provider finish
- mockProvider.doneResolve();
-
- // Wait for manager to call repo shutdown and start waiting for it
- yield mockRepo.shutdownPromise;
- // Check the shutdown state
- status = MockAsyncShutdown.status();
- equal(status[0].name, "AddonManager: Waiting for providers to shut down.");
- equal(status[0].state, "Complete");
- equal(status[1].name, "AddonRepository: async shutdown");
- equal(status[1].state, "in progress");
-
- // Now finish our shutdown, and wait for the manager to wrap up
- mockRepo.doneResolve();
- yield managerDown;
-
- // Check the shutdown state again
- status = MockAsyncShutdown.status();
- equal(status[0].name, "AddonRepository: async shutdown");
- equal(status[0].state, "done");
-});