mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 10:33:33 +00:00
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:
parent
4ac6763bca
commit
9ea55f75c4
@ -117,7 +117,7 @@ var gSync = {
|
|||||||
);
|
);
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
this,
|
this,
|
||||||
"SYNC_ENABLED",
|
"FXA_ENABLED",
|
||||||
"identity.fxaccounts.enabled"
|
"identity.fxaccounts.enabled"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -141,8 +141,8 @@ var gSync = {
|
|||||||
|
|
||||||
this._definePrefGetters();
|
this._definePrefGetters();
|
||||||
|
|
||||||
if (!this.SYNC_ENABLED) {
|
if (!this.FXA_ENABLED) {
|
||||||
this.onSyncDisabled();
|
this.onFxaDisabled();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ var gSync = {
|
|||||||
if (gSync.sendTabConfiguredAndLoading) {
|
if (gSync.sendTabConfiguredAndLoading) {
|
||||||
bodyNode.setAttribute("state", "notready");
|
bodyNode.setAttribute("state", "notready");
|
||||||
}
|
}
|
||||||
if (reloadDevices) {
|
if (reloadDevices && UIState.get().syncEnabled) {
|
||||||
// Force a background Sync
|
// Force a background Sync
|
||||||
Services.tm.dispatchToMainThread(async () => {
|
Services.tm.dispatchToMainThread(async () => {
|
||||||
// `engines: []` = clients engine only + refresh FxA Devices.
|
// `engines: []` = clients engine only + refresh FxA Devices.
|
||||||
@ -1032,8 +1032,8 @@ var gSync = {
|
|||||||
// can lead to a empty label for 'Send To Device' Menu.
|
// can lead to a empty label for 'Send To Device' Menu.
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
if (!this.SYNC_ENABLED) {
|
if (!this.FXA_ENABLED) {
|
||||||
// These items are hidden in onSyncDisabled(). No need to do anything.
|
// These items are hidden in onFxaDisabled(). No need to do anything.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let hasASendableURI = false;
|
let hasASendableURI = false;
|
||||||
@ -1064,7 +1064,7 @@ var gSync = {
|
|||||||
|
|
||||||
// "Send Page to Device" and "Send Link to Device" menu items
|
// "Send Page to Device" and "Send Link to Device" menu items
|
||||||
updateContentContextMenu(contextMenu) {
|
updateContentContextMenu(contextMenu) {
|
||||||
if (!this.SYNC_ENABLED) {
|
if (!this.FXA_ENABLED) {
|
||||||
// These items are hidden by default. No need to do anything.
|
// These items are hidden by default. No need to do anything.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1205,6 +1205,8 @@ var gSync = {
|
|||||||
if (!UIState.isReady()) {
|
if (!UIState.isReady()) {
|
||||||
return;
|
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();
|
const state = UIState.get();
|
||||||
if (state.status == UIState.STATUS_SIGNED_IN) {
|
if (state.status == UIState.STATUS_SIGNED_IN) {
|
||||||
this.updateSyncStatus({ syncing: true });
|
this.updateSyncStatus({ syncing: true });
|
||||||
@ -1338,7 +1340,7 @@ var gSync = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onSyncDisabled() {
|
onFxaDisabled() {
|
||||||
const toHide = [...document.querySelectorAll(".sync-ui-item")];
|
const toHide = [...document.querySelectorAll(".sync-ui-item")];
|
||||||
for (const item of toHide) {
|
for (const item of toHide) {
|
||||||
item.hidden = true;
|
item.hidden = true;
|
||||||
|
@ -311,8 +311,8 @@ add_task(async function test_page_contextmenu_login_failed() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_page_contextmenu_fxa_disabled() {
|
add_task(async function test_page_contextmenu_fxa_disabled() {
|
||||||
const getter = sinon.stub(gSync, "SYNC_ENABLED").get(() => false);
|
const getter = sinon.stub(gSync, "FXA_ENABLED").get(() => false);
|
||||||
gSync.onSyncDisabled(); // Would have been called on gSync initialization if SYNC_ENABLED had been set.
|
gSync.onFxaDisabled(); // Would have been called on gSync initialization if FXA_ENABLED had been set.
|
||||||
await openContentContextMenu("#moztext");
|
await openContentContextMenu("#moztext");
|
||||||
is(
|
is(
|
||||||
document.getElementById("context-sendpagetodevice").hidden,
|
document.getElementById("context-sendpagetodevice").hidden,
|
||||||
|
@ -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() {
|
add_task(async function test_tab_contextmenu_fxa_disabled() {
|
||||||
const getter = sinon.stub(gSync, "SYNC_ENABLED").get(() => false);
|
const getter = sinon.stub(gSync, "FXA_ENABLED").get(() => false);
|
||||||
// Simulate onSyncDisabled() being called on window open.
|
// Simulate onFxaDisabled() being called on window open.
|
||||||
gSync.onSyncDisabled();
|
gSync.onFxaDisabled();
|
||||||
|
|
||||||
updateTabContextMenu(testTab);
|
updateTabContextMenu(testTab);
|
||||||
is(
|
is(
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
add_task(async function test_policy_disable_fxaccounts() {
|
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({
|
await setupPolicyEngineWithJson({
|
||||||
policies: {
|
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.");
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user