Bug 384192 - Simplify the approach to supporting cross-domain Mochitests by moving all the code into runtests.pl.in (so the harnesses don't have to do anything except use the profile created for them). r=robcee, approval not needed for testing changes during yellow

This commit is contained in:
jwalden%mit.edu 2007-08-10 19:04:54 +00:00
Родитель 0dd09b4bc9
Коммит 65ac9d5793
5 изменённых файлов: 57 добавлений и 40 удалений

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

@ -99,6 +99,36 @@ use constant CHROMETESTS_URL => "http://" . TEST_SERVER_HOST . CHROME_PATH;
# (particularly after a build) takes forever. # (particularly after a build) takes forever.
use constant SERVER_STARTUP_TIMEOUT => 45; use constant SERVER_STARTUP_TIMEOUT => 45;
# Since some tests require cross-domain support in Mochitest, across ports,
# domains, subdomains, etc. we use a proxy autoconfig hack to map a bunch of
# servers onto localhost:8888. We have to grant them the same privileges as
# localhost:8888 here, since the browser only knows them as the URLs they're
# pretending to be.
my @servers = ("localhost:8888", # MUST be first -- see PAC pref-setting code
"example.org:80",
"test1.example.org:80",
"test2.example.org:80",
"sub1.test1.example.org:80",
"sub1.test2.example.org:80",
"sub2.test1.example.org:80",
"sub2.test2.example.org:80",
"example.org:8000",
"test1.example.org:8000",
"test2.example.org:8000",
"sub1.test1.example.org:8000",
"sub1.test2.example.org:8000",
"sub2.test1.example.org:8000",
"sub2.test2.example.org:8000",
"example.com:80",
"test1.example.com:80",
"test2.example.com:80",
"sub1.test1.example.com:80",
"sub1.test2.example.com:80",
"sub2.test1.example.com:80",
"sub2.test2.example.com:80");
my $profile = "mochitesttestingprofile"; my $profile = "mochitesttestingprofile";
my $profile_dir = "$FindBin::Bin/$profile"; my $profile_dir = "$FindBin::Bin/$profile";
@ -367,49 +397,43 @@ user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("browser.warnOnQuit", false); user_pref("browser.warnOnQuit", false);
PREFEND PREFEND
# # Grant God-power to all the servers on which tests can run.
# Since some tests require cross-domain support in Mochitest, across ports,
# domains, subdomains, etc. we have a proxying hack in cross-domain.js which
# maps a bunch of servers onto localhost:8888. We have to grant them the same
# privileges as localhost:8888 here, since the browser only knows them as the
# URLs they're pretending to be. See cross-domain.js for the other copy of
# this list.
#
# KEEP THESE TWO LISTS IN SYNC!
#
my @servers = ("http://localhost:8888",
"http://example.org:80",
"http://test1.example.org:80",
"http://test2.example.org:80",
"http://sub1.test1.example.org:80",
"http://sub1.test2.example.org:80",
"http://sub2.test1.example.org:80",
"http://sub2.test2.example.org:80",
"http://example.org:8000",
"http://test1.example.org:8000",
"http://test2.example.org:8000",
"http://sub1.test1.example.org:8000",
"http://sub1.test2.example.org:8000",
"http://sub2.test1.example.org:8000",
"http://sub2.test2.example.org:8000",
"http://example.com:80",
"http://test1.example.com:80",
"http://test2.example.com:80",
"http://sub1.test1.example.com:80",
"http://sub1.test2.example.com:80",
"http://sub2.test1.example.com:80",
"http://sub2.test2.example.com:80");
my $i = 1; my $i = 1;
my $server; my $server;
foreach $server (@servers) { foreach $server (@servers) {
$pref_content .= <<SERVERPREFEND; $pref_content .= <<SERVERPREFEND;
user_pref("capability.principal.codebase.p$i.granted", "UniversalXPConnect UniversalBrowserRead UniversalBrowserWrite UniversalPreferencesRead UniversalPreferencesWrite UniversalFileRead"); user_pref("capability.principal.codebase.p$i.granted", "UniversalXPConnect UniversalBrowserRead UniversalBrowserWrite UniversalPreferencesRead UniversalPreferencesWrite UniversalFileRead");
user_pref("capability.principal.codebase.p$i.id", "$server"); user_pref("capability.principal.codebase.p$i.id", "http://$server");
user_pref("capability.principal.codebase.p$i.subjectName", ""); user_pref("capability.principal.codebase.p$i.subjectName", "");
SERVERPREFEND SERVERPREFEND
$i++; $i++;
} }
# Now actually create the preference to make the proxying happen, stripping
# off the first server because it's the one to which we proxy all the others.
my $quotedServers = join(", ", map("'" . $_ . "'", @servers[1 .. $#servers]));
my $pacURL = "data:text/plain,";
$pacURL .= "function FindProxyForURL(url, host) ";
$pacURL .= "{ ";
$pacURL .= " var servers = [$quotedServers]; ";
$pacURL .= " var regex = ";
$pacURL .= " new RegExp('http://(.*?(:\\\\\\\\d+)?)/'); ";
$pacURL .= " var matches = regex.exec(url); ";
$pacURL .= " var hostport = matches[1], port = matches[2]; ";
$pacURL .= " if (!port) ";
$pacURL .= " hostport += ':80'; ";
$pacURL .= " if (servers.indexOf(hostport) >= 0) ";
$pacURL .= " return 'PROXY localhost:8888'; ";
$pacURL .= " return 'DIRECT'; ";
$pacURL .= "}";
$pref_content .= <<PROXYPREFEND;
user_pref("network.proxy.type", 2);
user_pref("network.proxy.autoconfig_url", "$pacURL");
PROXYPREFEND
my $chrome_content = <<CHROMEEND; my $chrome_content = <<CHROMEEND;
\@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */ \@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */
toolbar, toolbar,

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

@ -401,8 +401,6 @@ function testListing(metadata, response)
src: "/tests/SimpleTest/TestRunner.js"}), src: "/tests/SimpleTest/TestRunner.js"}),
SCRIPT({type: "text/javascript", SCRIPT({type: "text/javascript",
src: "/tests/SimpleTest/MozillaFileLogger.js"}), src: "/tests/SimpleTest/MozillaFileLogger.js"}),
SCRIPT({type: "text/javascript",
src: "/tests/SimpleTest/cross-domain.js"}),
SCRIPT({type: "text/javascript", SCRIPT({type: "text/javascript",
src: "/tests/SimpleTest/quit.js"}), src: "/tests/SimpleTest/quit.js"}),
SCRIPT({type: "text/javascript", SCRIPT({type: "text/javascript",

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

@ -51,7 +51,6 @@ _SIMPLETEST_FILES = MozillaFileLogger.js \
TestRunner.js \ TestRunner.js \
setup.js \ setup.js \
EventUtils.js \ EventUtils.js \
cross-domain.js \
$(NULL) $(NULL)
libs:: $(_SIMPLETEST_FILES) libs:: $(_SIMPLETEST_FILES)

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

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

@ -99,10 +99,6 @@ function goQuitApplication()
return false; return false;
} }
// shut down cross-domain mapping (really reverts preference values)
if (typeof crossDomain != "undefined")
crossDomain.disable();
const kAppStartup = '@mozilla.org/toolkit/app-startup;1'; const kAppStartup = '@mozilla.org/toolkit/app-startup;1';
const kAppShell = '@mozilla.org/appshell/appShellService;1'; const kAppShell = '@mozilla.org/appshell/appShellService;1';
var appService; var appService;