Bug 201356, make page load tests support XML documents, r=jrgm.

This commit is contained in:
heikki%netscape.com 2003-04-29 00:27:06 +00:00
Родитель e9ff3402eb
Коммит d528efc700
4 изменённых файлов: 75 добавлений и 25 удалений

Просмотреть файл

@ -18,6 +18,7 @@
#
# Contributor(s):
# John Morrison <jrgm@netscape.com>, original author
# Heikki Toivonen <heikki@netscape.com>
#
#
package PageData;
@ -71,18 +72,20 @@ sub _init {
# each of the remaining lines are:
# (1) the subdirectory containing the content for this URL,
# (2) the name of the top-level document [optional, default='index.html']
# (3) a character set for this document [optional, default is none]
# (3) mime type for this document [optional, default is text/html]
# (4) a character set for this document [optional, default is none]
# e.g.,
# home.netscape.com
# www.mozilla.org index.html
# www.aol.com default.html
# www.jp.aol.com index.html Shift_JIS
# www.aol.com default.xml text/xml
# www.jp.aol.com index.html text/html Shift_JIS
#
my @ary = split(/\s+/, $_);
$ary[1] ||= 'index.html';
push @{$self->{PageList}}, { Name => $ary[0],
URL => $ary[0] . '/' . $ary[1],
CharSet => $ary[2] || ''
MimeType => $ary[2] || "text/html",
CharSet => $ary[3] || ''
};
}
}
@ -144,6 +147,18 @@ sub charset {
}
sub mimetype {
# get the mimetype for this URL, by index
my $self = shift;
my $arg = shift;
if ($arg =~ /^\d+$/) {
return $self->_checkIndex($arg) ? $self->{PageList}[$arg]{MimeType} : "";
} else {
die "$arg' is not a numeric index";
}
}
sub name {
my $self = shift;
my $arg = shift;
@ -191,6 +206,8 @@ sub _checkIndex {
$MagicString = '<!-- MOZ_INSERT_CONTENT_HOOK -->';
$ClientJS =<<"ENDOFJS";
//<![CDATA[
function moztest_tokenizeQuery() {
var query = {};
var pairs = document.location.search.substring(1).split('&');
@ -261,6 +278,8 @@ function moztest_safetyValve() {
// normal processing is to calculate load time and fetch another URL
window.onload = moztest_onDocumentLoad;
//]]>
ENDOFJS
1; # return true from module

Просмотреть файл

@ -18,6 +18,7 @@
#
# Contributor(s):
# John Morrison <jrgm@netscape.com>, original author
# Heikki Toivonen <heikki@netscape.com>
#
Rough notes on setting up this test app. jrgm@netscape.com 2001/08/05
@ -153,4 +154,31 @@ Options +ExecCGI
this as the way to substitute a BASE HREF and some JS into the page which will control
the exectution of the test.
9) I've probably left some stuff out. Bug jrgm@netscape.com for the missing stuff.
9) You will most likely need to remove all load event handlers from your
test documents (onload attribute on body and handlers added with
addEventListener).
10) Because the system uses (X)HTML base, and some XML constructs are not
subject to that (for example xml-stylesheet processing instructions),
you may need to provide the absolute path to external resources.
11) If your documents are tranformed on the client side with XSLT, you will
need to add this snippet of XSLT to your stylesheet (and possibly make
sure it does not conflict with your other rules):
--8<--------------------------------------------------------------------
<!-- Page Loader -->
<xsl:template match="html:script">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
</xsl:template>
--8<--------------------------------------------------------------------
And near the top of your output rules add:
<xsl:apply-templates select="html:script"/>
Finally make sure you define the XHTML namespace in the stylesheet
with "html" prefix.
12) I've probably left some stuff out. Bug jrgm@netscape.com for the missing stuff.

Просмотреть файл

@ -19,6 +19,7 @@
#
# Contributor(s):
# John Morrison <jrgm@netscape.com>, original author
# Heikki Toivonen <heikki@netscape.com>
#
use strict;
@ -162,7 +163,7 @@ sub outputPage {
open (HTML, "<$file") ||
die "Can't open file: $file, $!";
my $hook = "<script>\n";
my $hook = "<script xmlns='http://www.w3.org/1999/xhtml'>\n";
$hook .= "var g_moztest_Start = (new Date()).getTime();\n";
$hook .= "var g_moztest_ServerTime='" . encodeHiResTime($gStartNow) . "';\n";
$hook .= "var g_moztest_Content='" . $pagedata->name($params{curidx}) . "';\n";
@ -176,7 +177,8 @@ sub outputPage {
if $ENV{SERVER_PORT} == 443;
warn "basepath: $basepath";
$basepath =~ s#^(.*?)(/base/)$#$1/nocache$2# if ($params{nocache});
$hook .= "<base href='". $basepath . $relpath . "'>";
$hook .= "<base href='". $basepath . $relpath .
"' xmlns='http://www.w3.org/1999/xhtml' />";
my $magic = $pagedata->magicString;
my $content = "";
@ -186,11 +188,12 @@ sub outputPage {
}
my $contentTypeHeader;
my $mimetype = $pagedata->mimetype($params{curidx});
my $charset = $pagedata->charset($params{curidx});
if ($charset) {
$contentTypeHeader = qq{Content-type: text/html; charset="$charset"\n\n};
$contentTypeHeader = qq{Content-type: $mimetype; charset="$charset"\n\n};
} else {
$contentTypeHeader = qq{Content-type: text/html\n\n};
$contentTypeHeader = qq{Content-type: $mimetype\n\n};
}
#warn $contentTypeHeader; #XXXjrgm testing...

Просмотреть файл

@ -44,8 +44,8 @@ HTTPBASE: http://somehost.somedomain.sometld/content/base/
FILEBASE: /var/www/html/content/base/
home.netscape.com index.html # optionally specify a filename
my.netscape.com index.html iso-8859-1 # optionally specify a filename and charset
www.aol.com
my.netscape.com index.html text/html iso-8859-1 # optionally specify a filename, mime type and charset
www.aol.com index.html text/html # optionally specify a filename and mime type
www.mapquest.com
www.moviefone.com
www.digitalcity.com