зеркало из https://github.com/mozilla/gecko-dev.git
Merge birch to m-c.
This commit is contained in:
Коммит
53f8ae9a2b
|
@ -116,15 +116,40 @@ SpecialPowers.addPermission("sms", true, document);
|
|||
let sms = window.navigator.mozSms;
|
||||
ok(sms instanceof MozSmsManager);
|
||||
|
||||
function repeat(func, array, oncomplete) {
|
||||
(function do_call(index) {
|
||||
let next = index < (array.length - 1) ? do_call.bind(null, index + 1) : oncomplete;
|
||||
array[index].push(next);
|
||||
func.apply(null, array[index]);
|
||||
})(0);
|
||||
}
|
||||
let tasks = {
|
||||
// List of test fuctions. Each of them should call |tasks.next()| when
|
||||
// completed or |tasks.finish()| to jump to the last one.
|
||||
_tasks: [],
|
||||
_nextTaskIndex: 0,
|
||||
|
||||
function testStrict7BitEncodingHelper(sent, received, next) {
|
||||
push: function push(func) {
|
||||
this._tasks.push(func);
|
||||
},
|
||||
|
||||
next: function next() {
|
||||
let index = this._nextTaskIndex++;
|
||||
let task = this._tasks[index];
|
||||
try {
|
||||
task();
|
||||
} catch (ex) {
|
||||
ok(false, "test task[" + index + "] throws: " + ex);
|
||||
// Run last task as clean up if possible.
|
||||
if (index != this._tasks.length - 1) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
finish: function finish() {
|
||||
this._tasks[this._tasks.length - 1]();
|
||||
},
|
||||
|
||||
run: function run() {
|
||||
this.next();
|
||||
}
|
||||
};
|
||||
|
||||
function testStrict7BitEncodingHelper(sent, received) {
|
||||
// The log message contains unicode and Marionette seems unable to process
|
||||
// it and throws: |UnicodeEncodeError: 'ascii' codec can't encode character
|
||||
// u'\xa5' in position 14: ordinal not in range(128)|.
|
||||
|
@ -135,7 +160,7 @@ function testStrict7BitEncodingHelper(sent, received, next) {
|
|||
function done(step) {
|
||||
count += step;
|
||||
if (count >= 2) {
|
||||
window.setTimeout(next, 0);
|
||||
window.setTimeout(tasks.next.bind(tasks), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,53 +186,75 @@ function testStrict7BitEncodingHelper(sent, received, next) {
|
|||
});
|
||||
}
|
||||
|
||||
function test_enabled() {
|
||||
// Bug 877141 - If you send several spaces together in a sms, the other
|
||||
// dipositive receives a "*" for each space.
|
||||
//
|
||||
// This function is called twice, with strict 7bit encoding enabled or
|
||||
// disabled. Expect the same result in both sent and received text and with
|
||||
// either strict 7bit encoding enabled or disabled.
|
||||
function testBug877141() {
|
||||
log("Testing bug 877141");
|
||||
let sent = "1 2 3";
|
||||
testStrict7BitEncodingHelper(sent, sent);
|
||||
}
|
||||
|
||||
tasks.push(function () {
|
||||
log("Testing with dom.sms.strict7BitEncoding enabled");
|
||||
|
||||
SpecialPowers.setBoolPref("dom.sms.strict7BitEncoding", true);
|
||||
tasks.next();
|
||||
});
|
||||
|
||||
let cases = [];
|
||||
|
||||
// Test for combined string.
|
||||
// Test for combined string.
|
||||
tasks.push(function () {
|
||||
let sent = "", received = "";
|
||||
for (let c in GSM_SMS_STRICT_7BIT_CHARMAP) {
|
||||
sent += c;
|
||||
received += GSM_SMS_STRICT_7BIT_CHARMAP[c];
|
||||
}
|
||||
cases.push([sent, received]);
|
||||
testStrict7BitEncodingHelper(sent, received);
|
||||
});
|
||||
|
||||
// When strict7BitEncoding is enabled, we should replace characters that
|
||||
// can't be encoded with GSM 7-Bit alphabets with '*'.
|
||||
cases.push(["\u65b0\u5e74\u5feb\u6a02", "****"]); // "Happy New Year" in Chinese.
|
||||
// When strict7BitEncoding is enabled, we should replace characters that
|
||||
// can't be encoded with GSM 7-Bit alphabets with '*'.
|
||||
tasks.push(function () {
|
||||
// "Happy New Year" in Chinese.
|
||||
let sent = "\u65b0\u5e74\u5feb\u6a02", received = "****";
|
||||
testStrict7BitEncodingHelper(sent, received);
|
||||
});
|
||||
|
||||
repeat(testStrict7BitEncodingHelper, cases, test_disabled);
|
||||
}
|
||||
tasks.push(testBug877141);
|
||||
|
||||
function test_disabled() {
|
||||
tasks.push(function () {
|
||||
log("Testing with dom.sms.strict7BitEncoding disabled");
|
||||
|
||||
SpecialPowers.setBoolPref("dom.sms.strict7BitEncoding", false);
|
||||
tasks.next();
|
||||
});
|
||||
|
||||
let cases = [];
|
||||
|
||||
// Test for combined string.
|
||||
// Test for combined string.
|
||||
tasks.push(function () {
|
||||
let sent = "";
|
||||
for (let c in GSM_SMS_STRICT_7BIT_CHARMAP) {
|
||||
sent += c;
|
||||
}
|
||||
cases.push([sent, sent]);
|
||||
testStrict7BitEncodingHelper(sent, sent);
|
||||
});
|
||||
|
||||
cases.push(["\u65b0\u5e74\u5feb\u6a02", "\u65b0\u5e74\u5feb\u6a02"]);
|
||||
tasks.push(function () {
|
||||
// "Happy New Year" in Chinese.
|
||||
let sent = "\u65b0\u5e74\u5feb\u6a02";
|
||||
testStrict7BitEncodingHelper(sent, sent);
|
||||
});
|
||||
|
||||
repeat(testStrict7BitEncodingHelper, cases, cleanUp);
|
||||
}
|
||||
tasks.push(testBug877141);
|
||||
|
||||
function cleanUp() {
|
||||
// WARNING: All tasks should be pushed before this!!!
|
||||
tasks.push(function cleanUp() {
|
||||
SpecialPowers.removePermission("sms", document);
|
||||
SpecialPowers.clearUserPref("dom.sms.enabled");
|
||||
SpecialPowers.clearUserPref("dom.sms.strict7BitEncoding");
|
||||
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
test_enabled();
|
||||
tasks.run();
|
||||
|
|
|
@ -130,6 +130,13 @@ function isComplete(code) {
|
|||
return (type != NETD_COMMAND_PROCEEDING);
|
||||
}
|
||||
|
||||
function defineLazyRegExp(obj, name, pattern) {
|
||||
obj.__defineGetter__(name, function() {
|
||||
delete obj[name];
|
||||
return obj[name] = new RegExp(pattern);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This component watches for network interfaces changing state and then
|
||||
* adjusts routes etc. accordingly.
|
||||
|
@ -216,6 +223,10 @@ function NetworkManager() {
|
|||
});
|
||||
|
||||
ppmm.addMessageListener('NetworkInterfaceList:ListInterface', this);
|
||||
|
||||
// Used in resolveHostname().
|
||||
defineLazyRegExp(this, "REGEXP_IPV4", "^\\d{1,3}(?:\\.\\d{1,3}){3}$");
|
||||
defineLazyRegExp(this, "REGEXP_IPV6", "^[\\da-fA-F]{4}(?::[\\da-fA-F]{4}){7}$");
|
||||
}
|
||||
NetworkManager.prototype = {
|
||||
classID: NETWORKMANAGER_CID,
|
||||
|
@ -611,17 +622,25 @@ NetworkManager.prototype = {
|
|||
resolveHostname: function resolveHostname(hosts) {
|
||||
let retval = [];
|
||||
|
||||
for(var i = 0; i < hosts.length; i++) {
|
||||
let hostname = hosts[i].split('/')[2];
|
||||
if (!hostname) {
|
||||
for (let hostname of hosts) {
|
||||
try {
|
||||
let uri = Services.io.newURI(hostname, null, null);
|
||||
hostname = uri.host;
|
||||
} catch (e) {}
|
||||
|
||||
if (hostname.match(this.REGEXP_IPV4) ||
|
||||
hostname.match(this.REGEXP_IPV6)) {
|
||||
retval.push(hostname);
|
||||
continue;
|
||||
}
|
||||
|
||||
let hostnameIps = gDNSService.resolve(hostname, 0);
|
||||
while (hostnameIps.hasMore()) {
|
||||
retval.push(hostnameIps.getNextAddrAsString());
|
||||
debug("Found IP at: " + JSON.stringify(retval));
|
||||
}
|
||||
try {
|
||||
let hostnameIps = gDNSService.resolve(hostname, 0);
|
||||
while (hostnameIps.hasMore()) {
|
||||
retval.push(hostnameIps.getNextAddrAsString());
|
||||
debug("Found IP at: " + JSON.stringify(retval));
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -1166,7 +1166,7 @@ SetNiceForPid(int aPid, int aNice)
|
|||
}
|
||||
|
||||
int newtaskpriority =
|
||||
std::max(origtaskpriority + aNice - origProcPriority, origProcPriority);
|
||||
std::max(origtaskpriority - origProcPriority + aNice, aNice);
|
||||
rv = setpriority(PRIO_PROCESS, tid, newtaskpriority);
|
||||
|
||||
if (rv) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче