summaryrefslogtreecommitdiffstats
path: root/testing/marionette/harness/marionette_harness/www/dom/cache/cacheUsage.html
blob: 8bb7da8f71fd526b3ea8e5b3da976eba8fe74bbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<html>
    <head>
        <script>
            async function getStorageEstimate() {
                let r = await navigator.storage.estimate();
                return r.usage;
            }

            function openCache(id) {
                return caches.open(id);
            }

            async function doCacheWork(id, n) {
                let c = await openCache(id);

                const body = new Uint32Array(1024);
                self.crypto.getRandomValues(body);

                for (let i = 0; i < n; i++) {
                    await c.put(new Request(`/data-${i}`), new Response(body))
                }

                await caches.delete(id)
                return "success";
            }
        </script>
    </head>
</html>