summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/mozilla/tests/service-workers/resources/intercept_media_sw.js
blob: 6c373aa0de28fa7359bbb8d67306aec426d371e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'use strict';

self.addEventListener('fetch', event => {
  if (event.request.url.indexOf('fetch_video.py') !== -1) {
    // A no-cors media range request /should not/ be intercepted.
    // Respond with some text to cause an error.
    event.respondWith(new Response('intercepted'));
  }
  else if (event.request.url.indexOf('blank.html') !== -1) {
    // A no-cors media non-range request /should/ be intercepted.
    // Respond with an image to avoid an error.
    event.respondWith(fetch('green.png'));
  }
});