Skip to content
Snippets Groups Projects
Commit 09975522 authored by Eemeli Aro's avatar Eemeli Aro
Browse files

Bug 1831872 - Migrate client.name2 string from sync.properties to Fluent....

Bug 1831872 - Migrate client.name2 string from sync.properties to Fluent. r=markh,fluent-reviewers,geckoview-reviewers,sync-reviewers,flod,m_kato

As this is the only string in `services/`, let's simplify by moving it under `toolkit/` and removing `services/sync/locales/` as empty.

On advice from markh, the ON_NEW_DEVICE_ID notification is delayed during device registration & updates until the update has been written to storage.

Differential Revision: https://phabricator.services.mozilla.com/D178805
parent 849756d4
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 64 deletions
......@@ -51,7 +51,6 @@ l10n-%:
$(NSINSTALL) -D $(DIST)/install
@$(MAKE) -C ../themes/shared/app-marketplace-icons AB_CD=$* XPI_NAME=locale-$*
@$(MAKE) -C ../../toolkit/locales l10n-$* XPI_ROOT_APPID='$(XPI_ROOT_APPID)'
@$(MAKE) -C ../../services/sync/locales AB_CD=$* XPI_NAME=locale-$*
@$(MAKE) -C ../../extensions/spellcheck/locales AB_CD=$* XPI_NAME=locale-$*
ifneq (,$(wildcard ../extensions/formautofill/locales))
@$(MAKE) -C ../extensions/formautofill/locales AB_CD=$* XPI_NAME=locale-$*
......@@ -69,7 +68,6 @@ chrome-%:
$(if $(filter en-US,$(AB_CD)),, @$(MAKE) merge-$*)
@$(MAKE) -C ../themes/shared/app-marketplace-icons chrome AB_CD=$*
@$(MAKE) -C ../../toolkit/locales chrome-$*
@$(MAKE) -C ../../services/sync/locales chrome AB_CD=$*
@$(MAKE) -C ../../extensions/spellcheck/locales chrome AB_CD=$*
ifneq (,$(wildcard ../extensions/formautofill/locales))
@$(MAKE) -C ../extensions/formautofill/locales chrome AB_CD=$*
......
......@@ -19,7 +19,6 @@ dirs = browser
# non-central apps might want to use %(topsrcdir)s here, or other vars
# RFE: that needs to be supported by compare-locales, too, though
toolkit = toolkit/locales/l10n.ini
services_sync = services/sync/locales/l10n.ini
[extras]
dirs = extensions/spellcheck
......@@ -139,10 +139,6 @@ locales = [
reference = "browser/extensions/report-site-issue/locales/en-US/**"
l10n = "{l}browser/extensions/report-site-issue/**"
[[paths]]
reference = "services/sync/locales/en-US/**"
l10n = "{l}services/sync/**"
[[includes]]
path = "toolkit/locales/l10n.toml"
......
......@@ -15,4 +15,3 @@ dirs = mobile mobile/android
[includes]
toolkit = toolkit/locales/l10n.ini
services_sync = services/sync/locales/l10n.ini
......@@ -165,6 +165,10 @@ exclude-multi-locale = [
reference = "toolkit/locales/en-US/chrome/global/intl.css"
l10n = "{l}toolkit/chrome/global/intl.css"
[[paths]]
reference = "toolkit/locales/en-US/toolkit/services/*.ftl"
l10n = "{l}toolkit/services/*.ftl"
[[paths]]
reference = "toolkit/locales/en-US/toolkit/about/*Support.ftl"
l10n = "{l}toolkit/toolkit/about/*Support.ftl"
......
......@@ -16,4 +16,3 @@ dirs = mobile mobile/android
[includes]
toolkit = toolkit/locales/l10n.ini
services_sync = services/sync/locales/l10n.ini
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
import fluent.syntax.ast as FTL
from fluent.migrate.helpers import TERM_REFERENCE, VARIABLE_REFERENCE
from fluent.migrate.transforms import REPLACE
def migrate(ctx):
"""Bug 1831872 - Migrate sync.properties to Fluent, part {index}."""
source = "services/sync/sync.properties"
target = "toolkit/services/accounts.ftl"
ctx.add_transforms(
target,
target,
[
FTL.Message(
id=FTL.Identifier("account-client-name"),
value=REPLACE(
source,
"client.name2",
{
"%1$S": VARIABLE_REFERENCE("user"),
"%2$S": TERM_REFERENCE("brand-short-name"),
"%3$S": VARIABLE_REFERENCE("system"),
},
),
),
],
)
......@@ -96,17 +96,6 @@ export class FxAccountsDevice {
user = Services.env.get("USERNAME");
}
let brand = Services.strings.createBundle(
"chrome://branding/locale/brand.properties"
);
let brandName;
try {
brandName = brand.GetStringFromName("brandShortName");
} catch (O_o) {
// this only fails in tests and markh can't work out why :(
brandName = Services.appinfo.name;
}
// The DNS service may fail to provide a hostname in edge-cases we don't
// fully understand - bug 1391488.
let hostname;
......@@ -125,17 +114,12 @@ export class FxAccountsDevice {
Ci.nsIHttpProtocolHandler
).oscpu;
// It's a little unfortunate that this string is defined as being weave/sync,
// but it's not worth moving it.
let syncStrings = Services.strings.createBundle(
"chrome://weave/locale/sync.properties"
const l10n = new Localization(
["services/accounts.ftl", "branding/brand.ftl"],
true
);
return sanitizeDeviceName(
syncStrings.formatStringFromName("client.name2", [
user,
brandName,
system,
])
l10n.formatValueSync("account-client-name", { user, system })
);
}
......@@ -453,7 +437,8 @@ export class FxAccountsDevice {
log.info("registering with available commands", availableCommandsKeys);
let device;
if (currentDevice && currentDevice.id) {
let is_existing = currentDevice && currentDevice.id;
if (is_existing) {
log.debug("updating existing device details");
device = await this._fxai.fxAccountsClient.updateDevice(
sessionToken,
......@@ -469,7 +454,6 @@ export class FxAccountsDevice {
this.getLocalType(),
deviceOptions
);
Services.obs.notifyObservers(null, ON_NEW_DEVICE_ID);
}
// Get the freshest device props before updating them.
......@@ -484,6 +468,10 @@ export class FxAccountsDevice {
registeredCommandsKeys: availableCommandsKeys,
},
});
// Must send the notification after we've written the storage.
if (!is_existing) {
Services.obs.notifyObservers(null, ON_NEW_DEVICE_ID);
}
return device.id;
} catch (error) {
return this._handleDeviceError(currentState, error, sessionToken);
......
......@@ -16,7 +16,7 @@ add_task(
);
Assert.equal(
await FxAccounts.config.promiseConnectAccountURI("test"),
"http://example.com/?context=null&entrypoint=test&action=email&service=sync"
"http://example.com/?context=fx_desktop_v3&entrypoint=test&action=email&service=sync"
);
Services.prefs.clearUserPref("identity.fxaccounts.remote.root");
......
......@@ -8,10 +8,16 @@ const { getFxAccountsSingleton } = ChromeUtils.importESModule(
);
const fxAccounts = getFxAccountsSingleton();
const { PREF_ACCOUNT_ROOT } = ChromeUtils.import(
const { ON_NEW_DEVICE_ID, PREF_ACCOUNT_ROOT } = ChromeUtils.import(
"resource://gre/modules/FxAccountsCommon.js"
);
function promiseObserved(topic) {
return new Promise(res => {
Services.obs.addObserver(res, topic);
});
}
_("Misc tests for FxAccounts.device");
fxAccounts.device._checkRemoteCommandsUpdateNeeded = async () => false;
......@@ -85,6 +91,8 @@ add_task(async function test_reset() {
return { id: "foo" };
});
await fxAccounts._internal.setSignedInUser(credentials);
// wait for device registration to complete.
await promiseObserved(ON_NEW_DEVICE_ID);
ok(!Services.prefs.prefHasUserValue(testPref));
// signing the user out should reset the name pref.
const namePref = PREF_ACCOUNT_ROOT + "device.name";
......
......@@ -50,6 +50,11 @@ add_test(function () {
});
add_task(async function test_rejection_reporting() {
Services.prefs.setBoolPref(
"browser.tabs.remote.separatePrivilegedMozillaWebContentProcess",
false
);
let mockMessage = {
command: "fxaccounts:login",
messageId: "1234",
......
[DEFAULT]
head = head.js ../../../common/tests/unit/head_helpers.js ../../../common/tests/unit/head_http.js
firefox-appdir = browser
skip-if = (toolkit == 'android' || appname == 'thunderbird')
support-files =
!/services/common/tests/unit/head_helpers.js
......
#filter substitution
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@AB_CD@.jar:
% locale weave @AB_CD@ %locale/@AB_CD@/services/
locale/@AB_CD@/services/sync.properties (%sync.properties)
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
[general]
depth = ../../..
[compare]
dirs = services/sync
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
JAR_MANIFESTS += ["jar.mn"]
......@@ -7,8 +7,6 @@
with Files("**"):
BUG_COMPONENT = ("Firefox", "Sync")
DIRS += ["locales"]
XPCSHELL_TESTS_MANIFESTS += ["tests/unit/xpcshell.ini"]
EXTRA_COMPONENTS += [
......
......@@ -2,5 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# %1: the user name (Ed), %2: the app name (Firefox), %3: the operating system (Android)
client.name2 = %1$S’s %2$S on %3$S
# Variables:
# $user (String): the user name (e.g. "Ed")
# $system (String): the operating system (e.g. "Android")
account-client-name = { $user }’s { -brand-short-name } on { $system }
......@@ -5,6 +5,7 @@
[localization] @AB_CD@.jar:
crashreporter (%crashreporter/**/*.ftl)
services (%services/**/*.ftl)
toolkit (%toolkit/**/*.ftl)
locales-preview/aboutTranslations.ftl (../locales-preview/aboutTranslations.ftl)
#ifdef MOZ_LAYOUT_DEBUGGER
......
......@@ -39,7 +39,6 @@ codespell:
- remote/doc/
- security/manager/locales/en-US/
- services/settings/docs/
- services/sync/locales/en-US/
- taskcluster/docs/
- testing/docs/xpcshell/
- testing/geckodriver/doc/
......
......@@ -15,7 +15,6 @@ l10n:
- mobile/android/locales/en-US
- netwerk/locales/en-US
- security/manager/locales/en-US
- services/sync/locales/en-US
- toolkit/locales/en-US
- tools/lint/l10n.yml
# files not supported by compare-locales,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment