Skip to content

Instantly share code, notes, and snippets.

@AlexanderOMara
Created May 1, 2017 20:02
Show Gist options
  • Save AlexanderOMara/f32ce245ed5bb365b27a3f6a1052e898 to your computer and use it in GitHub Desktop.
Save AlexanderOMara/f32ce245ed5bb365b27a3f6a1052e898 to your computer and use it in GitHub Desktop.
Firefox IndexedDB Limit Test
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Firefox IndexedDB Limit Test</title>
</head>
<body>
<script>
(function() {
'use strict';
var IDBReq = indexedDB.open('testdb', {
version: 1,
storage: 'persistent'
});
IDBReq.onupgradeneeded = function() {
this.result.createObjectStore('data');
};
var logmsg;
IDBReq.onsuccess = function() {
var DB = this.result;
var size = 0;
var next = function(i) {
var data = new Uint8Array(0xFFFF);
crypto.getRandomValues(data);
size += data.length;
logmsg = 'size: ' + size + 'b ' + (size / (1024 * 1024 * 1024)) + 'gb';
var store = DB.transaction(['data'], 'readwrite').objectStore('data');
var storeReq = store.add(data, 'data-' + i);
storeReq.onsuccess = function() {
next(i + 1);
};
storeReq.onerror = function() {
console.log('storeReq error');
console.log(this.error);
};
};
next(1);
};
setInterval(function() {
if (logmsg) {
console.log(logmsg);
logmsg = null;
}
}, 1000);
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment