mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 939331 - [Datastore] onchange event is fired for clear operations, r=ehsan
This commit is contained in:
parent
9b47c5d062
commit
5ce4271c24
@ -293,12 +293,14 @@ this.DataStore.prototype = {
|
||||
|
||||
sendNotification: function(aId, aOperation, aRevisionId) {
|
||||
debug("SendNotification");
|
||||
if (aOperation != REVISION_VOID) {
|
||||
cpmm.sendAsyncMessage("DataStore:Changed",
|
||||
{ store: this.name, owner: this.owner,
|
||||
message: { revisionId: aRevisionId, id: aId,
|
||||
operation: aOperation } } );
|
||||
if (aOperation == REVISION_VOID) {
|
||||
aOperation = "cleared";
|
||||
}
|
||||
|
||||
cpmm.sendAsyncMessage("DataStore:Changed",
|
||||
{ store: this.name, owner: this.owner,
|
||||
message: { revisionId: aRevisionId, id: aId,
|
||||
operation: aOperation } } );
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
|
@ -61,10 +61,16 @@
|
||||
}, cbError);
|
||||
}
|
||||
|
||||
function testStoreClear() {
|
||||
gStore.clear().catch(cbError);
|
||||
}
|
||||
|
||||
function eventListener(evt) {
|
||||
ok(evt, "OnChangeListener is called with data");
|
||||
is(/[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}/.test(evt.revisionId), true, "event.revisionId returns something");
|
||||
is(evt.id, gChangeId, "OnChangeListener is called with the right ID: " + evt.id);
|
||||
if (gChangeId) {
|
||||
is(evt.id, gChangeId, "OnChangeListener is called with the right ID: " + evt.id);
|
||||
}
|
||||
is(evt.operation, gChangeOperation, "OnChangeListener is called with the right operation:" + evt.operation + " " + gChangeOperation);
|
||||
runTest();
|
||||
}
|
||||
@ -92,6 +98,10 @@
|
||||
function() { gChangeId = 1; gChangeOperation = 'removed';
|
||||
testStoreRemove(1, true); },
|
||||
|
||||
// Clear
|
||||
function() { gChangeId = 0; gChangeOperation = 'cleared';
|
||||
testStoreClear(); },
|
||||
|
||||
// Remove onchange function and replace it with addEventListener
|
||||
function() {
|
||||
gStore.onchange = null;
|
||||
@ -111,6 +121,10 @@
|
||||
function() { gChangeId = 2; gChangeOperation = 'removed';
|
||||
testStoreRemove(2, true); },
|
||||
|
||||
// Clear
|
||||
function() { gChangeId = 0; gChangeOperation = 'cleared';
|
||||
testStoreClear(); },
|
||||
|
||||
// Remove event listener
|
||||
function() {
|
||||
gStore.removeEventListener('change', eventListener);
|
||||
|
Loading…
Reference in New Issue
Block a user