From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../bucket-quota-indexeddb.tentative.https.any.js | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 testing/web-platform/tests/storage/buckets/bucket-quota-indexeddb.tentative.https.any.js (limited to 'testing/web-platform/tests/storage/buckets/bucket-quota-indexeddb.tentative.https.any.js') diff --git a/testing/web-platform/tests/storage/buckets/bucket-quota-indexeddb.tentative.https.any.js b/testing/web-platform/tests/storage/buckets/bucket-quota-indexeddb.tentative.https.any.js new file mode 100644 index 0000000000..ba82edb72e --- /dev/null +++ b/testing/web-platform/tests/storage/buckets/bucket-quota-indexeddb.tentative.https.any.js @@ -0,0 +1,35 @@ +// META: title=Bucket quota enforcement for indexeddb +// META: script=/storage/buckets/resources/util.js + +promise_test(async t => { + const arraySize = 1e6; + const objectStoreName = "storageManager"; + const dbname = + this.window ? window.location.pathname : 'estimate-worker.https.html'; + + let quota = arraySize / 2; + const bucket = await navigator.storageBuckets.open('idb', {quota}); + + await indexedDbDeleteRequest(bucket.indexedDB, dbname); + + const db = + await indexedDbOpenRequest(t, bucket.indexedDB, dbname, (db_to_upgrade) => { + db_to_upgrade.createObjectStore(objectStoreName); + }); + + const txn = db.transaction(objectStoreName, 'readwrite'); + const buffer = new ArrayBuffer(arraySize); + const view = new Uint8Array(buffer); + + for (let i = 0; i < arraySize; i++) { + view[i] = Math.floor(Math.random() * 255); + } + + const testBlob = new Blob([buffer], {type: 'binary/random'}); + txn.objectStore(objectStoreName).add(testBlob, 1); + + await promise_rejects_dom( + t, 'QuotaExceededError', transactionPromise(txn)); + + db.close(); +}, 'IDB respects bucket quota'); -- cgit v1.2.3