Cache the page-owned app response before starting the worker

This commit is contained in:
Jonathan Sykes
2026-10-08 09:04:20 +08:00
parent e7a7cdc6b9
commit a86fa1cebe
16 changed files with 186 additions and 17 deletions

View File

@@ -42,3 +42,12 @@ test('overlapping idle warm messages share one download pool',async()=>{
await Promise.all([e.dispatch('message',{data:{type:'WARM_ASSETS',saveData:false}}),e.dispatch('message',{data:{type:'WARM_ASSETS',saveData:false}})]);
assert.equal(e.fetches.filter(url=>url==='/extra.js?v=extra').length,1);
});
test('page-captured app is reused on first install without a worker download',async()=>{
const e=environment(),cache=await e.storage.open(core.CACHE);
await cache.put('/app.js?v=app',new Response('page captured app',{headers:{'X-Asset-Hash':'app'}}));
await e.dispatch('install');assert.equal(e.fetches.includes('/app.js?v=app'),false);
assert.equal(await(await cache.match('/app.js?v=app')).text(),'page captured app');
assert.equal(e.skips.length,0);assert.equal(await core.state(cache),null);
});