performance-navigation-timing-cross-origin-bfcache.tentative.window.js (1987B)
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 cross-origin subtree's reasons are not exposed to 14 // notRestoredReasons. 15 promise_test(async t => { 16 const rcHelper = new RemoteContextHelper(); 17 // Open a window with noopener so that BFCache will work. 18 const rc1 = await rcHelper.addWindow( 19 /*config=*/ null, /*options=*/ {features: 'noopener'}); 20 const rc1_url = await rc1.executeScript(() => { 21 return location.href; 22 }); 23 // Add a cross-origin iframe. 24 const rc1_child = await rc1.addIframe( 25 /*extraConfig=*/ { 26 origin: 'HTTP_REMOTE_ORIGIN', 27 scripts: [], 28 headers: [], 29 }, 30 /*attributes=*/ {id: 'test-id'}, 31 ); 32 // Use WebSocket to block BFCache. 33 await useWebSocket(rc1_child); 34 const rc1_child_url = await rc1_child.executeScript(() => { 35 return location.href; 36 }); 37 // Add a child to the iframe. 38 const rc1_grand_child = await rc1_child.addIframe(); 39 const rc1_grand_child_url = await rc1_grand_child.executeScript(() => { 40 return location.href; 41 }); 42 43 // Check the BFCache result and the reported reasons. 44 await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ false); 45 await assertNotRestoredReasonsEquals( 46 rc1, 47 /*url=*/ rc1_url, 48 /*src=*/ null, 49 /*id=*/ null, 50 /*name=*/ null, 51 /*reasons=*/[{'reason': "masked"}], 52 /*children=*/[{ 53 'url': null, 54 'src': rc1_child_url, 55 'id': 'test-id', 56 'name': null, 57 'reasons': null, 58 'children': null 59 }]); 60 });