blob: 0b70f0e8919c0666dac9e08e7b0ec7e889112cf5 [file] [log] [blame]
<!doctype html>
<!--
This page makes a fetchLater call, and posts message back to source.
-->
<title>FetchLater</title>
<script>
const PARAMS = new URL(location.href).searchParams;
const REQUEST_INIT = Object.assign({},
PARAMS.has('activateAfter') ? {activateAfter: parseInt(PARAMS.get('activateAfter'), 10)} : null,
PARAMS.has('method') ? {method: PARAMS.get('method')} : null,
);
function postMessageBack(message) {
if (window.opener) {
window.opener.postMessage(message, '*');
} else {
parent.postMessage(message, '*');
}
}
try {
fetchLater('/beacon', REQUEST_INIT);
postMessageBack({type: 'fetchLater.done'});
} catch (e) {
postMessageBack({type: 'fetchLater.error', error: e});
}
</script>