estimate-usage-details-caches.https.tentative.any.js (769B)
1 // META: title=StorageManager: estimate() for caches 2 3 promise_test(async t => { 4 let estimate = await navigator.storage.estimate(); 5 6 const cachesUsageBeforeCreate = estimate.usageDetails.caches || 0; 7 8 const cacheName = 'testCache'; 9 const cache = await caches.open(cacheName); 10 t.add_cleanup(() => caches.delete(cacheName)); 11 12 await cache.put('/test.json', new Response('x'.repeat(1024*1024))); 13 14 estimate = await navigator.storage.estimate(); 15 assert_true('caches' in estimate.usageDetails); 16 const cachesUsageAfterPut = estimate.usageDetails.caches; 17 assert_greater_than( 18 cachesUsageAfterPut, cachesUsageBeforeCreate, 19 'estimated usage should increase after value is stored'); 20 }, 'estimate() shows usage increase after large value is stored');