зеркало из https://github.com/mozilla/pjs.git
bug 403106 - pageloader needs to timeout on failure to load
a=anodelman r=vlad
This commit is contained in:
Родитель
adf8276012
Коммит
4733eca15e
|
@ -56,6 +56,9 @@ var start_time;
|
|||
var cycle;
|
||||
var report;
|
||||
var renderReport;
|
||||
var noisy = false;
|
||||
var timeout = -1;
|
||||
var timeoutEvent = -1;
|
||||
var running = false;
|
||||
|
||||
var content;
|
||||
|
@ -88,6 +91,8 @@ function plInit() {
|
|||
if (args.width) winWidth = parseInt(args.width);
|
||||
if (args.height) winHeight = parseInt(args.height);
|
||||
if (args.filter) pageFilterRegexp = new RegExp(args.filter);
|
||||
if (args.noisy) noisy = true;
|
||||
if (args.timeout) timeout = parseInt(args.timeout);
|
||||
doRenderTest = args.doRender;
|
||||
|
||||
gIOS = Cc["@mozilla.org/network/io-service;1"]
|
||||
|
@ -199,10 +204,19 @@ function plLoadPage() {
|
|||
};
|
||||
}
|
||||
|
||||
if (timeout > 0) {
|
||||
timeoutEvent = setTimeout('loadFail()', timeout);
|
||||
}
|
||||
start_time = Date.now();
|
||||
content.loadURI(pageName);
|
||||
}
|
||||
|
||||
function loadFail() {
|
||||
var pageName = pages[pageIndex].url.spec;
|
||||
dumpLine("__FAILTimeout exceeded on " + pageName + "__FAIL")
|
||||
plStop(true);
|
||||
}
|
||||
|
||||
function plNextPage() {
|
||||
if (pageIndex < pages.length-1) {
|
||||
pageIndex++;
|
||||
|
@ -216,6 +230,9 @@ function plNextPage() {
|
|||
function plRecordTime(time) {
|
||||
var pageName = pages[pageIndex].url.spec;
|
||||
report.recordTime(pageIndex, time);
|
||||
if (noisy) {
|
||||
dumpLine("Cycle " + (cycle+1) + ": loaded " + pageName);
|
||||
}
|
||||
}
|
||||
|
||||
function plLoadHandlerCapturing(evt) {
|
||||
|
@ -223,6 +240,9 @@ function plLoadHandlerCapturing(evt) {
|
|||
if (evt.type != 'load' ||
|
||||
evt.originalTarget.defaultView.frameElement)
|
||||
return;
|
||||
if (timeout > 0) {
|
||||
clearTimeout(timeoutEvent);
|
||||
}
|
||||
|
||||
if (!(plPageFlags() & TEST_DOES_OWN_TIMING)) {
|
||||
dumpLine("tp: Capturing onload handler used with page that doesn't do its own timing?");
|
||||
|
@ -242,7 +262,9 @@ function plLoadHandler(evt) {
|
|||
if (evt.type != 'load' ||
|
||||
evt.originalTarget.defaultView.frameElement)
|
||||
return;
|
||||
|
||||
if (timeout > 0) {
|
||||
clearTimeout(timeoutEvent);
|
||||
}
|
||||
var end_time = Date.now();
|
||||
var time = (end_time - start_time);
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ PageLoaderCmdLineHandler.prototype =
|
|||
args.width = cmdLine.handleFlagWithParam("tpwidth", false);
|
||||
args.height = cmdLine.handleFlagWithParam("tpheight", false);
|
||||
args.offline = cmdLine.handleFlag("tpoffline", false);
|
||||
args.noisy = cmdLine.handleFlag("tpnoisy", false);
|
||||
args.timeout = cmdLine.handleFlagWithParam("tptimeout", false);
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
|
@ -115,7 +117,10 @@ PageLoaderCmdLineHandler.prototype =
|
|||
" -tprender Run render-only benchmark for each page\n" +
|
||||
" -tpwidth width Width of window\n" +
|
||||
" -tpheight height Height of window\n" +
|
||||
" -tpoffline Force offline mode\n"
|
||||
" -tpoffline Force offline mode\n" +
|
||||
" -tpnoisy Dump the name of the last loaded page to console\n" +
|
||||
" -tptimeout Max amount of time given for a page to load, quit if exceeded\n"
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче