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" // Controls whether this client can send and receive "close tab"
// commands from other FxA clients // 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 // Controls whether or not the client association ping has values set on it
// when the sync-ui-state:update notification fires. // when the sync-ui-state:update notification fires.

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

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

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

@ -15,6 +15,12 @@ const { getRemoteCommandStore, RemoteCommand } = ChromeUtils.importESModule(
"resource://services-sync/TabsStore.sys.mjs" "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 { class TelemetryMock {
constructor() { constructor() {
this._events = []; this._events = [];
@ -56,21 +62,37 @@ add_task(async function test_closetab_isDeviceCompatible() {
"https://identity.mozilla.com/cmd/close-uri/v1": "payload", "https://identity.mozilla.com/cmd/close-uri/v1": "payload",
}, },
}; };
// Even though the command is available, we're keeping this feature behind a feature // The feature should be on by default
// 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
);
Assert.ok(closeTab.isDeviceCompatible(device)); 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( Services.prefs.clearUserPref(
"identity.fxaccounts.commands.remoteTabManagement.enabled" "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() { add_task(async function test_closetab_send() {

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

@ -3346,6 +3346,20 @@ bounceTrackingProtection:
the feature without risking data loss. Telemetry is still collected the feature without risking data loss. Telemetry is still collected
normally. 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: crlite:
description: Prefs that control the use of CRLite description: Prefs that control the use of CRLite
owner: jschanck@mozilla.com owner: jschanck@mozilla.com