bug 469855 - allow test parameter to be placed anywhere in query string.

This commit is contained in:
Bob Clary 2009-01-14 07:16:16 -08:00
Родитель c2f97a4fa8
Коммит 12fecc8623
1 изменённых файлов: 97 добавлений и 116 удалений

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

@ -610,106 +610,84 @@ function jsTestDriverBrowserInit()
return;
}
var re = /test=([^;]+);language=(language|type);([a-zA-Z0-9.=;\/]+)/;
var matches = re.exec(document.location.search);
// testpath http://machine/path-to-suite/sub-suite/test.js
var testpath = matches[1];
var attribute = matches[2];
var value = matches[3];
if (testpath)
var properties = {};
var fields = document.location.search.slice(1).split(';');
for (var ifield = 0; ifield < fields.length; ifield++)
{
testpath = decodeURIComponent(testpath);
gTestPath = testpath;
var propertycaptures = /^([^=]+)=(.*)$/.exec(fields[ifield]);
if (!propertycaptures)
{
properties[fields[ifield]] = true;
}
else
{
properties[propertycaptures[1]] = decodeURIComponent(propertycaptures[2]);
if (propertycaptures[1] == 'language')
{
// language=(type|language);mimetype
properties.mimetype = fields[ifield+1];
}
}
}
var ise4x = /e4x\//.test(testpath);
var gczealmatches = /gczeal=([0-9]*)/.exec(document.location.search);
if (gczealmatches)
if (properties.language != 'type')
{
var zeal = Number(gczealmatches[1]);
gczeal(zeal);
try
{
properties.version = /javascript([.0-9]+)/.exec(properties.mimetype)[1];
}
catch(ex)
{
}
}
/*
* since the default setting of jit changed from false to true
* in http://hg.mozilla.org/tracemonkey/rev/685e00e68be9
* bisections which depend upon jit settings can be thrown off.
* default jit(false) to make bisections depending upon jit settings
* consistent over time. This is not needed in shell tests as the default
* jit setting has not changed there.
*/
var jitmatches = /;jit/.exec(document.location.search);
if (jitmatches)
{
jit(true);
}
else
{
jit(false);
}
var versionmatches;
if (attribute == 'type')
{
versionmatches = /version=([.0-9]+)/.exec(value);
}
else
{
versionmatches = /javascript([.0-9]+)/.exec(value);
}
if (versionmatches)
{
gVersion = 10*parseInt(versionmatches[1].replace(/\./g, ''));
}
else if (navigator.userAgent.indexOf('Gecko/') != -1)
if (!properties.version && navigator.userAgent.indexOf('Gecko/') != -1)
{
// If the version is not specified, and the browser is Gecko,
// adjust the version to match the suite version.
if (attribute == 'type')
if (properties.test.match(/^js1_6/))
{
value = 'text/javascript;version=';
properties.version = '1.6';
}
else if (properties.test.match(/^js1_7/))
{
properties.version = '1.7';
}
else if (properties.test.match(/^js1_8/))
{
properties.version = '1.8';
}
else if (properties.test.match(/^js1_8_1/))
{
properties.version = '1.8';
}
else
{
value = 'javascript';
}
if (testpath.match(/^js1_6/))
{
gVersion = 160;
value += '1.6';
}
else if (testpath.match(/^js1_7/))
{
gVersion = 170;
value += '1.7';
}
else if (testpath.match(/^js1_8/))
{
gVersion = 180;
value += '1.8';
}
else if (testpath.match(/^js1_8_1/))
{
gVersion = 180;
value += '1.8';
}
else
{
gVersion = 150;
value += '1.5';
properties.version = '1.5';
}
}
var testpathparts = testpath.split(/\//);
gTestPath = properties.test;
gVersion = 10*parseInt(properties.version.replace(/\./g, ''));
if (properties.gczeal)
{
gczeal(Number(properties.gczeal));
}
/*
* since the default setting of jit changed from false to true
* in http://hg.mozilla.org/tracemonkey/rev/685e00e68be9
* bisections which depend upon jit settings can be thrown off.
* default jit(false) to make bisections depending upon jit settings
* consistent over time. This is not needed in shell tests as the default
* jit setting has not changed there.
*/
jit(properties.jit);
var testpathparts = properties.test.split(/\//);
if (testpathparts.length < 3)
{
@ -720,52 +698,55 @@ function jsTestDriverBrowserInit()
var subsuite = testpathparts[testpathparts.length - 2];
var test = testpathparts[testpathparts.length - 1];
outputscripttag(suitepath + '/shell.js', attribute, value,
ise4x);
outputscripttag(suitepath + '/browser.js', attribute, value,
ise4x);
outputscripttag(suitepath + '/' + subsuite + '/shell.js', attribute, value,
ise4x);
outputscripttag(suitepath + '/' + subsuite + '/browser.js', attribute, value,
ise4x);
outputscripttag(suitepath + '/' + subsuite + '/' + test, attribute, value,
ise4x);
outputscripttag(suitepath + '/shell.js', properties);
outputscripttag(suitepath + '/browser.js', properties);
outputscripttag(suitepath + '/' + subsuite + '/shell.js', properties);
outputscripttag(suitepath + '/' + subsuite + '/browser.js', properties);
outputscripttag(suitepath + '/' + subsuite + '/' + test, properties,
properties.e4x || /e4x\//.test(properties.test));
document.write('<title>' + suitepath + '/' + subsuite + '/' + test +
'<\/title>');
document.write('<title>' + suitepath + '/' + subsuite + '/' + test + '<\/title>');
outputscripttag('js-test-driver-end.js', attribute, value,
false);
outputscripttag('js-test-driver-end.js', properties);
return;
}
function outputscripttag(src, attribute, value, ise4x)
function outputscripttag(src, properties, e4x)
{
if (!src)
{
return;
}
var s = '<script src="' + src + '" ';
if (ise4x)
if (e4x)
{
if (attribute == 'type')
{
value += ';e4x=1 ';
}
else
{
s += ' type="text/javascript';
if (gVersion != 150)
{
s += ';version=' + gVersion/100;
}
s += ';e4x=1" ';
}
// e4x requires type=mimetype;e4x=1
properties.language = 'type';
}
s += attribute + '="' + value + '"><\/script>';
var s = '<script src="' + src + '" ';
if (properties.language != 'type')
{
s += 'language="javascript';
if (properties.version)
{
s += properties.version;
}
}
else
{
s += 'type="' + properties.mimetype;
if (properties.version)
{
s += ';version=' + properties.version;
}
if (e4x)
{
s += ';e4x=1';
}
}
s += '"><\/script>';
document.write(s);
}