Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
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/. */
5 // SJS file that serves un-cacheable responses for STS tests that postMessage
6 // to the parent saying whether or not they were loaded securely.
8 function handleRequest(request, response)
9 {
10 var query = {};
11 request.queryString.split('&').forEach(function (val) {
12 var [name, value] = val.split('=');
13 query[name] = unescape(value);
14 });
16 response.setHeader("Cache-Control", "no-cache", false);
17 response.setHeader("Content-Type", "text/html", false);
19 if ('id' in query) {
20 var outstr = [
21 " <!DOCTYPE html>",
22 " <html> <head> <title>subframe for STS</title>",
23 " <script type='text/javascript'>",
24 " var self = window;",
25 " window.addEventListener('load', function() {",
26 " if (document.location.protocol === 'https:') {",
27 " self.parent.postMessage('SECURE " + query['id'] + "',",
28 " 'http://mochi.test:8888');",
29 " } else {",
30 " self.parent.postMessage('INSECURE " + query['id'] + "',",
31 " 'http://mochi.test:8888');",
32 " }",
33 " }, false);",
34 " </script>",
35 " </head>",
36 " <body>",
37 " STS state verification frame loaded via",
38 " <script>",
39 " document.write(document.location.protocol);",
40 " </script>",
41 " </body>",
42 " </html>"].join("\n");
43 response.write(outstr);
44 } else {
45 response.write("ERROR: no id provided");
46 }
47 }