summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/offline/file_testFile.sjs
blob: 62d020b355eb3c73545ee5c8ab58e715c5de4821 (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
function handleRequest(request, response) {
  var match = request.queryString.match(/^state=(.*)$/);
  if (match) {
    response.setStatusLine(request.httpVersion, 204, "No content");
    setState("version", match[1]);
    return;
  }
  const state = getState("version");
  let color = "green";
  if (state === "evil") {
    color = "red";
  }
  const frameContent = `
  <!DOCTYPE html>
  <html>
  <head>
  <style>body,html {background: ${color};}</style>
  </head>
  <body>
  <h1>Offline file: <span id="state">${state}</span></h1>
  `;
  response.setHeader("Content-Type", "text/html");
  response.setHeader("Cache-Control", "no-cache");
  response.write(frameContent);
}