function tryFillLocalStorage (chunkSize) {
var size = chunkSize / 4; // chunk will be repetition of 4B
var content = (new Array(size+1)).join('aใ');
var blob = {
size: chunkSize,
payload: content
};
// now is the generated time
blob.lastModifiedDate = new Date();
// Name it random so key won't conflict
blob.name = (~~(Math.random()*100000)+100000)+'.txt';
try {
localStorage.setItem(blob.name, JSON.stringify(blob));
} catch(e) {
try {
localStorage.removeItem(blob.name);
} catch(e) {}
return false;
}
try {
localStorage.removeItem(blob.name);
} catch(e) {}
return true;
}
// normal mode having max 5 MB in localStorage space,
// yes NORMAL MODE having max 5 MB
var LOCAL_STORAGE_DATA_SIZE = 1024 * 1024 * 5; // 5MB
if (tryFillLocalStorage(LOCAL_STORAGE_DATA_SIZE)) {
// IN PRIVATE MODE
}
Please if you can help implement and optimize that, because I'm currently using a whole different code structure, which support strict mode code.
Thanks.