<!DOCTYPE html>
<title>Service Worker: 3P window for partitioned service workers</title>
<script src="./test-helpers.sub.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<head>
<!-- The token below was generated via the following command:
tools/origin_trials/generate_token.py https://not-web-platform.test:8444
DisableThirdPartyStoragePartitioning2 --expire-timestamp=2000000000 -->
<meta http-equiv="origin-trial" content="A3DPTytI20KQsg/ekVlGii9dPqgdhuRNFGt/gxEKvrOBVFPSNkKy9xwF2zEkRXxBoG+Go5xqgfUxuDr1DQvAzgMAAAB6eyJvcmlnaW4iOiAiaHR0cHM6Ly9ub3Qtd2ViLXBsYXRmb3JtLnRlc3Q6ODQ0NCIsICJmZWF0dXJlIjogIkRpc2FibGVUaGlyZFBhcnR5U3RvcmFnZVBhcnRpdGlvbmluZzIiLCAiZXhwaXJ5IjogMjAwMDAwMDAwMH0=">
</head>
<body>
This page should be opened as a third-party window. It then loads an iframe
specified by the query parameter. Finally it forwards the postMessage from the
iframe up to the opener (the test).
<script>
async function onLoad() {
const message_promise = new Promise(resolve => {
self.addEventListener('message', evt => {
resolve(evt.data);
});
});
const search_param = new URLSearchParams(window.location.search);
const iframe_url = search_param.get('target');
var frame = document.createElement('iframe');
frame.src = iframe_url;
frame.style.position = 'absolute';
document.body.appendChild(frame);
await message_promise.then(data => {
// We're done, forward the message and clean up.
window.opener.postMessage(data, '*');
frame.remove();
});
}
self.addEventListener('load', onLoad);
</script>
</body>