Commit 58c970e5 authored by Romain Courteaud's avatar Romain Courteaud

[indexeddb] add compatibility with Firefox in private mode

parent ea9a9ec4
......@@ -24,8 +24,11 @@
"use strict";
/* Safari does not define DOMError */
/* + compat issue with private Firefox */
if (window.DOMError === undefined) {
window.DOMError = {};
window.DOMError = function FakeDOMError(message) {
this.message = message;
};
}
var util = {},
......
......@@ -43,10 +43,10 @@
/*jslint nomen: true */
/*global indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest,
DOMError, Set*/
DOMError, DOMException, Set*/
(function (indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest,
DOMError, Set) {
DOMError, DOMException, Set) {
"use strict";
// Read only as changing it can lead to data corruption
......@@ -145,7 +145,8 @@
canceller();
if ((error !== undefined) &&
(error.target instanceof IDBOpenDBRequest) &&
(error.target.error instanceof DOMError)) {
((error.target.error instanceof DOMError) ||
(error.target.error instanceof DOMException))) {
reject("Connection to: " + db_name + " failed: " +
error.target.error.message);
} else {
......@@ -709,4 +710,4 @@
jIO.addStorage("indexeddb", IndexedDBStorage);
}(indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest, DOMError,
Set));
DOMException, Set));
......@@ -20,10 +20,10 @@
/*jslint nomen: true */
/*global indexedDB, Blob, sinon, IDBDatabase,
IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange,
DOMException, Rusha*/
Rusha*/
(function (jIO, QUnit, indexedDB, Blob, sinon, IDBDatabase,
IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange,
DOMException, Rusha) {
Rusha) {
"use strict";
var test = QUnit.test,
stop = QUnit.stop,
......@@ -190,26 +190,17 @@
});
});
function startsWith(str, prefix) {
return str.substr(0, prefix.length) === prefix;
}
test("version decrease", function () {
var context = this;
expect(8);
expect(1);
return setupDBMigrationTest(context, {version: 3},
{version: 2}, function (evt) {
ok(evt.target.error instanceof DOMException);
equal(evt.target.error.name, 'VersionError');
ok(context.spy_open.calledOnce, "open count " +
context.spy_open.callCount);
equal(context.spy_open.firstCall.args[0], "jio:qunit",
"open first argument");
equal(context.spy_create_store.callCount, 0,
"createObjectStore count");
equal(context.spy_store.callCount, 0,
"objectStore count");
equal(context.spy_create_index.callCount, 0, "createIndex count");
equal(context.spy_delete_index.callCount, 0, "deleteIndex count");
{version: 2}, function (msg) {
ok(startsWith(msg, "Connection to: jio:qunit failed: "));
});
});
......@@ -2054,4 +2045,4 @@
}(jIO, QUnit, indexedDB, Blob, sinon, IDBDatabase,
IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange,
DOMException, Rusha));
Rusha));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment