diff --git a/browser/components/loop/GoogleImporter.jsm b/browser/components/loop/GoogleImporter.jsm
index 56e5cbe545ff..fb8680c14892 100644
--- a/browser/components/loop/GoogleImporter.jsm
+++ b/browser/components/loop/GoogleImporter.jsm
@@ -448,10 +448,13 @@ this.GoogleImporter.prototype = {
if (phoneNodes.length) {
contact.tel = [];
for (let [,phoneNode] of Iterator(phoneNodes)) {
+ let phoneNumber = phoneNode.hasAttribute("uri") ?
+ phoneNode.getAttribute("uri").replace("tel:", "") :
+ phoneNode.firstChild.nodeValue;
contact.tel.push({
pref: (phoneNode.getAttribute("primary") == "true"),
type: [getFieldType(phoneNode)],
- value: phoneNode.getAttribute("uri").replace("tel:", "")
+ value: phoneNumber
});
}
}
diff --git a/browser/components/loop/test/mochitest/browser_GoogleImporter.js b/browser/components/loop/test/mochitest/browser_GoogleImporter.js
index 00bdebdb5625..d0f0a100fde3 100644
--- a/browser/components/loop/test/mochitest/browser_GoogleImporter.js
+++ b/browser/components/loop/test/mochitest/browser_GoogleImporter.js
@@ -17,19 +17,25 @@ function promiseImport() {
});
}
+const kContactsCount = 7;
+
add_task(function* test_GoogleImport() {
let stats;
// An error may throw and the test will fail when that happens.
stats = yield promiseImport();
+ let contactsCount = mockDb.size;
+
// Assert the world.
- Assert.equal(stats.total, 6, "Five contacts should get processed");
- Assert.equal(stats.success, 6, "Five contacts should be imported");
+ Assert.equal(stats.total, contactsCount, "Five contacts should get processed");
+ Assert.equal(stats.success, contactsCount, "Five contacts should be imported");
yield promiseImport();
- Assert.equal(Object.keys(mockDb._store).length, 6, "Database should contain only five contact after reimport");
+ Assert.equal(Object.keys(mockDb._store).length, contactsCount, "Database should be the same size after reimport");
- let c = mockDb._store[mockDb._next_guid - 6];
+ let currentContact = contactsCount;
+
+ let c = mockDb._store[mockDb._next_guid - currentContact];
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");
@@ -39,7 +45,7 @@ add_task(function* test_GoogleImport() {
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 - 5];
+ c = mockDb._store[mockDb._next_guid - (--currentContact)];
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");
@@ -49,7 +55,7 @@ add_task(function* test_GoogleImport() {
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 - 4];
+ c = mockDb._store[mockDb._next_guid - (--currentContact)];
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");
@@ -59,7 +65,7 @@ add_task(function* test_GoogleImport() {
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 - 3];
+ c = mockDb._store[mockDb._next_guid - (--currentContact)];
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");
@@ -67,7 +73,7 @@ add_task(function* test_GoogleImport() {
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 - 2];
+ c = mockDb._store[mockDb._next_guid - (--currentContact)];
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");
@@ -75,11 +81,19 @@ add_task(function* test_GoogleImport() {
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];
+ c = mockDb._store[mockDb._next_guid - (--currentContact)];
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].type, "mobile", "Phone type should match");
+ Assert.equal(c.tel[0].value, "+31-6-12345678", "Phone 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");
+
+ c = mockDb._store[mockDb._next_guid - (--currentContact)];
+ Assert.equal(c.name[0], "215234523452345", "Full name should match");
+ Assert.equal(c.tel[0].type, "mobile", "Phone type should match");
+ Assert.equal(c.tel[0].value, "215234523452345", "Phone 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/6", "UID should match and be scoped to provider");
});
diff --git a/browser/components/loop/test/mochitest/fixtures/google_contacts.txt b/browser/components/loop/test/mochitest/fixtures/google_contacts.txt
index a3a0588d5626..3783db51eb7d 100644
--- a/browser/components/loop/test/mochitest/fixtures/google_contacts.txt
+++ b/browser/components/loop/test/mochitest/fixtures/google_contacts.txt
@@ -102,4 +102,16 @@
0612345678
+
+ http://www.google.com/m8/feeds/contacts/tester%40mochi.com/base/6
+ 2014-10-17T12:32:08.152Z
+ 2014-10-17T12:32:08.152Z
+
+
+
+
+
+ 215234523452345
+
+
diff --git a/browser/components/loop/test/mochitest/head.js b/browser/components/loop/test/mochitest/head.js
index 7ae7f1bfaadf..c98b8164b606 100644
--- a/browser/components/loop/test/mochitest/head.js
+++ b/browser/components/loop/test/mochitest/head.js
@@ -218,6 +218,10 @@ const mockDb = {
_store: { },
_next_guid: 1,
+ get size() {
+ return Object.getOwnPropertyNames(this._store).length;
+ },
+
add: function(details, callback) {
if (!("id" in details)) {
callback(new Error("No 'id' field present"));