docshell/test/file_bug475636.sjs

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 jsURL = "javascript:" + escape('window.parent.postMessage("JS uri ran", "*");\
michael@0 2 return \'\
michael@0 3 <script>\
michael@0 4 window.parent.postMessage("Able to access private: " +\
michael@0 5 window.parent.private, "*");\
michael@0 6 </script>\'');
michael@0 7 dataURL = "data:text/html," + escape('<!DOCTYPE HTML>\
michael@0 8 <script>\
michael@0 9 try {\
michael@0 10 window.parent.postMessage("Able to access private: " +\
michael@0 11 window.parent.private, "*");\
michael@0 12 }\
michael@0 13 catch (e) {\
michael@0 14 window.parent.postMessage("pass", "*");\
michael@0 15 }\
michael@0 16 </script>');
michael@0 17
michael@0 18 tests = [
michael@0 19 // Plain document should work as normal
michael@0 20 '<!DOCTYPE HTML>\
michael@0 21 <script>\
michael@0 22 try {\
michael@0 23 window.parent.private;\
michael@0 24 window.parent.postMessage("pass", "*");\
michael@0 25 }\
michael@0 26 catch (e) {\
michael@0 27 window.parent.postMessage("Unble to access private", "*");\
michael@0 28 }\
michael@0 29 </script>',
michael@0 30
michael@0 31 // refresh to plain doc
michael@0 32 { refresh: "file_bug475636.sjs?1",
michael@0 33 doc: '<!DOCTYPE HTML>' },
michael@0 34
michael@0 35 // meta-refresh to plain doc
michael@0 36 '<!DOCTYPE HTML>\
michael@0 37 <head>\
michael@0 38 <meta http-equiv="refresh" content="0; url=file_bug475636.sjs?1">\
michael@0 39 </head>',
michael@0 40
michael@0 41 // refresh to data url
michael@0 42 { refresh: dataURL,
michael@0 43 doc: '<!DOCTYPE HTML>' },
michael@0 44
michael@0 45 // meta-refresh to data url
michael@0 46 '<!DOCTYPE HTML>\
michael@0 47 <head>\
michael@0 48 <meta http-equiv="refresh" content="0; url=' + dataURL + '">\
michael@0 49 </head>',
michael@0 50
michael@0 51 // refresh to js url should not be followed
michael@0 52 { refresh: jsURL,
michael@0 53 doc:
michael@0 54 '<!DOCTYPE HTML>\
michael@0 55 <script>\
michael@0 56 setTimeout(function() {\
michael@0 57 window.parent.postMessage("pass", "*");\
michael@0 58 }, 2000);\
michael@0 59 </script>' },
michael@0 60
michael@0 61 // meta refresh to js url should not be followed
michael@0 62 '<!DOCTYPE HTML>\
michael@0 63 <head>\
michael@0 64 <meta http-equiv="refresh" content="0; url=' + jsURL + '">\
michael@0 65 </head>\
michael@0 66 <script>\
michael@0 67 setTimeout(function() {\
michael@0 68 window.parent.postMessage("pass", "*");\
michael@0 69 }, 2000);\
michael@0 70 </script>'
michael@0 71 ];
michael@0 72
michael@0 73
michael@0 74 function handleRequest(request, response)
michael@0 75 {
michael@0 76 dump("@@@@@@@@@hi there: " + request.queryString + "\n");
michael@0 77 test = tests[parseInt(request.queryString, 10) - 1];
michael@0 78 response.setHeader("Content-Type", "text/html");
michael@0 79
michael@0 80 if (!test) {
michael@0 81 response.write('<script>parent.postMessage("done", "*");</script>');
michael@0 82 }
michael@0 83 else if (typeof test == "string") {
michael@0 84 response.write(test);
michael@0 85 }
michael@0 86 else if (test.refresh) {
michael@0 87 response.setHeader("Refresh", "0; url=" + test.refresh);
michael@0 88 response.write(test.doc);
michael@0 89 }
michael@0 90 }

mercurial