navigation-same-document.window.js (1175B)
1 // META: title=RemoteContextHelper navigation using BFCache 2 // META: script=/common/dispatcher/dispatcher.js 3 // META: script=/common/get-host-info.sub.js 4 // META: script=/common/utils.js 5 // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js 6 // META: script=./resources/test-helper.js 7 8 'use strict'; 9 10 async function assertLocationIs(remoteContextWrapper, expectedLocation) { 11 assert_equals( 12 await remoteContextWrapper.executeScript(() => { 13 return location.toString(); 14 }), 15 expectedLocation, 'verify location'); 16 } 17 18 promise_test(async t => { 19 const rcHelper = new RemoteContextHelper(); 20 21 const rc = await rcHelper.addWindow(); 22 23 const oldLocation = await rc.executeScript(() => { 24 return location.toString(); 25 }); 26 const newLocation = oldLocation + '#fragment'; 27 28 // Navigate to same document. 29 await rc.navigateTo(newLocation); 30 31 // Verify that the window navigated. 32 await assertLocationIs(rc, newLocation); 33 34 // Navigate back. 35 await rc.historyBack(oldLocation); 36 37 // Verify that the window navigated back and the executor is running. 38 await assertLocationIs(rc, oldLocation); 39 });