<script>
window.onmessage = function(e) {
  const id = e.data['id'];
  try {
    var sw = window.navigator.serviceWorker;
  } catch (e) {
    window.top.postMessage({
        id: id,
        result: 'navigator.serviceWorker failed: ' + e.name
      }, '*');
    return;
  }

  window.navigator.serviceWorker.getRegistration()
    .then(function() {
        window.top.postMessage({id: id, result:'ok'}, '*');
      })
    .catch(function(e) {
        window.top.postMessage({
            id: id,
            result: 'getRegistration() failed: ' + e.name
          }, '*');
        });
};
</script>
