diff --git a/layout/tools/pageloader/pageloader.js b/layout/tools/pageloader/pageloader.js index 0ed10941cda..b59978be402 100644 --- a/layout/tools/pageloader/pageloader.js +++ b/layout/tools/pageloader/pageloader.js @@ -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); diff --git a/layout/tools/pageloader/tp-cmdline.js b/layout/tools/pageloader/tp-cmdline.js index e9267bb5c90..2f9c6ffc231 100644 --- a/layout/tools/pageloader/tp-cmdline.js +++ b/layout/tools/pageloader/tp-cmdline.js @@ -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" + };