buckets_storage_policy.tentative.https.any.js (946B)
1 // META: title=Buckets API: Tests for bucket storage policies. 2 // META: script=resources/util.js 3 // META: global=window,worker 4 5 'use strict'; 6 7 function sanitizeQuota(quota) { 8 return Math.max(1, Math.min(Number.MAX_SAFE_INTEGER, Math.floor(quota))); 9 } 10 11 async function testQuota(quota, name) { 12 const safeQuota = sanitizeQuota(quota); 13 const bucket = await navigator.storageBuckets.open(name, { quota: safeQuota }); 14 const estimateQuota = (await bucket.estimate()).quota; 15 assert_equals(estimateQuota, safeQuota); 16 } 17 18 promise_test(async testCase => { 19 await prepareForBucketTest(testCase); 20 21 const storageKeyQuota = (await navigator.storage.estimate()).quota; 22 23 testQuota(1, 'one'); 24 testQuota(storageKeyQuota / 4, 'quarter'); 25 testQuota(storageKeyQuota / 2, 'half'); 26 testQuota(storageKeyQuota - 1, 'one_less'); 27 testQuota(storageKeyQuota, 'origin_quota'); 28 }, 'Bucket quota is properly set as long as it is within the storage quota');