security/manager/ssl/tests/mochitest/stricttransportsecurity/verify.sjs

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 // SJS file that serves un-cacheable responses for STS tests that postMessage
michael@0 6 // to the parent saying whether or not they were loaded securely.
michael@0 7
michael@0 8 function handleRequest(request, response)
michael@0 9 {
michael@0 10 var query = {};
michael@0 11 request.queryString.split('&').forEach(function (val) {
michael@0 12 var [name, value] = val.split('=');
michael@0 13 query[name] = unescape(value);
michael@0 14 });
michael@0 15
michael@0 16 response.setHeader("Cache-Control", "no-cache", false);
michael@0 17 response.setHeader("Content-Type", "text/html", false);
michael@0 18
michael@0 19 if ('id' in query) {
michael@0 20 var outstr = [
michael@0 21 " <!DOCTYPE html>",
michael@0 22 " <html> <head> <title>subframe for STS</title>",
michael@0 23 " <script type='text/javascript'>",
michael@0 24 " var self = window;",
michael@0 25 " window.addEventListener('load', function() {",
michael@0 26 " if (document.location.protocol === 'https:') {",
michael@0 27 " self.parent.postMessage('SECURE " + query['id'] + "',",
michael@0 28 " 'http://mochi.test:8888');",
michael@0 29 " } else {",
michael@0 30 " self.parent.postMessage('INSECURE " + query['id'] + "',",
michael@0 31 " 'http://mochi.test:8888');",
michael@0 32 " }",
michael@0 33 " }, false);",
michael@0 34 " </script>",
michael@0 35 " </head>",
michael@0 36 " <body>",
michael@0 37 " STS state verification frame loaded via",
michael@0 38 " <script>",
michael@0 39 " document.write(document.location.protocol);",
michael@0 40 " </script>",
michael@0 41 " </body>",
michael@0 42 " </html>"].join("\n");
michael@0 43 response.write(outstr);
michael@0 44 } else {
michael@0 45 response.write("ERROR: no id provided");
michael@0 46 }
michael@0 47 }

mercurial