cache-storage.https.html (1252B)
1 <!DOCTYPE html> 2 <title>Same-origin prerendering can access cache storage</title> 3 <meta name="timeout" content="long"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/common/dispatcher/dispatcher.js"></script> 7 <script src="/common/utils.js"></script> 8 <script src="../resources/utils.js"></script> 9 <script src="resources/utils.js"></script> 10 11 <body> 12 <script> 13 setup(() => assertSpeculationRulesIsSupported()); 14 15 promise_test(async t => { 16 const cacheName = token(); 17 const cache = await caches.open(cacheName); 18 await cache.add('resources/cache.txt'); 19 t.add_cleanup(() => caches.delete(cacheName)); 20 const response = await cache.match('resources/cache.txt'); 21 const cacheText = await (response ? response.text() : 'primary cache match failed'); 22 23 const {exec} = await create_prerendered_page(t); 24 const result = await exec(async cacheName => { 25 const cache = await caches.open(cacheName); 26 const match = await cache.match('cache.txt'); 27 return await match.text(); 28 }, [cacheName]); 29 30 assert_equals( 31 result, cacheText, 32 'prerendering page should be able to read from cache storage.'); 33 }, 'prerendering page should be able to access cache storage') 34 35 </script>