Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 0cf92bf

Browse files
author
leo.bugzilla.gecko@gmail.com
committed
Bug 852057 - Sort contacts correctly when givenName or familyName is null. r=gwagner
1 parent 211e118 commit 0cf92bf

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

dom/contacts/fallback/ContactDB.jsm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ ContactDB.prototype = {
581581
xIndex++;
582582
}
583583
if (!x) {
584-
return sortOrder == 'ascending' ? 1 : -1;
584+
return sortOrder == 'descending' ? 1 : -1;
585585
}
586586
while (yIndex < sortBy.length && !y) {
587587
y = b.properties[sortBy[yIndex]] ? b.properties[sortBy[yIndex]][0].toLowerCase() : null;

dom/contacts/tests/test_contacts_basics.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
comp.utils.import("resource://gre/modules/PermissionPromptHelper.jsm");
2929
SpecialPowers.setBoolPref("dom.mozContacts.enabled", true);
3030
}
31-
31+
3232
SpecialPowers.addPermission("contacts-write", true, document);
3333
SpecialPowers.addPermission("contacts-read", true, document);
3434
SpecialPowers.addPermission("contacts-create", true, document);
@@ -140,8 +140,16 @@
140140
}
141141

142142
function checkStr(str1, str2, msg) {
143-
if (str1)
144-
ok(typeof str1 == "string" ? [str1] : str1, (typeof str2 == "string") ? [str2] : str2, msg);
143+
// comparing /[null(,null)+]/ and undefined should pass
144+
function nonNull(e) {
145+
return e != null;
146+
}
147+
if ((Array.isArray(str1) && str1.filter(nonNull).length == 0 && str2 == undefined)
148+
||(Array.isArray(str2) && str2.filter(nonNull).length == 0 && str1 == undefined)) {
149+
ok(true, msg);
150+
} else if (str1) {
151+
is(JSON.stringify(typeof str1 == "string" ? [str1] : str1), JSON.stringify(typeof str2 == "string" ? [str2] : str2), msg);
152+
}
145153
}
146154

147155
function checkAddress(adr1, adr2) {

0 commit comments

Comments
 (0)