summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/offline/updatingManifest.sjs
blob: 3d95bdcd611ac466a083f664a28350fb28638e7e (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
ver1manifest =
  "CACHE MANIFEST\n" +
  "# v1\n" +
  "\n" +
  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs\n" +
  "\n" +
  "FALLBACK:\n" +
  "namespace1/ fallback.html\n" +
  "\n" +
  "NETWORK:\n" +
  "onwhitelist.html\n";

ver2manifest =
  "CACHE MANIFEST\n" +
  "# v2\n" +
  "\n" +
  "http://mochi.test:8888/tests/SimpleTest/SimpleTest.js\n" +
  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs" +
  "\n" +
  "FALLBACK:\n" +
  "namespace1/ fallback.html\n" +
  "namespace1/sub/ fallback2.html\n";

ver3manifest =
  "CACHE MANIFEST\n" +
  "# v3\n" +
  "\n" +
  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs" +
  "\n" +
  "FALLBACK:\n" +
  "namespace1/sub fallback2.html\n" +
  "\n" +
  "NETWORK:\n" +
  "onwhitelist.html\n";

function handleRequest(request, response)
{
  var match = request.queryString.match(/^state=(.*)$/);
  if (match)
  {
    response.setStatusLine(request.httpVersion, 204, "No content");
    setState("offline.updatingManifest", match[1]);
  }

  if (request.queryString == "")
  {
    response.setStatusLine(request.httpVersion, 200, "Ok");
    response.setHeader("Content-Type", "text/cache-manifest");
    response.setHeader("Cache-Control", "no-cache");
    switch (getState("offline.updatingManifest"))
    {
      case "": // The default value
        response.write(ver1manifest + "\n#" + getState("offline.updatingManifest"));
        break;
      case "second":
        response.write(ver2manifest + "\n#" + getState("offline.updatingManifest"));
        break;
      case "third":
        response.write(ver3manifest + "\n#" + getState("offline.updatingManifest"));
        break;
    }
  }
}