Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/speculation-rules/prerender/resources/utils.js"></script>
<script src="session-storage-utils.js"></script>
<script>
const params = new URLSearchParams(location.search);
const uid = params.get('uid');
RunSessionStorageTest(async (isPrerendering, url, prerenderChannel, done) => {
if (!isPrerendering) {
startPrerendering(url);
// Wait for the message from the prerendering page.
assert_equals(
await getNextMessage(prerenderChannel),
'From prerendering page')
assert_equals(
getSessionStorageKeys(),
'',
'The session storage item set by the prerendering page must not be ' +
'visible in the initiator page.');
done();
} else {
sessionStorage.setItem('set by prerendering page', '1');
assert_equals(
getSessionStorageKeys(),
'set by prerendering page',
'The session storage item must have been added by the prerendering' +
' page.');
// Send the message to the initiator page.
prerenderChannel.postMessage('From prerendering page');
}
}, uid);
</script>