title: service worker install event is called before register event is completed
body: <p>I have attached install event to service worker as below. But Install event fired before register event is completed. See code snippets and console logs below.</p>
  
  <p>My concern is how install event is fired before register event is completed?</p>
  
  <pre><code>if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('./service-worker.js',{scope : '/'}).then(function(registration) {
      // Registration was successful
      console.log('ServiceWorker registration successful with scope: ', registration.scope);
    }).catch(function(err) {
      // registration failed :(
      console.log('ServiceWorker registration failed: ', err);
    });
  }
  
  
  var cacheName = 'V-1';
  var filesToCache = [
    '/', '/index.html',
    '/css/all.css', '/css/material.min.css',
    '/js/all.js', '/js/material.min.js',
    '/images/service-worker-1.png','/images/service-worker-2.png','/images/service-worker-3.png',
  ];
  
  self.addEventListener('install', function(e) {
    console.log('[ServiceWorker] Installing');
    e.waitUntil(
      caches.open(cacheName).then(function(cache) {
        console.log('[ServiceWorker] Caching app shell');
        return cache
                .addAll(filesToCache) //this is atomic in nature i.e. if any of the file fails the entire cache step fails.
                .then(() =&gt; {console.log('[ServiceWorker] App shell Caching  Successful');})
                .catch(() =&gt; {console.log('[ServiceWorker] App shell Caching  Failed');})
      })
    );
  });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/lf5gH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lf5gH.png" alt="Console Logs"></a></p>