mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1369285 - update how we build the default sync device name. r=tcsc
MozReview-Commit-ID: 6eY8IzKg9kd --HG-- extra : rebase_source : ae321d48de0144c29fa4f40fd16a02c44539d795
This commit is contained in:
parent
7fa53cfeaa
commit
dc01c77702
@ -592,7 +592,7 @@ this.Utils = {
|
||||
// 'device' is defined on unix systems
|
||||
Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2).get("device") ||
|
||||
// hostname of the system, usually assigned by the user or admin
|
||||
Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2).get("host") ||
|
||||
Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService).myHostName ||
|
||||
// fall back on ua info string
|
||||
Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).oscpu;
|
||||
|
||||
|
@ -490,6 +490,8 @@ function promiseNextTick() {
|
||||
// Avoid an issue where `client.name2` containing unicode characters causes
|
||||
// a number of tests to fail, due to them assuming that we do not need to utf-8
|
||||
// encode or decode data sent through the mocked server (see bug 1268912).
|
||||
// We stash away the original implementation so test_utils_misc.js can test it.
|
||||
Utils._orig_getDefaultDeviceName = Utils.getDefaultDeviceName;
|
||||
Utils.getDefaultDeviceName = function() {
|
||||
return "Test device name";
|
||||
};
|
||||
|
29
services/sync/tests/unit/test_utils_misc.js
Normal file
29
services/sync/tests/unit/test_utils_misc.js
Normal file
@ -0,0 +1,29 @@
|
||||
_("Misc tests for utils.js");
|
||||
|
||||
add_test(function test_default_device_name() {
|
||||
// Note that head_helpers overrides getDefaultDeviceName - this test is
|
||||
// really just to ensure the actual implementation is sane - we can't
|
||||
// really check the value it uses is correct.
|
||||
// We are just hoping to avoid a repeat of bug 1369285.
|
||||
let def = Utils._orig_getDefaultDeviceName(); // make sure it doesn't throw.
|
||||
_("default value is " + def);
|
||||
ok(def.length > 0);
|
||||
|
||||
// This is obviously tied to the implementation, but we want early warning
|
||||
// if any of these things fail.
|
||||
// We really want one of these 2 to provide a value.
|
||||
let hostname = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2).get("device") ||
|
||||
Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService).myHostName;
|
||||
_("hostname is " + hostname);
|
||||
ok(hostname.length > 0);
|
||||
// the hostname should be in the default.
|
||||
ok(def.includes(hostname));
|
||||
// We expect the following to work as a fallback to the above.
|
||||
let fallback = Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).oscpu;
|
||||
_("UA fallback is " + fallback);
|
||||
ok(fallback.length > 0);
|
||||
// the fallback should not be in the default
|
||||
ok(!def.includes(fallback));
|
||||
|
||||
run_next_test();
|
||||
});
|
@ -30,6 +30,7 @@ support-files =
|
||||
[test_utils_json.js]
|
||||
[test_utils_lock.js]
|
||||
[test_utils_makeGUID.js]
|
||||
[test_utils_misc.js]
|
||||
[test_utils_notify.js]
|
||||
[test_utils_passphrase.js]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user