mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 880644 - [SMS/MMS] Auto suggestions returning incorrect results. r=bent
This commit is contained in:
parent
fb7e87fd57
commit
2028ac5d64
@ -885,11 +885,22 @@ ContactDB.prototype = {
|
||||
"Falling back to 'startsWith'.");
|
||||
}
|
||||
// not case sensitive
|
||||
let tmp = options.filterValue.toString().toLowerCase();
|
||||
let lowerCase = options.filterValue.toString().toLowerCase();
|
||||
if (key === "tel") {
|
||||
tmp = PhoneNumberUtils.normalize(tmp, /*numbersOnly*/ true);
|
||||
let origLength = lowerCase.length;
|
||||
let tmp = PhoneNumberUtils.normalize(lowerCase, /*numbersOnly*/ true);
|
||||
if (tmp.length != origLength) {
|
||||
let NON_SEARCHABLE_CHARS = /[^#+\*\d\s()-]/;
|
||||
// e.g. number "123". find with "(123)" but not with "123a"
|
||||
if (tmp === "" || NON_SEARCHABLE_CHARS.test(lowerCase)) {
|
||||
if (DEBUG) debug("Call continue!");
|
||||
continue;
|
||||
}
|
||||
lowerCase = tmp;
|
||||
}
|
||||
}
|
||||
let range = this._global.IDBKeyRange.bound(tmp, tmp + "\uFFFF");
|
||||
if (DEBUG) debug("lowerCase: " + lowerCase);
|
||||
let range = this._global.IDBKeyRange.bound(lowerCase, lowerCase + "\uFFFF");
|
||||
let index = store.index(key + "LowerCase");
|
||||
request = index.mozGetAll(range, limit);
|
||||
}
|
||||
|
@ -1425,6 +1425,78 @@ var steps = [
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
},
|
||||
function () {
|
||||
ok(true, "Testing numbersOnly search");
|
||||
createResult1 = new mozContact();
|
||||
createResult1.init({ givenName: ["aaaaaaaaa"], tel: [{ value: "1234567890"}]});
|
||||
req = navigator.mozContacts.save(createResult1);
|
||||
req.onsuccess = function () {
|
||||
ok(createResult1.id, "The contact now has an ID.");
|
||||
next();
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
},
|
||||
function () {
|
||||
ok(true, "Test numbersOnly search");
|
||||
var options = {filterBy: ["givenName", "tel"],
|
||||
filterOp: "contains",
|
||||
filterValue: "a"};
|
||||
req = mozContacts.find(options);
|
||||
req.onsuccess = function () {
|
||||
ok(req.result.length == 1, "1 Entry.");
|
||||
checkContacts(req.result[0], createResult1);
|
||||
next();
|
||||
}
|
||||
req.onerror = onFailure;
|
||||
},
|
||||
function () {
|
||||
ok(true, "Test numbersOnly search");
|
||||
var options = {filterBy: ["givenName", "tel"],
|
||||
filterOp: "contains",
|
||||
filterValue: "b"};
|
||||
req = mozContacts.find(options);
|
||||
req.onsuccess = function () {
|
||||
ok(req.result.length == 0, "0 Entries.");
|
||||
next();
|
||||
}
|
||||
req.onerror = onFailure;
|
||||
},
|
||||
function () {
|
||||
ok(true, "Test numbersOnly search");
|
||||
var options = {filterBy: ["givenName", "tel"],
|
||||
filterOp: "contains",
|
||||
filterValue: "1a"};
|
||||
req = mozContacts.find(options);
|
||||
req.onsuccess = function () {
|
||||
ok(req.result.length == 0, "0 Entries.");
|
||||
next();
|
||||
}
|
||||
req.onerror = onFailure;
|
||||
},
|
||||
function () {
|
||||
ok(true, "Test numbersOnly search");
|
||||
var options = {filterBy: ["givenName", "tel"],
|
||||
filterOp: "contains",
|
||||
filterValue: "1(23)"};
|
||||
req = mozContacts.find(options);
|
||||
req.onsuccess = function () {
|
||||
ok(req.result.length == 1, "1 Entry.");
|
||||
next();
|
||||
}
|
||||
req.onerror = onFailure;
|
||||
},
|
||||
function () {
|
||||
ok(true, "Test numbersOnly search");
|
||||
var options = {filterBy: ["givenName", "tel"],
|
||||
filterOp: "contains",
|
||||
filterValue: "1(23)a"};
|
||||
req = mozContacts.find(options);
|
||||
req.onsuccess = function () {
|
||||
ok(req.result.length == 0, "0 Entries.");
|
||||
next();
|
||||
}
|
||||
req.onerror = onFailure;
|
||||
},
|
||||
function () {
|
||||
ok(true, "Deleting database");
|
||||
req = mozContacts.clear()
|
||||
|
@ -92,9 +92,9 @@ this.PhoneNumberUtils = {
|
||||
return isPlain;
|
||||
},
|
||||
|
||||
normalize: function Normalize(aNumber) {
|
||||
var normalized = PhoneNumber.Normalize(aNumber);
|
||||
if (DEBUG) debug("normalize(" + aNumber + "): " + normalized);
|
||||
normalize: function Normalize(aNumber, aNumbersOnly) {
|
||||
var normalized = PhoneNumber.Normalize(aNumber, aNumbersOnly);
|
||||
if (DEBUG) debug("normalize(" + aNumber + "): " + normalized + ", " + aNumbersOnly);
|
||||
return normalized;
|
||||
}
|
||||
};
|
||||
|
@ -47,5 +47,8 @@ function ParseWithMcc(dial, mcc) {
|
||||
CantParseWithMcc("1234", 123);
|
||||
ParseWithMcc("4165555555", 302);
|
||||
|
||||
is(PhoneNumberUtils.normalize("123abc", true), "123", "NumbersOnly");
|
||||
is(PhoneNumberUtils.normalize("123abc", false), "123222", "NumbersOnly");
|
||||
|
||||
</script>
|
||||
</window>
|
||||
|
Loading…
Reference in New Issue
Block a user