Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | #!/usr/bin/perl |
michael@0 | 2 | # |
michael@0 | 3 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 6 | use Time::HiRes qw(gettimeofday tv_interval); |
michael@0 | 7 | |
michael@0 | 8 | sub encodeHiResTime { |
michael@0 | 9 | my $timeref = shift; |
michael@0 | 10 | return unless ref($timeref); |
michael@0 | 11 | my $time = $$timeref[0] . "-" . $$timeref[1]; |
michael@0 | 12 | return $time; |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | my $time = encodeHiResTime([gettimeofday()]); |
michael@0 | 16 | |
michael@0 | 17 | print "Content-type: text/html\n\n"; |
michael@0 | 18 | print <<"ENDOFHTML"; |
michael@0 | 19 | <html> |
michael@0 | 20 | <head> |
michael@0 | 21 | <script> |
michael@0 | 22 | |
michael@0 | 23 | var gServerTime = '$time'; |
michael@0 | 24 | |
michael@0 | 25 | function tokenizeQuery() { |
michael@0 | 26 | var query = {}; |
michael@0 | 27 | var pairs = document.location.search.substring(1).split('&'); |
michael@0 | 28 | for (var i=0; i < pairs.length; i++) { |
michael@0 | 29 | var pair = pairs[i].split('='); |
michael@0 | 30 | query[pair[0]] = unescape(pair[1]); |
michael@0 | 31 | } |
michael@0 | 32 | return query; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function setLocationHref(aHref, aReplace) { |
michael@0 | 36 | if (aReplace) |
michael@0 | 37 | document.location.replace(aHref); |
michael@0 | 38 | else |
michael@0 | 39 | document.location.href = aHref; |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | var gHref; |
michael@0 | 43 | function doNextRequest(aTime) { |
michael@0 | 44 | function getValue(arg,def) { |
michael@0 | 45 | return !isNaN(arg) ? parseInt(Number(arg)) : def; |
michael@0 | 46 | } |
michael@0 | 47 | var q = tokenizeQuery(); |
michael@0 | 48 | var delay = getValue(q['delay'], 0); |
michael@0 | 49 | |
michael@0 | 50 | var now = (new Date()).getTime(); |
michael@0 | 51 | var c_intvl = now - c_ts; |
michael@0 | 52 | var c_ts = now + delay; // adjust for delay time |
michael@0 | 53 | // Now make the request ... |
michael@0 | 54 | if (q['url']) { |
michael@0 | 55 | gHref = q['url'] + |
michael@0 | 56 | "?c_part=" + -1 + // bogo request is not recorded |
michael@0 | 57 | "&index=" + 0 + |
michael@0 | 58 | "&id=" + q['id'] + |
michael@0 | 59 | "&maxcyc=" + q['maxcyc'] + |
michael@0 | 60 | "&replace=" + q['replace'] + |
michael@0 | 61 | "&nocache=" + q['nocache'] + |
michael@0 | 62 | "&delay=" + delay + |
michael@0 | 63 | "&timeout=" + q['timeout'] + |
michael@0 | 64 | "&c_intvl=" + c_intvl + |
michael@0 | 65 | "&s_ts=" + gServerTime + |
michael@0 | 66 | "&c_ts=" + c_ts; |
michael@0 | 67 | window.setTimeout("setLocationHref(gHref,false);", delay); |
michael@0 | 68 | return true; |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function startTest() { |
michael@0 | 73 | if (window.innerHeight && window.innerWidth) { |
michael@0 | 74 | // force a consistent region for layout and painting. |
michael@0 | 75 | window.innerWidth=820; |
michael@0 | 76 | window.innerHeight=620; |
michael@0 | 77 | } |
michael@0 | 78 | doNextRequest(0); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | window.setTimeout("startTest()", 1000); |
michael@0 | 82 | |
michael@0 | 83 | </script> |
michael@0 | 84 | </head> |
michael@0 | 85 | <body> |
michael@0 | 86 | <p> |
michael@0 | 87 | This page starts the test. |
michael@0 | 88 | </p> |
michael@0 | 89 | <p> |
michael@0 | 90 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 91 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 92 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 93 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 94 | </p> |
michael@0 | 95 | <p> |
michael@0 | 96 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 97 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 98 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 99 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 100 | </p> |
michael@0 | 101 | <p> |
michael@0 | 102 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 103 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 104 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 105 | dummy page dummy page dummy page dummy page dummy page dummy page |
michael@0 | 106 | </p> |
michael@0 | 107 | </body> |
michael@0 | 108 | </html> |
michael@0 | 109 | |
michael@0 | 110 | ENDOFHTML |
michael@0 | 111 | |
michael@0 | 112 | exit 0; |