summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/xsl-base-url-worker.js
blob: 50e2b1842ffc7f2ef2017846406eb67ed9491ead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
self.addEventListener('fetch', event => {
  const url = new URL(event.request.url);

  // For the import-relative.xsl file, respond in a way that changes the
  // response URL. This is expected to change the base URL and allow the import
  // from the file to succeed.
  const path = 'request-url-path/import-relative.xsl';
  if (url.pathname.indexOf(path) != -1) {
    // Respond with a different URL, deleting "request-url-path/".
    event.respondWith(fetch('import-relative.xsl'));
  }
});