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

[indexeddb] add compatibility with Firefox in private mode

parent ea9a9ec4
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
"use strict"; "use strict";
/* Safari does not define DOMError */ /* Safari does not define DOMError */
/* + compat issue with private Firefox */
if (window.DOMError === undefined) { if (window.DOMError === undefined) {
window.DOMError = {}; window.DOMError = function FakeDOMError(message) {
this.message = message;
};
} }
var util = {}, var util = {},
......
...@@ -43,10 +43,10 @@ ...@@ -43,10 +43,10 @@
/*jslint nomen: true */ /*jslint nomen: true */
/*global indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest, /*global indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest,
DOMError, Set*/ DOMError, DOMException, Set*/
(function (indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest, (function (indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest,
DOMError, Set) { DOMError, DOMException, Set) {
"use strict"; "use strict";
// Read only as changing it can lead to data corruption // Read only as changing it can lead to data corruption
...@@ -145,7 +145,8 @@ ...@@ -145,7 +145,8 @@
canceller(); canceller();
if ((error !== undefined) && if ((error !== undefined) &&
(error.target instanceof IDBOpenDBRequest) && (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: " + reject("Connection to: " + db_name + " failed: " +
error.target.error.message); error.target.error.message);
} else { } else {
...@@ -709,4 +710,4 @@ ...@@ -709,4 +710,4 @@
jIO.addStorage("indexeddb", IndexedDBStorage); jIO.addStorage("indexeddb", IndexedDBStorage);
}(indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest, DOMError, }(indexedDB, jIO, RSVP, Blob, Math, IDBKeyRange, IDBOpenDBRequest, DOMError,
Set)); DOMException, Set));
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
/*jslint nomen: true */ /*jslint nomen: true */
/*global indexedDB, Blob, sinon, IDBDatabase, /*global indexedDB, Blob, sinon, IDBDatabase,
IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange, IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange,
DOMException, Rusha*/ Rusha*/
(function (jIO, QUnit, indexedDB, Blob, sinon, IDBDatabase, (function (jIO, QUnit, indexedDB, Blob, sinon, IDBDatabase,
IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange, IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange,
DOMException, Rusha) { Rusha) {
"use strict"; "use strict";
var test = QUnit.test, var test = QUnit.test,
stop = QUnit.stop, stop = QUnit.stop,
...@@ -190,26 +190,17 @@ ...@@ -190,26 +190,17 @@
}); });
}); });
function startsWith(str, prefix) {
return str.substr(0, prefix.length) === prefix;
}
test("version decrease", function () { test("version decrease", function () {
var context = this; var context = this;
expect(8); expect(1);
return setupDBMigrationTest(context, {version: 3}, return setupDBMigrationTest(context, {version: 3},
{version: 2}, function (evt) { {version: 2}, function (msg) {
ok(evt.target.error instanceof DOMException); ok(startsWith(msg, "Connection to: jio:qunit failed: "));
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");
}); });
}); });
...@@ -2054,4 +2045,4 @@ ...@@ -2054,4 +2045,4 @@
}(jIO, QUnit, indexedDB, Blob, sinon, IDBDatabase, }(jIO, QUnit, indexedDB, Blob, sinon, IDBDatabase,
IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange, 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