Created
May 1, 2017 20:02
-
-
Save AlexanderOMara/f32ce245ed5bb365b27a3f6a1052e898 to your computer and use it in GitHub Desktop.
Firefox IndexedDB Limit Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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