Created
July 27, 2015 11:24
-
-
Save gladkih/865a311c0f77f657ca05 to your computer and use it in GitHub Desktop.
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
function gen(n) { | |
return new Array((n * 1024) + 1).join('a') | |
} | |
if (!localStorage.getItem('size')) { | |
var i = 0; | |
try { | |
// Test up to 10 MB | |
for (i = 0; i <= 10000; i += 250) { | |
localStorage.setItem('test', gen(i)); | |
} | |
} catch (e) { | |
localStorage.removeItem('test'); | |
localStorage.setItem('size', i ? i - 250 : 0); | |
} | |
} | |
console.log(localStorage.getItem('size')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment