зеркало из https://github.com/mozilla/pjs.git
Bug 544385 Allow reftest to run tests and read manifests from both http and file system r=dbaron p=jmaher Landed on a CLOSED TREE
This commit is contained in:
Родитель
d89f84387b
Коммит
44f5c62772
|
@ -58,6 +58,7 @@ const NS_XREAPPINFO_CONTRACTID =
|
|||
|
||||
|
||||
var gLoadTimeout = 0;
|
||||
var gRemote = false;
|
||||
|
||||
// "<!--CLEAR-->"
|
||||
const BLANK_URL_FOR_CLEARING = "data:text/html,%3C%21%2D%2DCLEAR%2D%2D%3E";
|
||||
|
@ -158,6 +159,7 @@ function OnRefTestLoad()
|
|||
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch2);
|
||||
gLoadTimeout = prefs.getIntPref("reftest.timeout");
|
||||
gRemote = prefs.getBoolPref("reftest.remote");
|
||||
}
|
||||
catch(e) {
|
||||
gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518
|
||||
|
@ -177,9 +179,13 @@ function OnRefTestLoad()
|
|||
|
||||
gIOService = CC[IO_SERVICE_CONTRACTID].getService(CI.nsIIOService);
|
||||
gDebug = CC[DEBUG_CONTRACTID].getService(CI.nsIDebug2);
|
||||
gServer = CC["@mozilla.org/server/jshttp;1"].
|
||||
createInstance(CI.nsIHttpServer);
|
||||
|
||||
|
||||
if (gRemote) {
|
||||
gServer = null;
|
||||
} else {
|
||||
gServer = CC["@mozilla.org/server/jshttp;1"].
|
||||
createInstance(CI.nsIHttpServer);
|
||||
}
|
||||
try {
|
||||
if (gServer)
|
||||
StartHTTPServer();
|
||||
|
@ -247,12 +253,29 @@ function OnRefTestUnload()
|
|||
gBrowser.removeEventListener("load", OnDocumentLoad, true);
|
||||
}
|
||||
|
||||
// Read all available data from an input stream and return it
|
||||
// as a string.
|
||||
function getStreamContent(inputStream)
|
||||
{
|
||||
var streamBuf = "";
|
||||
var sis = CC["@mozilla.org/scriptableinputstream;1"].
|
||||
createInstance(CI.nsIScriptableInputStream);
|
||||
sis.init(inputStream);
|
||||
|
||||
var available;
|
||||
while ((available = sis.available()) != 0) {
|
||||
streamBuf += sis.read(available);
|
||||
}
|
||||
|
||||
return streamBuf;
|
||||
}
|
||||
|
||||
function ReadTopManifest(aFileURL)
|
||||
{
|
||||
gURLs = new Array();
|
||||
var url = gIOService.newURI(aFileURL, null, null);
|
||||
if (!url || !url.schemeIs("file"))
|
||||
throw "Expected a file URL for the manifest.";
|
||||
if (!url)
|
||||
throw "Expected a file or http URL for the manifest.";
|
||||
ReadManifest(url);
|
||||
}
|
||||
|
||||
|
@ -260,15 +283,20 @@ function ReadTopManifest(aFileURL)
|
|||
// please keep the parser in print-manifest-dirs.py in sync.
|
||||
function ReadManifest(aURL)
|
||||
{
|
||||
var listURL = aURL.QueryInterface(CI.nsIFileURL);
|
||||
|
||||
var secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
|
||||
.getService(CI.nsIScriptSecurityManager);
|
||||
|
||||
var fis = CC[NS_LOCALFILEINPUTSTREAM_CONTRACTID].
|
||||
createInstance(CI.nsIFileInputStream);
|
||||
fis.init(listURL.file, -1, -1, false);
|
||||
var lis = fis.QueryInterface(CI.nsILineInputStream);
|
||||
var listURL = aURL;
|
||||
var channel = gIOService.newChannelFromURI(aURL);
|
||||
var inputStream = channel.open();
|
||||
if (channel instanceof Components.interfaces.nsIHttpChannel
|
||||
&& channel.responseStatus != 200) {
|
||||
dump("REFTEST TEST-UNEXPECTED-FAIL | | HTTP ERROR : " +
|
||||
channel.responseStatus + "\n");
|
||||
}
|
||||
var streamBuf = getStreamContent(inputStream);
|
||||
inputStream.close();
|
||||
var lines = streamBuf.split(/(\n|\r|\r\n)/);
|
||||
|
||||
// Build the sandbox for fails-if(), etc., condition evaluation.
|
||||
var sandbox = new Components.utils.Sandbox(aURL.spec);
|
||||
|
@ -320,13 +348,10 @@ function ReadManifest(aURL)
|
|||
sandbox.nativeThemePref = true;
|
||||
}
|
||||
|
||||
var line = {value:null};
|
||||
var lineNo = 0;
|
||||
var urlprefix = "";
|
||||
do {
|
||||
var more = lis.readLine(line);
|
||||
for each (var str in lines) {
|
||||
++lineNo;
|
||||
var str = line.value;
|
||||
if (str.charAt(0) == "#")
|
||||
continue; // entire line was a comment
|
||||
var i = str.search(/\s+#/);
|
||||
|
@ -395,12 +420,14 @@ function ReadManifest(aURL)
|
|||
var runHttp = false;
|
||||
var httpDepth;
|
||||
if (items[0] == "HTTP") {
|
||||
runHttp = true;
|
||||
runHttp = (aURL.scheme == "file"); // We can't yet run the local HTTP server
|
||||
// for non-local reftests.
|
||||
httpDepth = 0;
|
||||
items.shift();
|
||||
} else if (items[0].match(/HTTP\(\.\.(\/\.\.)*\)/)) {
|
||||
// Accept HTTP(..), HTTP(../..), HTTP(../../..), etc.
|
||||
runHttp = true;
|
||||
runHttp = (aURL.scheme == "file"); // We can't yet run the local HTTP server
|
||||
// for non-local reftests.
|
||||
httpDepth = (items[0].length - 5) / 3;
|
||||
items.shift();
|
||||
}
|
||||
|
@ -430,7 +457,7 @@ function ReadManifest(aURL)
|
|||
throw "Error 3 in manifest file " + aURL.spec + " line " + lineNo;
|
||||
var [testURI] = runHttp
|
||||
? ServeFiles(aURL, httpDepth,
|
||||
listURL.file.parent, [items[1]])
|
||||
listURL, [items[1]])
|
||||
: [gIOService.newURI(items[1], null, listURL)];
|
||||
var prettyPath = runHttp
|
||||
? gIOService.newURI(items[1], null, listURL).spec
|
||||
|
@ -449,7 +476,7 @@ function ReadManifest(aURL)
|
|||
throw "Error 4 in manifest file " + aURL.spec + " line " + lineNo;
|
||||
var [testURI] = runHttp
|
||||
? ServeFiles(aURL, httpDepth,
|
||||
listURL.file.parent, [items[1]])
|
||||
listURL, [items[1]])
|
||||
: [gIOService.newURI(items[1], null, listURL)];
|
||||
var prettyPath = runHttp
|
||||
? gIOService.newURI(items[1], null, listURL).spec
|
||||
|
@ -468,7 +495,7 @@ function ReadManifest(aURL)
|
|||
throw "Error 5 in manifest file " + aURL.spec + " line " + lineNo;
|
||||
var [testURI, refURI] = runHttp
|
||||
? ServeFiles(aURL, httpDepth,
|
||||
listURL.file.parent, [items[1], items[2]])
|
||||
listURL, [items[1], items[2]])
|
||||
: [gIOService.newURI(items[1], null, listURL),
|
||||
gIOService.newURI(items[2], null, listURL)];
|
||||
var prettyPath = runHttp
|
||||
|
@ -488,7 +515,7 @@ function ReadManifest(aURL)
|
|||
} else {
|
||||
throw "Error 6 in manifest file " + aURL.spec + " line " + lineNo;
|
||||
}
|
||||
} while (more);
|
||||
}
|
||||
}
|
||||
|
||||
function AddURIUseCount(uri)
|
||||
|
@ -518,8 +545,11 @@ function BuildUseCounts()
|
|||
}
|
||||
}
|
||||
|
||||
function ServeFiles(manifestURL, depth, directory, files)
|
||||
function ServeFiles(manifestURL, depth, aURL, files)
|
||||
{
|
||||
var listURL = aURL.QueryInterface(CI.nsIFileURL);
|
||||
var directory = listURL.file.parent;
|
||||
|
||||
// Allow serving a tree that's an ancestor of the directory containing
|
||||
// the files so that they can use resources in ../ (etc.).
|
||||
var dirPath = "/";
|
||||
|
|
Загрузка…
Ссылка в новой задаче