title: ServiceWorker: No FetchEvent for javascript triggered request?
body: <p>I am using Chrome stable 46.</p>
  
  <p>I have a very basic site. One button.onclick that <code>fetch('a')</code> and one <code>&lt;a&gt;</code> tag that opens <code>b</code>. Both urls <code>a</code> and <code>b</code> do not exist, I intend to catch them in the service worker and just return a <code>new Response()</code>.</p>
  
  <p>If I click on the button which fetches <code>a</code>, the service worker is not involved and I get a 404 error.<br>
  But if I click on the link that goes to <code>b</code>, the service worker onfetches and returns the response.</p>
  
  <p><strong>Question</strong>: Why is the service worker not getting any FetchEvent for the <code>fetch('a')</code> request?</p>
  
  <p>See the files below</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;p&gt;&lt;button onclick="fetch('a');"&gt;fetch a&lt;/button&gt;&lt;/p&gt;
      &lt;p&gt;&lt;a href="b"&gt;go to b&lt;/a&gt;&lt;/p&gt;
      &lt;script src="js.js" defer&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>js.js</p>
  
  <pre><code>navigator.serviceWorker.register('sw.js');
  </code></pre>
  
  <p>sw.js</p>
  
  <pre><code>self.onfetch = function(event) {
    var request = event.request;
    event.respondWith(
      caches.match(request).then(function(response) {
        return new Response('here is your onfetch response');
      })
    );
  };
  </code></pre>