chromium/third_party/blink/web_tests/http/tests/serviceworker/resources/window-close-during-registration.html

<html>
<script>
var scope = 'empty';

navigator.serviceWorker.getRegistration(scope)
  .then(function(registration) {
      if (registration)
        registration.unregister();
    })
  .then(function() {
      var promise = navigator.serviceWorker.register('empty-worker.js',
                                                     { scope: scope });
      window.close();
      window.opener.done();
      return promise;
    })
  .catch(function(error) {
      window.opener.testFailed(error.message);
      window.opener.done();
    });
</script>
</html>