Backed out changeset 06f41c22f3a6 (bug 1888460) for causing linux xpcshell failures...
[gecko.git] / dom / workers / test / bug1047663_worker.sjs
blob169ca05f8991bc0cdecaa91ad8d68ac543912639
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 "use strict";
6 const WORKER_1 = `
7   "use strict";
9   self.onmessage = function () {
10     postMessage("one");
11   };
14 const WORKER_2 = `
15   "use strict";
17   self.onmessage = function () {
18     postMessage("two");
19   };
22 function handleRequest(request, response) {
23   let count = getState("count");
24   if (count === "") {
25     count = "1";
26   }
28   // This header is necessary for the cache to trigger.
29   response.setHeader("Cache-control", "max-age=3600");
30   response.setHeader("Content-Type", "text/javascript", false);
32   // If this is the first request, return the first source.
33   if (count === "1") {
34     response.write(WORKER_1);
35     setState("count", "2");
36   }
37   // For all subsequent requests, return the second source.
38   else {
39     response.write(WORKER_2);
40   }