summaryrefslogtreecommitdiffstats
path: root/dom/fetch/tests/credentialless_worker.sjs
blob: a9e2197d1843bb28193f85afa1105c43c77864c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const WORKER = `
  onmessage = function(event) {
    fetch(event.data, {
      mode: "no-cors",
      credentials: "include"
    }).then(function() {
      postMessage("fetch done");
    });
  }
`;

function handleRequest(request, response) {
  if (request.queryString === "credentialless") {
    response.setHeader("Cross-Origin-Embedder-Policy", "credentialless", true);
  }

  response.setHeader("Content-Type", "application/javascript", false);
  response.setStatusLine(request.httpVersion, "200", "Found");
  response.write(WORKER);
}