#!/usr/bin/perl ############################################################ # &outputDebug(); # uncomment this to enable debug mode output # On the web, see http://www.bath.ac.uk/%7Epy8ieh/cgi/development/tests/tables ############################################################ # name: Tables # author: Ian Hickson # license: GPL # description: serious stress tests for table layout # This test is at: # http://www.bath.ac.uk/%7Epy8ieh/cgi/development/tests/tables ############################################################ # Initialise System use lib '../utils'; use strict 'vars'; $output::mediaPath = '../../../media/'; $output::appName = 'Table Stress Tests'; $output::appStyle = 'style/table-test.css'; $output::authorContact = 'http://www.bath.ac.uk/%7Epy8ieh/'; $output::authorName = 'Ian Hickson'; $output::authorEmail = 'py8ieh=website=cgi=development=tests=tables@bath.ac.uk'; require 'inputRoutines.pl'; # get cookies, parameters require 'outputRoutines.pl'; # so that we can output stuff ############################################################ $param::tables = 1 unless defined($param::tables); $param::heads = 0 unless defined($param::heads); $param::foots = 0 unless defined($param::foots); $param::bodies = 1 unless defined($param::bodies); $param::rows = 5 unless defined($param::rows); $param::cols = 5 unless defined($param::cols); $param::delay = 0 unless defined($param::delay); $param::junk = 6 unless defined($param::junk); $param::confusion = 0 unless defined($param::confusion); $param::tablestyle = 'table-layout: fixed; width: 80%;' unless defined($param::tablestyle); &output::printHTMLHeader(); print '

Version 2.2! Now with Extra Confusion Parameter!

'; print "
  1. Tables: (tables per test)
  2. Head: (include 1 <thead> per table)
  3. Foot: (include 1 <tfoot> per table)
  4. Bodies: (<tbody>s per table)
  5. Rows: (rows per table section)
  6. Cols: (cells per row)
  7. Delay: (seconds delay per cell)
    • Include KB of compressible junk in between each cell (to force everything on the network to flush caches between each cell)
  8. Confusion Offset: (normal cells between extra cells)
  9. Table Style: (content of table's style attribute)

"; my ($total) = $param::tables * ($param::rows * $param::cols) * ($param::heads + $param::bodies + $param::foots); print "

$param::tables test table".($param::tables == 1 ? '' : 's')." × ($param::rows row".($param::rows == 1 ? '' : 's')." × $param::cols cell".($param::cols == 1 ? '' : 's').") × ($param::heads header".($param::heads == 1 ? '' : 's')." + $param::bodies bod".($param::bodies == 1 ? 'y' : 'ies')." + $param::foots footer".($param::foots == 1 ? '' : 's').") = $total cell".($total == 1 ? '' : 's')." total".(($param::delay > 0) ? (" (plus ".($total * $param::delay)." second".(($total * $param::delay) == 1 ? '' : 's')." delay minimum)") : "") .($param::confusion > 0 ? ", excluding any extra confusion cell" : "").".

"; my ($t, $x, $y); my ($cells) = $param::confusion; for ($t = 1; $t <= $param::tables; $t++) { print " \n"; for ($b = 1; $b <= $param::heads; $b++) { print " \n"; &docells('H'); print " \n"; } for ($b = 1; $b <= $param::foots; $b++) { print " \n"; &docells('F'); print " \n"; } for ($b = 1; $b <= $param::bodies; $b++) { print " \n"; &docells('B'); print " \n"; } print "
\n\n"; } &output::printHTMLFooter(); ############################################################ sub docells { my($T) = @_; my($JUNK); for ($x = 1; $x <= $param::rows; $x++) { print " "; for ($y = 1; $y <= $param::cols; $y++) { print " $T $x:$y "; if ($param::delay > 0) { sleep $param::delay; if ($param::junk) { print ""; } } print " "; if (($param::confusion > 0) and (--$cells <= 0)) { print " extra cell! "; $cells = $param::confusion; } } print "\n"; } }