1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/footprint/buster.cgi Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 1.4 +#!/usr/bin/perl 1.5 +# 1.6 +# This Source Code Form is subject to the terms of the Mozilla Public 1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.9 + 1.10 +# This is a modified version of Chris Hofmann's <chofmann@netscape.com> 1.11 +# infamous "browser buster" test harness. It's a bit simpler (CGI 1.12 +# instead of using cookies; IFRAME instead of FRAMESET), and has some 1.13 +# extra parameters that make it a bit easier to test with, but it's 1.14 +# pretty faithful otherwise. 1.15 +# 1.16 +# It accepts a couple of parameters, including 1.17 +# 1.18 +# file=<filename> Set this to the name of the file containing 1.19 +# the URLs that you want the buster to cycle through. This 1.20 +# might be a security hole, so don't run this script on a 1.21 +# server with s3kret stuff on it, mmkay? 1.22 +# 1.23 +# page=<number> This is used to maintain state, and is the line 1.24 +# number in the file that the buster will pull up in the 1.25 +# IFRAME. Set if by hand if you need to for some reason. 1.26 +# 1.27 +# last=<number> The buster will run until it's exhausted all 1.28 +# the URLs in the file, or until it reaches this line in the 1.29 +# file; e.g., setting it to "5" will load five URLs. 1.30 +# 1.31 +# refresh=<number> The timeout (in seconds) to wait before doing 1.32 +# a page refresh, and thus loading the next URL. Defaults to 1.33 +# thirty. 1.34 + 1.35 +use CGI; 1.36 + 1.37 +# Find the page'th URL in the file with the specified name 1.38 +sub FindURL($$) 1.39 +{ 1.40 + my ($file, $page) = @_; 1.41 + 1.42 + open URLS, $file 1.43 + || die("can't open $::File"); 1.44 + 1.45 + LINE: while (<URLS>) { 1.46 + next LINE if /^#/; 1.47 + last LINE unless --$page; 1.48 + } 1.49 + 1.50 + close URLS; 1.51 + 1.52 + chomp; 1.53 + return $_; 1.54 +} 1.55 + 1.56 +# Scrape parameters 1.57 +$::Query = new CGI; 1.58 + 1.59 +$::File = $::Query->param("file"); 1.60 +$::File = "top100.txt" unless $::File; 1.61 + 1.62 +$::Page = $::Query->param("page"); 1.63 +$::Page = 0 unless $::Page; 1.64 +$::URL = FindURL($::File, ++$::Page); 1.65 + 1.66 +$::Last = $::Query->param("last"); 1.67 +$::Last = -1 unless $::Last; 1.68 + 1.69 +$::Refresh = $::Query->param("refresh"); 1.70 +$::Refresh = 30 unless $::Refresh; 1.71 + 1.72 +# Header 1.73 +print qq{Content-type: text/html 1.74 + 1.75 +<html> 1.76 +<head> 1.77 +}; 1.78 + 1.79 +# Meat 1.80 +if ($::URL && ($::Page <= $::Last || $::Last == -1)) { 1.81 + # Make a web page that'll load $::URL in an IFRAME, with 1.82 + # a meta-refresh that'll reload us again in short order. 1.83 + print qq{<meta http-equiv="Pragma" content="no-cache"> 1.84 +<meta http-equiv="refresh" content="$::Refresh;url=buster.cgi?file=$::File&page=$::Page&last=$::Last&refresh=$::Refresh"> 1.85 +<title>BrowserBuster II: $::URL</title> 1.86 +<style type="text/css"> 1.87 +body { 1.88 + overflow: hidden; 1.89 + border: 0; 1.90 + margin: 0; 1.91 +} 1.92 +</style> 1.93 +</head> 1.94 +<script> 1.95 +dump("+++ loading $::URL\\n"); 1.96 +</script> 1.97 +<body> 1.98 +}; 1.99 + print "$::File: $::URL"; 1.100 + if ($::Last != -1) { 1.101 + print " ($::Page of $::Last)<br>"; 1.102 + } 1.103 + print qq{ 1.104 +<iframe width="100%" height="100%" src="$::URL"> 1.105 +}; 1.106 +} 1.107 +else { 1.108 + # Make a web page that'll close the current browser 1.109 + # window, terminating the test app. 1.110 + print qq{<head> 1.111 +<title>BrowserBuster II: Done!</title> 1.112 +<body onload="window.close();"> 1.113 +All done! 1.114 +}; 1.115 +} 1.116 + 1.117 +# Footer 1.118 +print qq{</body> 1.119 +</html> 1.120 +};