performance-navigation-timing-fetch.tentative.window.js (1457B)
1 // META: title=Ensure that ongoing fetch upon entering bfcache blocks bfcache and recorded. 2 // META: script=./test-helper.js 3 // META: script=/common/dispatcher/dispatcher.js 4 // META: script=/common/get-host-info.sub.js 5 // META: script=/common/utils.js 6 // META: script=/html/browsers/browsing-the-web/back-forward-cache/resources/rc-helper.js 7 // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js 8 // META: timeout=long 9 10 'use strict'; 11 12 promise_test(async t => { 13 const rcHelper = new RemoteContextHelper(); 14 // Open a window with noopener so that BFCache will work. 15 const rc1 = await rcHelper.addWindow( 16 /*config=*/ null, /*options=*/ {features: 'noopener'}); 17 const rc1_url = await rc1.executeScript(() => { 18 return location.href; 19 }); 20 const wavURL = new URL(get_host_info().HTTP_REMOTE_ORIGIN + '/fetch/range/resources/long-wav.py'); 21 await rc1.executeScript((wavURL) => { 22 // Register pagehide handler to create a fetch request. 23 addEventListener('pagehide', (wavURL) => { 24 fetch(wavURL, { 25 keepalive: true 26 }); 27 }) 28 }); 29 30 // Check the BFCache result and the reported reasons. 31 await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ false); 32 await assertNotRestoredReasonsEquals( 33 rc1, 34 /*url=*/ rc1_url, 35 /*src=*/ null, 36 /*id=*/ null, 37 /*name=*/ null, 38 /*reasons=*/[{'reason': 'fetch'}], 39 /*children=*/[]); 40 });