Skip to content

Commit

Permalink
Bug 1793125 [wpt PR 36204] - Storage Buckets: hook up CacheStorage (p…
Browse files Browse the repository at this point in the history
…art 3/3), a=testonly

Automatic update from web-platform-tests
Storage Buckets: hook up CacheStorage (part 3/3)

Bug: 1218097
Change-Id: I59939c05933fe404e97888b9810580c5029e470d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3880834
Reviewed-by: Ayu Ishii <[email protected]>
Reviewed-by: Ben Kelly <[email protected]>
Reviewed-by: Nasko Oskov <[email protected]>
Commit-Queue: Evan Stade <[email protected]>
Commit-Queue: Nasko Oskov <[email protected]>
Auto-Submit: Evan Stade <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1056452}

--

wpt-commits: eee708c4a74589371201151a153b988502401fd1
wpt-pr: 36204
  • Loading branch information
Evan Stade authored and moz-wptsync-bot committed Oct 21, 2022
1 parent d5aa015 commit a4f6ff7
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,38 @@ cache_test(async (cache) => {
assert_true(cachedResponseText.indexOf("name=\"name\"\r\n\r\nvalue") !== -1);
}, 'Cache.put called with simple Request and form data Response');

promise_test(async function(test) {
var inboxBucket = await navigator.storageBuckets.open('inbox');
var draftsBucket = await navigator.storageBuckets.open('drafts');

test.add_cleanup(async function() {
await navigator.storageBuckets.delete('inbox');
await navigator.storageBuckets.delete('drafts');
});

const cacheName = 'attachments';
const cacheKey = 'receipt1.txt';

var inboxCache = await inboxBucket.caches.open(cacheName);
var draftsCache = await draftsBucket.caches.open(cacheName);

await inboxCache.put(cacheKey, new Response('bread x 2'))
await draftsCache.put(cacheKey, new Response('eggs x 1'));

return inboxCache.match(cacheKey)
.then(function(result) {
return result.text();
})
.then(function(body) {
assert_equals(body, 'bread x 2', 'Wrong cache contents');
return draftsCache.match(cacheKey);
})
.then(function(result) {
return result.text();
})
.then(function(body) {
assert_equals(body, 'eggs x 1', 'Wrong cache contents');
});
}, 'caches from different buckets have different contents');

done();

0 comments on commit a4f6ff7

Please sign in to comment.