Bug 1905974: Flip closing tabs remotely to default on r=markh

Differential Revision: https://phabricator.services.mozilla.com/D215570
This commit is contained in:
Sammy Khamis 2024-07-22 17:17:58 +00:00
Родитель 1360b6b248
Коммит 4805a2e7f8
4 изменённых файлов: 54 добавлений и 18 удалений

Просмотреть файл

@ -2043,7 +2043,7 @@ pref("identity.fxaccounts.commands.missed.fetch_interval", 86400);
// Controls whether this client can send and receive "close tab"
// commands from other FxA clients
pref("identity.fxaccounts.commands.remoteTabManagement.enabled", false);
pref("identity.fxaccounts.commands.remoteTabManagement.enabled", true);
// Controls whether or not the client association ping has values set on it
// when the sync-ui-state:update notification fires.

Просмотреть файл

@ -28,6 +28,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
getRemoteCommandStore: "resource://services-sync/TabsStore.sys.mjs",
RemoteCommand: "resource://services-sync/TabsStore.sys.mjs",
Utils: "resource://services-sync/util.sys.mjs",
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
});
XPCOMUtils.defineLazyPreferenceGetter(
@ -571,15 +572,14 @@ export class CloseRemoteTab extends Command {
}
}
// Returns true if the target device is compatible with closing a tab
// XXX - kill this - the pref check is for local stuff, not whether the device is capable!
// However, this means moving the pref check into the front-end UI code, which isn't ideal.
// Returns true if:
// - The target device is compatible with closing a tab (device capability) and
// - The local device has the feature enabled locally
isDeviceCompatible(device) {
let pref = Services.prefs.getBoolPref(
"identity.fxaccounts.commands.remoteTabManagement.enabled",
false
return (
lazy.NimbusFeatures.remoteTabManagement.getVariable("closeTabsEnabled") &&
super.isDeviceCompatible(device)
);
return pref && super.isDeviceCompatible(device);
}
// Handle incoming remote tab payload, called by FxAccountsCommands.

Просмотреть файл

@ -15,6 +15,12 @@ const { getRemoteCommandStore, RemoteCommand } = ChromeUtils.importESModule(
"resource://services-sync/TabsStore.sys.mjs"
);
ChromeUtils.defineESModuleGetters(this, {
ExperimentAPI: "resource://nimbus/ExperimentAPI.sys.mjs",
ExperimentFakes: "resource://testing-common/NimbusTestUtils.sys.mjs",
ExperimentManager: "resource://nimbus/lib/ExperimentManager.sys.mjs",
});
class TelemetryMock {
constructor() {
this._events = [];
@ -56,21 +62,37 @@ add_task(async function test_closetab_isDeviceCompatible() {
"https://identity.mozilla.com/cmd/close-uri/v1": "payload",
},
};
// Even though the command is available, we're keeping this feature behind a feature
// flag for now, so it should still show up as "not available"
Assert.ok(!closeTab.isDeviceCompatible(device));
// Enable the feature
Services.prefs.setBoolPref(
"identity.fxaccounts.commands.remoteTabManagement.enabled",
true
);
// The feature should be on by default
Assert.ok(closeTab.isDeviceCompatible(device));
// clear it for the next test
// Disable the feature
Services.prefs.setBoolPref(
"identity.fxaccounts.commands.remoteTabManagement.enabled",
false
);
Assert.ok(!closeTab.isDeviceCompatible(device));
// clear the pref to test overriding with nimbus
Services.prefs.clearUserPref(
"identity.fxaccounts.commands.remoteTabManagement.enabled"
);
Assert.ok(closeTab.isDeviceCompatible(device));
// Verify that nimbus can remotely override the pref
await ExperimentManager.onStartup();
await ExperimentAPI.ready();
let doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "remoteTabManagement",
// You can add values for each variable you added to the manifest
value: {
closeTabsEnabled: false,
},
});
// Feature successfully disabled
Assert.ok(!closeTab.isDeviceCompatible(device));
doExperimentCleanup();
});
add_task(async function test_closetab_send() {

Просмотреть файл

@ -3346,6 +3346,20 @@ bounceTrackingProtection:
the feature without risking data loss. Telemetry is still collected
normally.
remoteTabManagement:
description: >
Features that let users manage tabs on other devices that are
connected to the same Mozilla account.
owner: skhamis@mozilla.com
hasExposure: false
variables:
closeTabsEnabled:
description: >-
When true, the user can close tabs on other devices connected to
the same Mozilla account from the synced tabs menu.
type: boolean
fallbackPref: identity.fxaccounts.commands.remoteTabManagement.enabled
crlite:
description: Prefs that control the use of CRLite
owner: jschanck@mozilla.com