Bug 882777 - Contacts API: Fix Date and pref properties. r=reuben

This commit is contained in:
Gregor Wagner 2013-06-13 15:43:30 -07:00
parent 867e55f074
commit 13a679b1dd
2 changed files with 10 additions and 8 deletions

View File

@ -88,7 +88,8 @@ ContactAddress.prototype = {
locality: 'rw',
region: 'rw',
postalCode: 'rw',
countryName: 'rw'
countryName: 'rw',
pref: 'rw'
},
classID : CONTACTADDRESS_CID,
@ -116,7 +117,8 @@ function ContactField(aType, aValue, aPref) {
ContactField.prototype = {
__exposedProps__: {
type: 'rw',
value: 'rw'
value: 'rw',
pref: 'rw'
},
classID : CONTACTFIELD_CID,
@ -146,7 +148,8 @@ ContactTelField.prototype = {
__exposedProps__: {
type: 'rw',
value: 'rw',
carrier: 'rw'
carrier: 'rw',
pref: 'rw'
},
classID : CONTACTTELFIELD_CID,
@ -417,7 +420,7 @@ Contact.prototype = {
},
set bday(aBday) {
if (aBday instanceof Date) {
if (aBday && aBday.constructor.name === "Date") {
this._bday = aBday;
} else if (typeof aBday === "string" || typeof aBday === "number") {
this._bday = new Date(aBday);
@ -429,7 +432,7 @@ Contact.prototype = {
},
set anniversary(aAnniversary) {
if (aAnniversary instanceof Date) {
if (aAnniversary && aAnniversary.constructor.name === "Date") {
this._anniversary = aAnniversary;
} else if (typeof aAnniversary === "string" || typeof aAnniversary === "number") {
this._anniversary = new Date(aAnniversary);

View File

@ -162,7 +162,6 @@ function checkAddress(adr1, adr2) {
ok(false, "Expected both adrs to be either present or absent");
return;
}
dump("adr1: " + adr1 + ", adr2: " + adr2 + "\n");
checkStrArray(adr1.type, adr2.type, "Same type");
checkStrArray(adr1.streetAddress, adr2.streetAddress, "Same streetAddress");
checkStrArray(adr1.locality, adr2.locality, "Same locality");
@ -350,7 +349,6 @@ 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: "+55 (31) 9876-3456"}],
is(findResult1.tel[0].carrier, "testCarrier", "Same Carrier");
@ -910,9 +908,10 @@ var steps = [
},
function () {
ok(true, "Retrieving all contacts");
req = mozContacts.find({})
req = mozContacts.find({sortBy: 'FamilyName',})
req.onsuccess = function () {
is(req.result.length, 2, "Found exactly 2 contact.");
checkContacts(properties2, req.result[1]);
next();
}
req.onerror = onFailure;