commit 8edaac307780ea3c4eeaa9627ff26518013ed862
parent b7a062c68842e35187256b65a14faa4c9b27af8d
Author: Sammy Khamis <skhamis@mozilla.com>
Date: Thu, 4 Dec 2025 00:17:54 +0000
Bug 2003898 - Dont show connect another device button if no sync keys r=sync-reviewers,LougeniaBailey,markh
Differential Revision: https://phabricator.services.mozilla.com/D274987
Diffstat:
4 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/browser/base/content/browser-sync.js b/browser/base/content/browser-sync.js
@@ -1195,10 +1195,14 @@ var gSync = {
document,
"PanelUI-fxa-menu-setup-sync-container"
);
-
const fxaToolbarMenuButton = document.getElementById(
"fxa-toolbar-menu-button"
);
+ const syncSetupSeparator = PanelMultiView.getViewNode(
+ document,
+ "PanelUI-set-up-sync-separator"
+ );
+
let fxaAvatarLabelEl = document.getElementById("fxa-avatar-label");
// Reset FxA/Sync UI elements to default, which is signed out
@@ -1311,10 +1315,17 @@ var gSync = {
if (this._shouldShowSyncOffIndicator()) {
fxaToolbarMenuButton?.setAttribute("badge-status", "sync-disabled");
}
- // Show the sync element depending on if the user is enrolled or not
syncSetupEl.removeAttribute("hidden");
}
+ if (state.hasSyncKeys) {
+ cadButtonEl.removeAttribute("hidden");
+ syncSetupSeparator.removeAttribute("hidden");
+ } else {
+ cadButtonEl.setAttribute("hidden", "true");
+ syncSetupSeparator.setAttribute("hidden", "true");
+ }
+
// Reposition profiles elements
emptyProfilesButton.remove();
profilesButton.remove();
diff --git a/browser/base/content/test/sync/browser_sync.js b/browser/base/content/test/sync/browser_sync.js
@@ -790,6 +790,7 @@ add_task(async function test_new_sync_setup_ui() {
let state = {
status: UIState.STATUS_SIGNED_IN,
syncEnabled: false,
+ hasSyncKeys: true,
email: "foo@bar.com",
displayName: "Foo Bar",
avatarURL: "https://foo.bar",
@@ -839,6 +840,7 @@ add_task(async function test_ui_my_services_signedin() {
let state = {
status: UIState.STATUS_SIGNED_IN,
syncEnabled: true,
+ hasSyncKeys: true,
email: "foo@bar.com",
displayName: "Foo Bar",
avatarURL: "https://foo.bar",
diff --git a/services/sync/modules/UIState.sys.mjs b/services/sync/modules/UIState.sys.mjs
@@ -10,8 +10,11 @@
* @property {string} [avatarURL] The user's FxA avatar URL.
* @property {Date} [lastSync] The last sync time.
* @property {boolean} [syncing] Whether or not we are currently syncing.
+ * @property {boolean} [hasSyncKeys] Whether the user has sync keys available.
*/
+import { SCOPE_APP_SYNC } from "resource://gre/modules/FxAccountsCommon.sys.mjs";
+
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
LOGIN_FAILED_LOGIN_REJECTED: "resource://services-sync/constants.sys.mjs",
@@ -173,6 +176,8 @@ const UIStateInternal = {
state.avatarURL = userData.avatar;
state.avatarIsDefault = userData.avatarDefault;
state.syncEnabled = !!syncUserName;
+ state.hasSyncKeys =
+ await this.fxAccounts.keys.hasKeysForScope(SCOPE_APP_SYNC);
}
state.status = status;
},
diff --git a/services/sync/tests/unit/test_uistate.js b/services/sync/tests/unit/test_uistate.js
@@ -74,6 +74,7 @@ add_task(async function test_refreshState_signedin() {
hasLocalSession: () => Promise.resolve(true),
keys: {
canGetKeyForScope: () => Promise.resolve(true),
+ hasKeysForScope: () => Promise.resolve(true),
},
};
@@ -86,6 +87,7 @@ add_task(async function test_refreshState_signedin() {
equal(state.avatarURL, "https://foo/bar");
equal(state.lastSync, now);
equal(state.syncing, false);
+ equal(state.hasSyncKeys, true);
UIStateInternal.fxAccounts = fxAccountsOrig;
Services.prefs.clearUserPref("services.sync.username");
@@ -134,6 +136,7 @@ add_task(async function test_refreshState_signedin_profile_unavailable() {
hasLocalSession: () => Promise.resolve(true),
keys: {
canGetKeyForScope: () => Promise.resolve(true),
+ hasKeysForScope: () => Promise.resolve(true),
},
_internal: {
profile: {
@@ -216,6 +219,7 @@ add_task(async function test_refreshState_loginFailed() {
Promise.resolve({ verified: true, uid: "123", email: "foo@bar.com" }),
keys: {
canGetKeyForScope: () => Promise.resolve(true),
+ hasKeysForScope: () => Promise.resolve(true),
},
};
@@ -271,6 +275,7 @@ async function configureUIState(syncing, lastSync = new Date()) {
hasLocalSession: () => Promise.resolve(true),
keys: {
canGetKeyForScope: () => Promise.resolve(true),
+ hasKeysForScope: () => Promise.resolve(true),
},
};
await UIState.refresh();
@@ -343,6 +348,7 @@ add_task(async function test_refreshState_signedin_with_synckeys() {
hasLocalSession: () => Promise.resolve(true),
keys: {
canGetKeyForScope: () => Promise.resolve(true),
+ hasKeysForScope: () => Promise.resolve(true),
},
};
@@ -371,13 +377,16 @@ add_task(async function test_refreshState_third_party_auth_no_sync() {
email: "foo@bar.com",
}),
hasLocalSession: () => Promise.resolve(true),
- keys: {},
+ keys: {
+ hasKeysForScope: () => Promise.resolve(false),
+ },
};
let state = await UIState.refresh();
equal(state.status, UIState.STATUS_SIGNED_IN);
equal(state.syncEnabled, false);
+ equal(state.hasSyncKeys, false);
equal(state.uid, "123");
equal(state.email, "foo@bar.com");