summaryrefslogtreecommitdiffstats
path: root/remote/shared/listeners/test/browser/browser_ContextualIdentityListener.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--remote/shared/listeners/test/browser/browser_ContextualIdentityListener.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/remote/shared/listeners/test/browser/browser_ContextualIdentityListener.js b/remote/shared/listeners/test/browser/browser_ContextualIdentityListener.js
new file mode 100644
index 0000000000..df783a5688
--- /dev/null
+++ b/remote/shared/listeners/test/browser/browser_ContextualIdentityListener.js
@@ -0,0 +1,38 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const { ContextualIdentityListener } = ChromeUtils.importESModule(
+ "chrome://remote/content/shared/listeners/ContextualIdentityListener.sys.mjs"
+);
+
+add_task(async function test_createdOnNewContextualIdentity() {
+ const listener = new ContextualIdentityListener();
+ const created = listener.once("created");
+
+ listener.startListening();
+
+ ContextualIdentityService.create("test_name");
+
+ const { identity } = await created;
+ is(identity.name, "test_name", "Received expected identity");
+
+ listener.stopListening();
+
+ ContextualIdentityService.remove(identity.userContextId);
+});
+
+add_task(async function test_deletedOnRemovedContextualIdentity() {
+ const listener = new ContextualIdentityListener();
+ const deleted = listener.once("deleted");
+
+ listener.startListening();
+
+ const testIdentity = ContextualIdentityService.create("test_name");
+ ContextualIdentityService.remove(testIdentity.userContextId);
+
+ const { identity } = await deleted;
+ is(identity.name, "test_name", "Received expected identity");
+
+ listener.stopListening();
+});