mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 963274 - Allow removing contacts by ID. r=gwagner
This commit is contained in:
parent
1a92335312
commit
dd066d6108
@ -391,14 +391,19 @@ ContactManager.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
remove: function removeContact(aRecord) {
|
||||
remove: function removeContact(aRecordOrId) {
|
||||
let request = this.createRequest();
|
||||
if (!aRecord || !aRecord.id) {
|
||||
let id;
|
||||
if (typeof aRecordOrId === "string") {
|
||||
id = aRecordOrId;
|
||||
} else if (!aRecordOrId || !aRecordOrId.id) {
|
||||
Services.DOMRequest.fireErrorAsync(request, true);
|
||||
return request;
|
||||
} else {
|
||||
id = aRecordOrId.id;
|
||||
}
|
||||
|
||||
let options = { id: aRecord.id };
|
||||
let options = { id: id };
|
||||
let allowCallback = function() {
|
||||
cpmm.sendAsyncMessage("Contact:Remove", {requestID: this.getRequestId({request: request, reason: "remove"}), options: options});
|
||||
}.bind(this);
|
||||
|
@ -800,6 +800,28 @@ var steps = [
|
||||
ok(!c.jobTitle, "jobTitle is not set");
|
||||
next();
|
||||
},
|
||||
function() {
|
||||
ok(true, "mozContacts.remove with an ID works");
|
||||
var c = new mozContact({name: ["Ephemeral Jimmy"]});
|
||||
req = navigator.mozContacts.save(c);
|
||||
req.onsuccess = function() {
|
||||
req = navigator.mozContacts.remove(c.id);
|
||||
req.onsuccess = function() {
|
||||
req = navigator.mozContacts.find({
|
||||
filterBy: ["id"],
|
||||
filterOp: "equals",
|
||||
filterValue: c.id
|
||||
});
|
||||
req.onsuccess = function() {
|
||||
ise(req.result.length, 0, "Successfully removed contact by ID");
|
||||
next();
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
},
|
||||
function () {
|
||||
ok(true, "all done!\n");
|
||||
SimpleTest.finish();
|
||||
|
@ -118,7 +118,7 @@ interface ContactManager : EventTarget {
|
||||
DOMCursor getAll(optional ContactFindSortOptions options);
|
||||
DOMRequest clear();
|
||||
DOMRequest save(mozContact contact);
|
||||
DOMRequest remove(mozContact contact);
|
||||
DOMRequest remove((mozContact or DOMString) contactOrId);
|
||||
DOMRequest getRevision();
|
||||
DOMRequest getCount();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user