Last active
December 9, 2015 00:08
-
-
Save h3h/a3c6c2477635d1221ad1 to your computer and use it in GitHub Desktop.
Fill up localStorage completely on a given page.
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
var DATA = [ | |
'0', | |
'0000000000', | |
'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' | |
]; | |
var chunkSize, i, printFactor; | |
var chunkIndex = (DATA.length - 1); | |
while (chunkIndex >= 0) { | |
try { | |
chunkSize = DATA[chunkIndex].length; | |
i = 0; | |
printFactor = Math.pow(10, 5 - Math.log10(chunkSize)); | |
console.log("Filling your localStorage up with %d-byte chunks...", chunkSize); | |
while (++i) { | |
window.localStorage['garbage'+i] = DATA[chunkIndex]; | |
if (i % printFactor == 0) { | |
console.log("%d chunks saved to localStorage for this chunk size.", i); | |
} | |
} | |
} catch (e) { | |
if (chunkIndex == 0) { | |
console.log("All full: %s", e); | |
} | |
chunkIndex--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment