Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
Prevent a Deferred from firing twice when an IndexedDB version change…
Browse files Browse the repository at this point in the history
… is blocked.

R=nweiz
DELTA=10  (8 added, 0 deleted, 2 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=5769


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2271 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information
tbreisacher@google.com committed Nov 5, 2012
1 parent b1a9a81 commit 00c7300
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions closure/goog/db/indexeddb.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,18 @@ goog.db.IndexedDb.prototype.setVersion = function(version) {
d.callback(new goog.db.Transaction(ev.target.result));
};
request.onerror = function(ev) {
d.errback(new goog.db.Error(ev.target.errorCode, 'setting version'));
// If a version change is blocked, onerror and onblocked may both fire.
// Check d.hasFired() to avoid an AlreadyCalledError.
if (!d.hasFired()) {
d.errback(new goog.db.Error(ev.target.errorCode, 'setting version'));
}
};
request.onblocked = function(ev) {
d.errback(new goog.db.Error.VersionChangeBlockedError());
// If a version change is blocked, onerror and onblocked may both fire.
// Check d.hasFired() to avoid an AlreadyCalledError.
if (!d.hasFired()) {
d.errback(new goog.db.Error.VersionChangeBlockedError());
}
};
return d;
};
Expand Down

0 comments on commit 00c7300

Please sign in to comment.