performance-navigation-timing-bfcache-reasons-stay.tentative.window.js (1720B)
1 // META: title=RemoteContextHelper navigation using BFCache 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: script=/websockets/constants.sub.js 9 // META: timeout=long 10 11 'use strict'; 12 13 // Ensure that notRestoredReasons are only updated after non BFCache navigation. 14 promise_test(async t => { 15 const rcHelper = new RemoteContextHelper(); 16 // Open a window with noopener so that BFCache will work. 17 const rc1 = await rcHelper.addWindow( 18 /*config=*/ null, /*options=*/ {features: 'noopener'}); 19 // Use WebSocket to block BFCache. 20 await useWebSocket(rc1); 21 const rc1_url = await rc1.executeScript(() => { 22 return location.href; 23 }); 24 25 // Check the BFCache result and the reported reasons. 26 await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ false); 27 await assertNotRestoredReasonsEquals( 28 rc1, 29 /*url=*/ rc1_url, 30 /*src=*/ null, 31 /*id=*/ null, 32 /*name=*/ null, 33 /*reasons=*/[{'reason': 'websocket'}], 34 /*children=*/ []); 35 36 // This time no blocking feature is used, so the page is restored 37 // from BFCache. Ensure that the previous reasons stay there. 38 await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ true); 39 await assertNotRestoredReasonsEquals( 40 rc1, 41 /*url=*/ rc1_url, 42 /*src=*/ null, 43 /*id=*/ null, 44 /*name=*/ null, 45 /*reasons=*/[{'reason': 'websocket'}], 46 /*children=*/ []); 47 });