Bug 1583414 - don't attempt to refresh the FxA device list if sync's not configured. r=eoger

Differential Revision: https://phabricator.services.mozilla.com/D46889

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Hammond 2019-09-25 04:31:20 +00:00
parent 4ac6763bca
commit 9ea55f75c4
4 changed files with 17 additions and 15 deletions

View File

@ -117,7 +117,7 @@ var gSync = {
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"SYNC_ENABLED",
"FXA_ENABLED",
"identity.fxaccounts.enabled"
);
},
@ -141,8 +141,8 @@ var gSync = {
this._definePrefGetters();
if (!this.SYNC_ENABLED) {
this.onSyncDisabled();
if (!this.FXA_ENABLED) {
this.onFxaDisabled();
return;
}
@ -313,7 +313,7 @@ var gSync = {
if (gSync.sendTabConfiguredAndLoading) {
bodyNode.setAttribute("state", "notready");
}
if (reloadDevices) {
if (reloadDevices && UIState.get().syncEnabled) {
// Force a background Sync
Services.tm.dispatchToMainThread(async () => {
// `engines: []` = clients engine only + refresh FxA Devices.
@ -1032,8 +1032,8 @@ var gSync = {
// can lead to a empty label for 'Send To Device' Menu.
this.init();
if (!this.SYNC_ENABLED) {
// These items are hidden in onSyncDisabled(). No need to do anything.
if (!this.FXA_ENABLED) {
// These items are hidden in onFxaDisabled(). No need to do anything.
return;
}
let hasASendableURI = false;
@ -1064,7 +1064,7 @@ var gSync = {
// "Send Page to Device" and "Send Link to Device" menu items
updateContentContextMenu(contextMenu) {
if (!this.SYNC_ENABLED) {
if (!this.FXA_ENABLED) {
// These items are hidden by default. No need to do anything.
return;
}
@ -1205,6 +1205,8 @@ var gSync = {
if (!UIState.isReady()) {
return;
}
// Note we don't bother checking if sync is actually enabled - none of the
// UI which calls this function should be visible in that case.
const state = UIState.get();
if (state.status == UIState.STATUS_SIGNED_IN) {
this.updateSyncStatus({ syncing: true });
@ -1338,7 +1340,7 @@ var gSync = {
}
},
onSyncDisabled() {
onFxaDisabled() {
const toHide = [...document.querySelectorAll(".sync-ui-item")];
for (const item of toHide) {
item.hidden = true;

View File

@ -311,8 +311,8 @@ add_task(async function test_page_contextmenu_login_failed() {
});
add_task(async function test_page_contextmenu_fxa_disabled() {
const getter = sinon.stub(gSync, "SYNC_ENABLED").get(() => false);
gSync.onSyncDisabled(); // Would have been called on gSync initialization if SYNC_ENABLED had been set.
const getter = sinon.stub(gSync, "FXA_ENABLED").get(() => false);
gSync.onFxaDisabled(); // Would have been called on gSync initialization if FXA_ENABLED had been set.
await openContentContextMenu("#moztext");
is(
document.getElementById("context-sendpagetodevice").hidden,

View File

@ -177,9 +177,9 @@ add_task(async function test_tab_contextmenu_sync_not_ready_other_state() {
});
add_task(async function test_tab_contextmenu_fxa_disabled() {
const getter = sinon.stub(gSync, "SYNC_ENABLED").get(() => false);
// Simulate onSyncDisabled() being called on window open.
gSync.onSyncDisabled();
const getter = sinon.stub(gSync, "FXA_ENABLED").get(() => false);
// Simulate onFxaDisabled() being called on window open.
gSync.onFxaDisabled();
updateTabContextMenu(testTab);
is(

View File

@ -4,7 +4,7 @@
"use strict";
add_task(async function test_policy_disable_fxaccounts() {
is(gSync.SYNC_ENABLED, true, "Sync is enabled before setting the policy.");
is(gSync.FXA_ENABLED, true, "Sync is enabled before setting the policy.");
await setupPolicyEngineWithJson({
policies: {
@ -12,5 +12,5 @@ add_task(async function test_policy_disable_fxaccounts() {
},
});
is(gSync.SYNC_ENABLED, false, "Sync is disabled after setting the policy.");
is(gSync.FXA_ENABLED, false, "Sync is disabled after setting the policy.");
});