summaryrefslogtreecommitdiffstats
path: root/toolkit/components/normandy/test/browser/browser_CleanupManager.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /toolkit/components/normandy/test/browser/browser_CleanupManager.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/normandy/test/browser/browser_CleanupManager.js')
-rw-r--r--toolkit/components/normandy/test/browser/browser_CleanupManager.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/toolkit/components/normandy/test/browser/browser_CleanupManager.js b/toolkit/components/normandy/test/browser/browser_CleanupManager.js
new file mode 100644
index 0000000000..7ea9e25364
--- /dev/null
+++ b/toolkit/components/normandy/test/browser/browser_CleanupManager.js
@@ -0,0 +1,26 @@
+"use strict";
+
+const { CleanupManager } = ChromeUtils.import(
+ "resource://normandy/lib/CleanupManager.jsm"
+); /* global CleanupManagerClass */
+
+add_task(async function testCleanupManager() {
+ const spy1 = sinon.spy();
+ const spy2 = sinon.spy();
+ const spy3 = sinon.spy();
+
+ const manager = new CleanupManager.constructor();
+ manager.addCleanupHandler(spy1);
+ manager.addCleanupHandler(spy2);
+ manager.addCleanupHandler(spy3);
+ manager.removeCleanupHandler(spy2); // Test removal
+
+ await manager.cleanup();
+ ok(spy1.called, "cleanup called the spy1 handler");
+ ok(!spy2.called, "cleanup did not call the spy2 handler");
+ ok(spy3.called, "cleanup called the spy3 handler");
+
+ await manager.cleanup();
+ ok(spy1.calledOnce, "cleanup only called the spy1 handler once");
+ ok(spy3.calledOnce, "cleanup only called the spy3 handler once");
+});