Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | |
michael@0 | 7 | # This is a modified version of Chris Hofmann's <chofmann@netscape.com> |
michael@0 | 8 | # infamous "browser buster" test harness. It's a bit simpler (CGI |
michael@0 | 9 | # instead of using cookies; IFRAME instead of FRAMESET), and has some |
michael@0 | 10 | # extra parameters that make it a bit easier to test with, but it's |
michael@0 | 11 | # pretty faithful otherwise. |
michael@0 | 12 | # |
michael@0 | 13 | # It accepts a couple of parameters, including |
michael@0 | 14 | # |
michael@0 | 15 | # file=<filename> Set this to the name of the file containing |
michael@0 | 16 | # the URLs that you want the buster to cycle through. This |
michael@0 | 17 | # might be a security hole, so don't run this script on a |
michael@0 | 18 | # server with s3kret stuff on it, mmkay? |
michael@0 | 19 | # |
michael@0 | 20 | # page=<number> This is used to maintain state, and is the line |
michael@0 | 21 | # number in the file that the buster will pull up in the |
michael@0 | 22 | # IFRAME. Set if by hand if you need to for some reason. |
michael@0 | 23 | # |
michael@0 | 24 | # last=<number> The buster will run until it's exhausted all |
michael@0 | 25 | # the URLs in the file, or until it reaches this line in the |
michael@0 | 26 | # file; e.g., setting it to "5" will load five URLs. |
michael@0 | 27 | # |
michael@0 | 28 | # refresh=<number> The timeout (in seconds) to wait before doing |
michael@0 | 29 | # a page refresh, and thus loading the next URL. Defaults to |
michael@0 | 30 | # thirty. |
michael@0 | 31 | |
michael@0 | 32 | use CGI; |
michael@0 | 33 | |
michael@0 | 34 | # Find the page'th URL in the file with the specified name |
michael@0 | 35 | sub FindURL($$) |
michael@0 | 36 | { |
michael@0 | 37 | my ($file, $page) = @_; |
michael@0 | 38 | |
michael@0 | 39 | open URLS, $file |
michael@0 | 40 | || die("can't open $::File"); |
michael@0 | 41 | |
michael@0 | 42 | LINE: while (<URLS>) { |
michael@0 | 43 | next LINE if /^#/; |
michael@0 | 44 | last LINE unless --$page; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | close URLS; |
michael@0 | 48 | |
michael@0 | 49 | chomp; |
michael@0 | 50 | return $_; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | # Scrape parameters |
michael@0 | 54 | $::Query = new CGI; |
michael@0 | 55 | |
michael@0 | 56 | $::File = $::Query->param("file"); |
michael@0 | 57 | $::File = "top100.txt" unless $::File; |
michael@0 | 58 | |
michael@0 | 59 | $::Page = $::Query->param("page"); |
michael@0 | 60 | $::Page = 0 unless $::Page; |
michael@0 | 61 | $::URL = FindURL($::File, ++$::Page); |
michael@0 | 62 | |
michael@0 | 63 | $::Last = $::Query->param("last"); |
michael@0 | 64 | $::Last = -1 unless $::Last; |
michael@0 | 65 | |
michael@0 | 66 | $::Refresh = $::Query->param("refresh"); |
michael@0 | 67 | $::Refresh = 30 unless $::Refresh; |
michael@0 | 68 | |
michael@0 | 69 | # Header |
michael@0 | 70 | print qq{Content-type: text/html |
michael@0 | 71 | |
michael@0 | 72 | <html> |
michael@0 | 73 | <head> |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | # Meat |
michael@0 | 77 | if ($::URL && ($::Page <= $::Last || $::Last == -1)) { |
michael@0 | 78 | # Make a web page that'll load $::URL in an IFRAME, with |
michael@0 | 79 | # a meta-refresh that'll reload us again in short order. |
michael@0 | 80 | print qq{<meta http-equiv="Pragma" content="no-cache"> |
michael@0 | 81 | <meta http-equiv="refresh" content="$::Refresh;url=buster.cgi?file=$::File&page=$::Page&last=$::Last&refresh=$::Refresh"> |
michael@0 | 82 | <title>BrowserBuster II: $::URL</title> |
michael@0 | 83 | <style type="text/css"> |
michael@0 | 84 | body { |
michael@0 | 85 | overflow: hidden; |
michael@0 | 86 | border: 0; |
michael@0 | 87 | margin: 0; |
michael@0 | 88 | } |
michael@0 | 89 | </style> |
michael@0 | 90 | </head> |
michael@0 | 91 | <script> |
michael@0 | 92 | dump("+++ loading $::URL\\n"); |
michael@0 | 93 | </script> |
michael@0 | 94 | <body> |
michael@0 | 95 | }; |
michael@0 | 96 | print "$::File: $::URL"; |
michael@0 | 97 | if ($::Last != -1) { |
michael@0 | 98 | print " ($::Page of $::Last)<br>"; |
michael@0 | 99 | } |
michael@0 | 100 | print qq{ |
michael@0 | 101 | <iframe width="100%" height="100%" src="$::URL"> |
michael@0 | 102 | }; |
michael@0 | 103 | } |
michael@0 | 104 | else { |
michael@0 | 105 | # Make a web page that'll close the current browser |
michael@0 | 106 | # window, terminating the test app. |
michael@0 | 107 | print qq{<head> |
michael@0 | 108 | <title>BrowserBuster II: Done!</title> |
michael@0 | 109 | <body onload="window.close();"> |
michael@0 | 110 | All done! |
michael@0 | 111 | }; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | # Footer |
michael@0 | 115 | print qq{</body> |
michael@0 | 116 | </html> |
michael@0 | 117 | }; |