I am trying to fix failing tests of sklad library in Internet Explorer by running them in SauceLabs. Unfortunately I found that autoIncrement property of object store is always undefined, but I couldn't find any evidence that this property is broken in IE. Or am I missing smth?
var sDBName = "ADatabase" + Date.now();
var nDBVersion = 1.0;
var req = indexedDB.open( sDBName, nDBVersion );
req.onsuccess = function(evt) {
var tr = evt.target.result.transaction(['MyObjectStore'], 'readwrite'); // reaonly
tr.oncomplete = function () {
console.log('transaction completed')
}
var objStore = tr.objectStore('MyObjectStore');
console.log('objStore', objStore);
// expect to get true, but it's undefined
console.log('objStore.autoIncrement', objStore.autoIncrement);
console.log('objStore.keyPath', objStore.keyPath);
}
req.onupgradeneeded = function(evt) {
console.log('upgradeneeded')
var hDBHandle = evt.target.result;
var sStoreName = "MyObjectStore";
var oDBOptions = { keyPath : "RecordID", autoIncrement : true };
var oStore = hDBHandle.createObjectStore( sStoreName, oDBOptions );
var oIxOptions = { unique: false, multientry: false };
oStore.createIndex( "SortByTitle", "DeckTitle", oIxOptions );
oStore.createIndex( "SortByDesc", "Description", oIxOptions );
console.log('upgraded')
}
Bad news: this is a bug and it's closed in Microsoft bug tracker: https://connect.microsoft.com/IE/Feedback/Details/772726
Good news: you can write a polyfill for this property like I did (link). The idea is to check whether autoIncrement is undefined. If it's undefined you should start a read/write transaction where you add data to object store. Based on response/exceptions you can understand whether this object store has true or false autoIncrement field. Of course you should rollback this transaction afterwards.
If you don't want to work with all this stuff I wrote a library for you: link