<!DOCTYPE html>
<meta charset="utf-8">
<title>Controlled page</title>
<script>
// |kThirdPartyServiceWorker| from web_feature.mojom.
const kFeature = 3007;
window.onmessage = (async e => {
if (e.data !== 'from_opener_assert_has_use_counter') {
window.top.postMessage('FAIL: unexpected message', '*');
return;
}
const registration = await navigator.serviceWorker.register('../resources/empty-worker.js');
await window.internals.observeUseCounter(document, kFeature);
if (window.internals.isUseCounted(document, kFeature)) {
window.top.postMessage('from_iframe_verified_has_use_counter', '*');
return;
}
window.top.postMessage('FAIL: !isUseCounted', '*');
registration.unregister();
});
</script>