зеркало из https://github.com/mozilla/pjs.git
Bug 201356, make page load tests support XML documents, r=jrgm.
This commit is contained in:
Родитель
e9ff3402eb
Коммит
d528efc700
|
@ -1,16 +1,16 @@
|
|||
#
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
#
|
||||
# The Original Code is Mozilla page-loader test, released Aug 5, 2001
|
||||
#
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
|
@ -18,8 +18,9 @@
|
|||
#
|
||||
# Contributor(s):
|
||||
# John Morrison <jrgm@netscape.com>, original author
|
||||
#
|
||||
#
|
||||
# Heikki Toivonen <heikki@netscape.com>
|
||||
#
|
||||
#
|
||||
package PageData;
|
||||
use strict;
|
||||
use vars qw($MagicString $ClientJS); # defined at end of file
|
||||
|
@ -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.
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
#
|
||||
# The Original Code is Mozilla page-loader test, released Aug 5, 2001
|
||||
#
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
|
@ -19,7 +19,8 @@
|
|||
#
|
||||
# Contributor(s):
|
||||
# John Morrison <jrgm@netscape.com>, original author
|
||||
#
|
||||
# Heikki Toivonen <heikki@netscape.com>
|
||||
#
|
||||
|
||||
use strict;
|
||||
use CGI::Request;
|
||||
|
@ -29,7 +30,7 @@ use POSIX qw(strftime);
|
|||
use DBI;
|
||||
|
||||
# list of test pages, JS to insert, httpbase, filebase, etc.
|
||||
use PageData;
|
||||
use PageData;
|
||||
|
||||
use vars qw(%params $req $cgi $dbh $pagedata
|
||||
$gStartNow $gStartNowStr
|
||||
|
@ -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...
|
||||
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
#
|
||||
#
|
||||
|
||||
HTTPBASE: http://somehost.somedomain.sometld/content/base/
|
||||
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
|
||||
home.netscape.com index.html # optionally specify a filename
|
||||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче