I want to make sure my code handles the QuotaExceededError
with IndexedDB properly, I'd prefer not torturing my SSD to do so.
Is there any way to set a storage limit (like to say 5 MB) in the developer tools or browser settings?
I want to make sure my code handles the QuotaExceededError
with IndexedDB properly, I'd prefer not torturing my SSD to do so.
Is there any way to set a storage limit (like to say 5 MB) in the developer tools or browser settings?
In Chrome, you can launch the browser with --user-data-dir pointing at a smaller volume, e.g. via tmpfs
.
Chrome doesn't have devtools support for such testing, but it's on the wish list.
sudo mount -t tmpfs -o size=1G tmpfs /mnt/mytmpfs
for the specific limit you want to test. –
Alcantar As of today you can open DevTools, go to the Application Panel and check the Simulate custom storage quota
label and then provide the maximum amount of MB that can be stored by IndexedDB.
I've used a VM with a small hard drive. That's not ideal obviously, so I hope someone suggests a better answer!
Building on @joshua-bell's answer but adding detail on exactly how to do this in Mac OSX:
mount-ram.sh
file at https://gist.github.com/koshigoe/822455 (you will probably want the unmount-ram.sh file for later as well)mount-ram.sh
, run sh mount-ram.sh mytmpfs 512
cd /Applications/Google Chrome.app/Contents/MacOS
(at least that's where it was on my machine)./Google\ Chrome --user-data-dir=/PATH/TO/mytmpfs/
, replacing /PATH/TO/mytmpfs/
with the path the directory you created in step 3.Now you've got Chrome running, pointed at a file system with only 512MB of storage.
If you're ok with a 100MB storage limit, just open Chrome in incognito mode.
To see how much storage you have left, try this:
navigator.storage.estimate().then(console.log)
© 2022 - 2024 — McMap. All rights reserved.