Bug 596580: Fix mozJSSubScriptLoader's version finding. (r=brendan)
[mozilla-central.git] / tools / footprint / buster.cgi
blobdc6888843e775c6a0d28e37c85548d58dd6c8b7c
1 #!/usr/bin/perl
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
16 # The Original Code is buster.cgi, released
17 # November 13, 2000.
19 # The Initial Developer of the Original Code is
20 # Netscape Communications Corporation.
21 # Portions created by the Initial Developer are Copyright (C) 2000
22 # the Initial Developer. All Rights Reserved.
24 # Contributor(s):
25 # Chris Waterson <waterson@netscape.com>
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
41 # This is a modified version of Chris Hofmann's <chofmann@netscape.com>
42 # infamous "browser buster" test harness. It's a bit simpler (CGI
43 # instead of using cookies; IFRAME instead of FRAMESET), and has some
44 # extra parameters that make it a bit easier to test with, but it's
45 # pretty faithful otherwise.
47 # It accepts a couple of parameters, including
49 # file=<filename> Set this to the name of the file containing
50 # the URLs that you want the buster to cycle through. This
51 # might be a security hole, so don't run this script on a
52 # server with s3kret stuff on it, mmkay?
54 # page=<number> This is used to maintain state, and is the line
55 # number in the file that the buster will pull up in the
56 # IFRAME. Set if by hand if you need to for some reason.
58 # last=<number> The buster will run until it's exhausted all
59 # the URLs in the file, or until it reaches this line in the
60 # file; e.g., setting it to "5" will load five URLs.
62 # refresh=<number> The timeout (in seconds) to wait before doing
63 # a page refresh, and thus loading the next URL. Defaults to
64 # thirty.
66 use CGI;
68 # Find the page'th URL in the file with the specified name
69 sub FindURL($$)
71 my ($file, $page) = @_;
73 open URLS, $file
74 || die("can't open $::File");
76 LINE: while (<URLS>) {
77 next LINE if /^#/;
78 last LINE unless --$page;
81 close URLS;
83 chomp;
84 return $_;
87 # Scrape parameters
88 $::Query = new CGI;
90 $::File = $::Query->param("file");
91 $::File = "top100.txt" unless $::File;
93 $::Page = $::Query->param("page");
94 $::Page = 0 unless $::Page;
95 $::URL = FindURL($::File, ++$::Page);
97 $::Last = $::Query->param("last");
98 $::Last = -1 unless $::Last;
100 $::Refresh = $::Query->param("refresh");
101 $::Refresh = 30 unless $::Refresh;
103 # Header
104 print qq{Content-type: text/html
106 <html>
107 <head>
110 # Meat
111 if ($::URL && ($::Page <= $::Last || $::Last == -1)) {
112 # Make a web page that'll load $::URL in an IFRAME, with
113 # a meta-refresh that'll reload us again in short order.
114 print qq{<meta http-equiv="Pragma" content="no-cache">
115 <meta http-equiv="refresh" content="$::Refresh;url=buster.cgi?file=$::File&page=$::Page&last=$::Last&refresh=$::Refresh">
116 <title>BrowserBuster II: $::URL</title>
117 <style type="text/css">
118 body {
119 overflow: hidden;
120 border: 0;
121 margin: 0;
123 </style>
124 </head>
125 <script>
126 dump("+++ loading $::URL\\n");
127 </script>
128 <body>
130 print "$::File: $::URL";
131 if ($::Last != -1) {
132 print " ($::Page of $::Last)<br>";
134 print qq{
135 <iframe width="100%" height="100%" src="$::URL">
138 else {
139 # Make a web page that'll close the current browser
140 # window, terminating the test app.
141 print qq{<head>
142 <title>BrowserBuster II: Done!</title>
143 <body onload="window.close();">
144 All done!
148 # Footer
149 print qq{</body>
150 </html>