mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 784099 - Contacts API is not saving contacts. r=fabrice
This commit is contained in:
parent
0da94251f3
commit
ab32c56f22
@ -67,6 +67,14 @@ function ContactAddress(aType, aStreetAddress, aLocality, aRegion, aPostalCode,
|
||||
};
|
||||
|
||||
ContactAddress.prototype = {
|
||||
__exposedProps__: {
|
||||
type: 'rw',
|
||||
streetAddress: 'rw',
|
||||
locality: 'rw',
|
||||
region: 'rw',
|
||||
postalCode: 'rw',
|
||||
countryName: 'rw'
|
||||
},
|
||||
|
||||
classID : CONTACTADDRESS_CID,
|
||||
classInfo : XPCOMUtils.generateCI({classID: CONTACTADDRESS_CID,
|
||||
@ -90,6 +98,10 @@ function ContactField(aType, aValue) {
|
||||
};
|
||||
|
||||
ContactField.prototype = {
|
||||
__exposedProps__: {
|
||||
type: 'rw',
|
||||
value: 'rw'
|
||||
},
|
||||
|
||||
classID : CONTACTFIELD_CID,
|
||||
classInfo : XPCOMUtils.generateCI({classID: CONTACTFIELD_CID,
|
||||
@ -114,6 +126,11 @@ function ContactTelField(aType, aValue, aCarrier) {
|
||||
};
|
||||
|
||||
ContactTelField.prototype = {
|
||||
__exposedProps__: {
|
||||
type: 'rw',
|
||||
value: 'rw',
|
||||
carrier: 'rw'
|
||||
},
|
||||
|
||||
classID : CONTACTTELFIELD_CID,
|
||||
classInfo : XPCOMUtils.generateCI({classID: CONTACTTELFIELD_CID,
|
||||
@ -157,7 +174,33 @@ const nsIDOMContact = Components.interfaces.nsIDOMContact;
|
||||
function Contact() { debug("Contact constr: "); this.wrappedJSObject = this; };
|
||||
|
||||
Contact.prototype = {
|
||||
|
||||
__exposedProps__: {
|
||||
id: 'rw',
|
||||
updated: 'rw',
|
||||
published: 'rw',
|
||||
name: 'rw',
|
||||
honorificPrefix: 'rw',
|
||||
givenName: 'rw',
|
||||
additionalName: 'rw',
|
||||
familyName: 'rw',
|
||||
honorificSuffix: 'rw',
|
||||
nickname: 'rw',
|
||||
email: 'rw',
|
||||
photo: 'rw',
|
||||
url: 'rw',
|
||||
category: 'rw',
|
||||
adr: 'rw',
|
||||
tel: 'rw',
|
||||
org: 'rw',
|
||||
jobTitle: 'rw',
|
||||
bday: 'rw',
|
||||
note: 'rw',
|
||||
impp: 'rw',
|
||||
anniversary: 'rw',
|
||||
sex: 'rw',
|
||||
genderIdentity: 'rw'
|
||||
},
|
||||
|
||||
init: function init(aProp) {
|
||||
// Accept non-array strings for DOMString[] properties and convert them.
|
||||
function _create(aField) {
|
||||
@ -321,9 +364,9 @@ ContactManager.prototype = {
|
||||
_convertContactsArray: function(aContacts) {
|
||||
let contacts = new Array();
|
||||
for (let i in aContacts) {
|
||||
let newContact = Components.classes['@mozilla.org/contact;1'].createInstance();
|
||||
let newContact = new Contact();
|
||||
newContact.init(aContacts[i].properties);
|
||||
this._setMetaData(newContact.wrappedJSObject, aContacts[i]);
|
||||
this._setMetaData(newContact, aContacts[i]);
|
||||
contacts.push(newContact);
|
||||
}
|
||||
return contacts;
|
||||
@ -339,7 +382,6 @@ ContactManager.prototype = {
|
||||
let req = this.getRequest(msg.requestID);
|
||||
if (req) {
|
||||
let result = this._convertContactsArray(contacts);
|
||||
debug("result: " + JSON.stringify(result));
|
||||
Services.DOMRequest.fireSuccess(req.request, result);
|
||||
} else {
|
||||
debug("no request stored!" + msg.requestID);
|
||||
|
@ -92,7 +92,7 @@ var properties2 = {
|
||||
honorificSuffix: "dummyHonorificSuffix",
|
||||
additionalName: "dummyadditionalName",
|
||||
nickname: "dummyNickname",
|
||||
tel: [{type: ["test"], value: "123456789"},{type: ["home", "custom"], value: "234567890"}],
|
||||
tel: [{type: ["test"], value: "123456789", carrier: "myCarrier"},{type: ["home", "custom"], value: "234567890"}],
|
||||
email: [{type: ["test"], value: "a@b.c"}, {value: "b@c.d"}],
|
||||
adr: [adr1, adr2],
|
||||
impp: [{type: ["aim"], value:"im1"}, {value: "im2"}],
|
||||
@ -154,8 +154,8 @@ function checkTel(tel1, tel2) {
|
||||
}
|
||||
|
||||
function checkField(field1, field2) {
|
||||
checkStr(field1.type, field1.type, "Same type");
|
||||
checkStr(field1.value, field1.value, "Same value");
|
||||
checkStr(field1.type, field2.type, "Same type");
|
||||
checkStr(field1.value, field2.value, "Same value");
|
||||
}
|
||||
|
||||
function checkContacts(contact1, contact2) {
|
||||
@ -312,6 +312,20 @@ var steps = [
|
||||
findResult1 = req.result[0];
|
||||
ok(findResult1.id == sample_id1, "Same ID");
|
||||
checkContacts(createResult1, properties1);
|
||||
dump("findResult: " + JSON.stringify(findResult1) + "\n");
|
||||
// Some manual testing. Testint the testfunctions
|
||||
// tel: [{type: ["work"], value: "123456", carrier: "testCarrier"} , {type: ["home", "fax"], value: "+9-876-5432"}],
|
||||
is(findResult1.tel[0].carrier, "testCarrier", "Same Carrier");
|
||||
is(findResult1.tel[0].type, "work", "Same type");
|
||||
is(findResult1.tel[0].value, "123456", "Same Value");
|
||||
is(findResult1.tel[1].type[1], "fax", "Same type");
|
||||
is(findResult1.tel[1].value, "+9-876-5432", "Same Value");
|
||||
|
||||
is(findResult1.adr[0].countryName, "country 1", "Same country");
|
||||
|
||||
// email: [{type: ["work"], value: "x@y.com"}]
|
||||
is(findResult1.email[0].type, "work", "Same Type");
|
||||
is(findResult1.email[0].value, "x@y.com", "Same Value");
|
||||
next();
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
|
Loading…
Reference in New Issue
Block a user