--- a/browser/components/loop/GoogleImporter.jsm
+++ b/browser/components/loop/GoogleImporter.jsm
@@ -446,17 +446,17 @@ this.GoogleImporter.prototype = {
// Process telephone numbers.
let phoneNodes = entry.getElementsByTagNameNS(kNS_GD, "phoneNumber");
if (phoneNodes.length) {
contact.tel = [];
for (let [,phoneNode] of Iterator(phoneNodes)) {
contact.tel.push({
pref: (phoneNode.getAttribute("primary") == "true"),
type: [getFieldType(phoneNode)],
- value: phoneNode.firstChild.nodeValue
+ value: phoneNode.getAttribute("uri").replace("tel:", "")
});
}
}
let orgNodes = entry.getElementsByTagNameNS(kNS_GD, "organization");
if (orgNodes.length) {
contact.org = [];
contact.jobTitle = [];
@@ -496,17 +496,17 @@ this.GoogleImporter.prototype = {
try {
email = getPreferred(contact);
} catch (ex) {}
if (email) {
contact.name = [email.value];
} else {
let tel;
try {
- tel = getPreferred(contact, "phone");
+ tel = getPreferred(contact, "tel");
} catch (ex) {}
if (tel) {
contact.name = [tel.value];
}
}
}
}
}
--- a/browser/components/loop/test/mochitest/browser_GoogleImporter.js
+++ b/browser/components/loop/test/mochitest/browser_GoogleImporter.js
@@ -18,60 +18,68 @@ function promiseImport() {
}
add_task(function* test_GoogleImport() {
let stats;
// An error may throw and the test will fail when that happens.
stats = yield promiseImport();
// Assert the world.
- Assert.equal(stats.total, 5, "Five contacts should get processed");
- Assert.equal(stats.success, 5, "Five contacts should be imported");
+ Assert.equal(stats.total, 6, "Five contacts should get processed");
+ Assert.equal(stats.success, 6, "Five contacts should be imported");
yield promiseImport();
- Assert.equal(Object.keys(mockDb._store).length, 5, "Database should contain only five contact after reimport");
+ Assert.equal(Object.keys(mockDb._store).length, 6, "Database should contain only five contact after reimport");
- let c = mockDb._store[mockDb._next_guid - 5];
+ let c = mockDb._store[mockDb._next_guid - 6];
Assert.equal(c.name[0], "John Smith", "Full name should match");
Assert.equal(c.givenName[0], "John", "Given name should match");
Assert.equal(c.familyName[0], "Smith", "Family name should match");
Assert.equal(c.email[0].type, "other", "Email type should match");
Assert.equal(c.email[0].value, "john.smith@example.com", "Email should match");
Assert.equal(c.email[0].pref, true, "Pref should match");
Assert.equal(c.category[0], "google", "Category should match");
Assert.equal(c.id, "http://www.google.com/m8/feeds/contacts/tester%40mochi.com/base/0", "UID should match and be scoped to provider");
- c = mockDb._store[mockDb._next_guid - 4];
+ c = mockDb._store[mockDb._next_guid - 5];
Assert.equal(c.name[0], "Jane Smith", "Full name should match");
Assert.equal(c.givenName[0], "Jane", "Given name should match");
Assert.equal(c.familyName[0], "Smith", "Family name should match");
Assert.equal(c.email[0].type, "other", "Email type should match");
Assert.equal(c.email[0].value, "jane.smith@example.com", "Email should match");
Assert.equal(c.email[0].pref, true, "Pref should match");
Assert.equal(c.category[0], "google", "Category should match");
Assert.equal(c.id, "http://www.google.com/m8/feeds/contacts/tester%40mochi.com/base/1", "UID should match and be scoped to provider");
- c = mockDb._store[mockDb._next_guid - 3];
+ c = mockDb._store[mockDb._next_guid - 4];
Assert.equal(c.name[0], "Davy Randall Jones", "Full name should match");
Assert.equal(c.givenName[0], "Davy Randall", "Given name should match");
Assert.equal(c.familyName[0], "Jones", "Family name should match");
Assert.equal(c.email[0].type, "other", "Email type should match");
Assert.equal(c.email[0].value, "davy.jones@example.com", "Email should match");
Assert.equal(c.email[0].pref, true, "Pref should match");
Assert.equal(c.category[0], "google", "Category should match");
Assert.equal(c.id, "http://www.google.com/m8/feeds/contacts/tester%40mochi.com/base/2", "UID should match and be scoped to provider");
- c = mockDb._store[mockDb._next_guid - 2];
+ c = mockDb._store[mockDb._next_guid - 3];
Assert.equal(c.name[0], "noname@example.com", "Full name should match");
Assert.equal(c.email[0].type, "other", "Email type should match");
Assert.equal(c.email[0].value, "noname@example.com", "Email should match");
Assert.equal(c.email[0].pref, true, "Pref should match");
Assert.equal(c.category[0], "google", "Category should match");
Assert.equal(c.id, "http://www.google.com/m8/feeds/contacts/tester%40mochi.com/base/3", "UID should match and be scoped to provider");
- c = mockDb._store[mockDb._next_guid - 1];
+ c = mockDb._store[mockDb._next_guid - 2];
Assert.equal(c.name[0], "lycnix", "Full name should match");
Assert.equal(c.email[0].type, "other", "Email type should match");
Assert.equal(c.email[0].value, "lycnix", "Email should match");
Assert.equal(c.email[0].pref, true, "Pref should match");
Assert.equal(c.category[0], "google", "Category should match");
Assert.equal(c.id, "http://www.google.com/m8/feeds/contacts/tester%40mochi.com/base/7", "UID should match and be scoped to provider");
+
+ c = mockDb._store[mockDb._next_guid - 1];
+ Assert.equal(c.name[0], "+31-6-12345678", "Full name should match");
+ Assert.equal(c.tel[0].type, "mobile", "Email type should match");
+ Assert.equal(c.tel[0].value, "+31-6-12345678", "Email should match");
+ Assert.equal(c.tel[0].pref, false, "Pref should match");
+ Assert.equal(c.category[0], "google", "Category should match");
+ Assert.equal(c.id, "http://www.google.com/m8/feeds/contacts/tester%40mochi.com/base/8", "UID should match and be scoped to provider");
});