summaryrefslogtreecommitdiffstats
path: root/services/fxaccounts/tests/browser/browser_device_connected.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /services/fxaccounts/tests/browser/browser_device_connected.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--services/fxaccounts/tests/browser/browser_device_connected.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/services/fxaccounts/tests/browser/browser_device_connected.js b/services/fxaccounts/tests/browser/browser_device_connected.js
new file mode 100644
index 0000000000..8bee7f81f6
--- /dev/null
+++ b/services/fxaccounts/tests/browser/browser_device_connected.js
@@ -0,0 +1,48 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const { FxAccounts } = ChromeUtils.importESModule(
+ "resource://gre/modules/FxAccounts.sys.mjs"
+);
+
+const gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"].getService(
+ Ci.nsIObserver
+);
+const DEVICES_URL = "https://example.com/devices";
+
+add_setup(async function () {
+ const origManageDevicesURI = FxAccounts.config.promiseManageDevicesURI;
+ FxAccounts.config.promiseManageDevicesURI = () =>
+ Promise.resolve(DEVICES_URL);
+ setupMockAlertsService();
+
+ registerCleanupFunction(function () {
+ FxAccounts.config.promiseManageDevicesURI = origManageDevicesURI;
+ delete window.FxAccounts;
+ });
+});
+
+async function testDeviceConnected(deviceName) {
+ info("testDeviceConnected with deviceName=" + deviceName);
+ BrowserTestUtils.loadURIString(gBrowser.selectedBrowser, "about:mozilla");
+ await waitForDocLoadComplete();
+
+ let waitForTabPromise = BrowserTestUtils.waitForNewTab(gBrowser);
+
+ Services.obs.notifyObservers(null, "fxaccounts:device_connected", deviceName);
+
+ let tab = await waitForTabPromise;
+ Assert.ok("Tab successfully opened");
+
+ Assert.equal(tab.linkedBrowser.currentURI.spec, DEVICES_URL);
+
+ BrowserTestUtils.removeTab(tab);
+}
+
+add_task(async function () {
+ await testDeviceConnected("My phone");
+});
+
+add_task(async function () {
+ await testDeviceConnected(null);
+});