Bug 1097222 - Extend client record format on desktop. r=markh

This commit is contained in:
Richard Newman 2014-11-17 19:06:00 -08:00
parent 1fbb76c595
commit 09fa8af5d3
2 changed files with 48 additions and 5 deletions

View File

@ -29,7 +29,11 @@ ClientsRec.prototype = {
ttl: CLIENTS_TTL
};
Utils.deferGetSet(ClientsRec, "cleartext", ["name", "type", "commands", "version", "protocols"]);
Utils.deferGetSet(ClientsRec,
"cleartext",
["name", "type", "commands",
"version", "protocols",
"formfactor", "os", "appPackage", "application", "device"]);
this.ClientEngine = function ClientEngine(service) {
@ -100,6 +104,11 @@ ClientEngine.prototype = {
},
set localID(value) Svc.Prefs.set("client.GUID", value),
get brandName() {
let brand = new StringBundle("chrome://branding/locale/brand.properties");
return brand.get("brandShortName");
},
get localName() {
let localName = Svc.Prefs.get("client.name", "");
if (localName != "")
@ -111,9 +120,8 @@ ClientEngine.prototype = {
let user = env.get("USER") || env.get("USERNAME") ||
Svc.Prefs.get("account") || Svc.Prefs.get("username");
let brandName = this.brandName;
let appName;
let brand = new StringBundle("chrome://branding/locale/brand.properties");
let brandName = brand.get("brandShortName");
try {
let syncStrings = new StringBundle("chrome://browser/locale/sync.properties");
appName = syncStrings.getFormattedString("sync.defaultAccountApplication", [brandName]);
@ -412,9 +420,18 @@ ClientStore.prototype = {
record.commands = this.engine.localCommands;
record.version = Services.appinfo.version;
record.protocols = SUPPORTED_PROTOCOL_VERSIONS;
}
else
// Optional fields.
record.os = Services.appinfo.OS; // "Darwin"
record.appPackage = Services.appinfo.ID;
record.application = this.engine.brandName // "Nightly"
// We can't compute these yet.
// record.device = ""; // Bug 1100723
// record.formfactor = ""; // Bug 1100722
} else {
record.cleartext = this._remoteClients[id];
}
return record;
},

View File

@ -577,6 +577,32 @@ add_test(function test_receive_display_uri() {
do_check_true(engine.processIncomingCommands());
});
add_test(function test_optional_client_fields() {
_("Ensure that we produce records with the fields added in Bug 1097222.");
const SUPPORTED_PROTOCOL_VERSIONS = ["1.1", "1.5"];
let local = engine._store.createRecord(engine.localID, "clients");
do_check_eq(local.name, engine.localName);
do_check_eq(local.type, engine.localType);
do_check_eq(local.version, Services.appinfo.version);
do_check_array_eq(local.protocols, SUPPORTED_PROTOCOL_VERSIONS);
// Optional fields.
// Make sure they're what they ought to be...
do_check_eq(local.os, Services.appinfo.OS);
do_check_eq(local.appPackage, Services.appinfo.ID);
// ... and also that they're non-empty.
do_check_true(!!local.os);
do_check_true(!!local.appPackage);
do_check_true(!!local.application);
// We don't currently populate device or formfactor.
// See Bug 1100722, Bug 1100723.
run_next_test();
});
function run_test() {
initTestLogging("Trace");
Log.repository.getLogger("Sync.Engine.Clients").level = Log.Level.Trace;