Bug 818507 - Importing SIM contacts stays stuck on spinner. r=gal

This commit is contained in:
Gregor Wagner 2012-12-05 20:03:27 -08:00
parent 5b4f9109b2
commit 17f90acec3
2 changed files with 48 additions and 3 deletions

View File

@ -104,9 +104,23 @@ this.PhoneNumber = (function (dataBase) {
// of type object, because they were already resolved (parsed into
// an object), and their country code should have been in the cache.
if (Array.isArray(entry)) {
for (var n = 0; n < entry.length; ++n) {
if (typeof entry[n] == "string" && entry[n].substr(2,2) == region)
return entry[n] = ParseMetaData(countryCode, entry[n]);
for (var n = 0; n < entry.length; n++) {
if (typeof entry[n] == "string" && entry[n].substr(2,2) == region) {
if (n > 0) {
// Only the first entry has the formats field set.
// Parse the main country if we haven't already and use
// the formats field from the main country.
if (typeof entry[0] == "string" && entry[0].substr(2,2) == region)
entry[0] = ParseMetaData(countryCode, entry[0]);
let formats = entry[0].formats;
let current = ParseMetaData(countryCode, entry[n]);
current.formats = formats;
return entry[n] = current;
}
entry[n] = ParseMetaData(countryCode, entry[n]);
return entry[n];
}
}
continue;
}

View File

@ -42,6 +42,17 @@ function Parse(dial, currentRegion) {
return result;
}
function ParseWithIntl(dial, currentRegion) {
var result = PhoneNumber.Parse(dial, currentRegion);
if (!result) {
ok(false, "got: " + dial + " " + currentRegion);
} else {
ok(result.internationalNumber, "Has International!");
ok(true, "Parses!\n");
}
return result;
}
function Test(dial, currentRegion, nationalNumber, region) {
var result = Parse(dial, currentRegion);
if (result.region != region || result.nationalNumber != nationalNumber) {
@ -124,6 +135,26 @@ Parse("+52 1 33 1234-5678", "MX");
Parse("044 (33) 1234-5678", "MX");
Parse("045 33 1234-5678", "MX");
ParseWithIntl("4031234567", "CA");
Parse("(416) 585-4319", "CA");
Parse("647-967-4357", "CA");
Parse("416-716-8768", "CA");
Parse("18002684646", "CA");
Parse("416-445-9119", "CA");
Parse("1-800-668-6866", "CA");
Parse("(416) 453-6486", "CA");
Parse("(647) 268-4778", "CA");
Parse("647-218-1313", "CA");
Parse("+1 647-209-4642", "CA");
Parse("416-559-0133", "CA");
Parse("+1 647-639-4118", "CA");
Parse("+12898803664", "CA");
Parse("780-901-4687", "CA");
Parse("+14167070550", "CA");
Parse("+1-647-522-6487", "CA");
Parse("(416) 877-0880", "CA");
// Test that lots of spaces are ok.
Parse("0 3 3 3 1 6 0 0 5", "NZ");