From c7adbabdd50d9f2a5218d8fa9f7120203e04f0b5 Mon Sep 17 00:00:00 2001 From: Gregor Wagner Date: Tue, 7 Aug 2012 15:02:37 -0700 Subject: [PATCH] Bug 736883 - Contacts API: Add pictures. r=bent --- dom/contacts/ContactManager.js | 17 +- dom/contacts/tests/Makefile.in | 1 + dom/contacts/tests/test_contacts_basics.html | 2 - dom/contacts/tests/test_contacts_blobs.html | 324 ++++++++++++++++++ .../contacts/nsIDOMContactProperties.idl | 2 +- testing/mochitest/android.json | 1 + 6 files changed, 343 insertions(+), 4 deletions(-) create mode 100644 dom/contacts/tests/test_contacts_blobs.html diff --git a/dom/contacts/ContactManager.js b/dom/contacts/ContactManager.js index c9f9cb4ad648..04407ba06672 100644 --- a/dom/contacts/ContactManager.js +++ b/dom/contacts/ContactManager.js @@ -168,6 +168,21 @@ Contact.prototype = { } }; + function _checkBlobArray(aBlob) { + if (Array.isArray(aBlob)) { + for (let i = 0; i < aBlob.length; i++) { + if (typeof aBlob != 'object') { + return null; + } + if (!(aBlob[i] instanceof Components.interfaces.nsIDOMBlob)) { + return null; + } + } + return aBlob; + } + return null; + }; + this.name = _create(aProp.name) || null; this.honorificPrefix = _create(aProp.honorificPrefix) || null; this.givenName = _create(aProp.givenName) || null; @@ -185,7 +200,7 @@ Contact.prototype = { this.email = null; } - this.photo = _create(aProp.photo) || null; + this.photo = _checkBlobArray(aProp.photo) || null; this.url = _create(aProp.url) || null; this.category = _create(aProp.category) || null; diff --git a/dom/contacts/tests/Makefile.in b/dom/contacts/tests/Makefile.in index 9f53a7ccb2b8..3da19e6dfd90 100644 --- a/dom/contacts/tests/Makefile.in +++ b/dom/contacts/tests/Makefile.in @@ -17,6 +17,7 @@ DIRS = \ MOCHITEST_FILES = \ test_contacts_basics.html \ test_contacts_events.html \ + test_contacts_blobs.html \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/dom/contacts/tests/test_contacts_basics.html b/dom/contacts/tests/test_contacts_basics.html index 52f5d1f6584d..3d76dfcc9144 100644 --- a/dom/contacts/tests/test_contacts_basics.html +++ b/dom/contacts/tests/test_contacts_basics.html @@ -99,7 +99,6 @@ var properties2 = { jobTitle: ["boss", "superboss"], bday: new Date("1980, 12, 01"), note: "test note", - photo: ["pic1", "pic2"], category: ["cat1", "cat2"], url: ["www.1.com", "www.2.com"], anniversary: new Date("2000, 12, 01"), @@ -165,7 +164,6 @@ function checkContacts(contact1, contact2) { checkStr(contact1.familyName, contact2.familyName, "Same familyName"); checkStr(contact1.honorificSuffix, contact2.honorificSuffix, "Same honorificSuffix"); checkStr(contact1.nickname, contact2.nickname, "Same nickname"); - checkStr(contact1.photo, contact2.photo, "Same photo"); checkStr(contact1.url, contact2.url, "Same url"); checkStr(contact1.category, contact2.category, "Same category"); checkStr(contact1.org, contact2.org, "Same org"); diff --git a/dom/contacts/tests/test_contacts_blobs.html b/dom/contacts/tests/test_contacts_blobs.html new file mode 100644 index 000000000000..0c0d7b3a0121 --- /dev/null +++ b/dom/contacts/tests/test_contacts_blobs.html @@ -0,0 +1,324 @@ + + + + + Test for Bug {674720} WebContacts + + + + + + +Mozilla Bug {674720} +

+ +
+
+
+ + \ No newline at end of file diff --git a/dom/interfaces/contacts/nsIDOMContactProperties.idl b/dom/interfaces/contacts/nsIDOMContactProperties.idl index 082bad9575f1..c647b14dad85 100644 --- a/dom/interfaces/contacts/nsIDOMContactProperties.idl +++ b/dom/interfaces/contacts/nsIDOMContactProperties.idl @@ -54,7 +54,7 @@ interface nsIDOMContactProperties : nsISupports attribute jsval honorificSuffix; // DOMString[] attribute jsval nickname; // DOMString[] attribute jsval email; // ContactEmail[] - attribute jsval photo; // DOMString[] + attribute jsval photo; // nsIDOMBlob[] attribute jsval url; // DOMString[] attribute jsval category; // DOMString[] attribute jsval adr; // ContactAddress[] diff --git a/testing/mochitest/android.json b/testing/mochitest/android.json index e05cf49ce5fe..78dfa7924706 100644 --- a/testing/mochitest/android.json +++ b/testing/mochitest/android.json @@ -146,6 +146,7 @@ "dom/network/tests/test_network_basics.html": "", "dom/settings/tests/test_settings_events.html": "", "dom/settings/tests/test_settings_basics.html": "", + "dom/contacts/tests/test_contacts_blobs.html": "", "dom/contacts/tests/test_contacts_basics.html": "", "dom/contacts/tests/test_contacts_events.html": "", "dom/sms/tests/test_sms_basics.html": "",