Mercurial > hg > config
changeset 200:31249cbe4f19
Bug 629691 - pageloader.xpi does not support e10s for Tp chrome testing. r=jmaher
author | Joel Maher <jmaher@mozilla.com> |
---|---|
date | Sun, 30 Jan 2011 10:21:05 -0500 |
parents | eab9ffc922b1 |
children | bffb8b1b0948 |
files | chrome/pageloader.js components/tp-cmdline.js |
diffstat | 2 files changed, 66 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/chrome/pageloader.js Fri Nov 05 09:56:58 2010 -0700 +++ b/chrome/pageloader.js Sun Jan 30 10:21:05 2011 -0500 @@ -62,6 +62,7 @@ var renderReport; var noisy = false; var timeout = -1; +var delay = 250; var timeoutEvent = -1; var running = false; var forceCC = true; @@ -98,6 +99,7 @@ if (args.filter) pageFilterRegexp = new RegExp(args.filter); if (args.noisy) noisy = true; if (args.timeout) timeout = parseInt(args.timeout); + if (args.delay) delay = parseInt(args.delay); forceCC = !args.noForceCC; doRenderTest = args.doRender; @@ -168,6 +170,18 @@ browserWindow.focus(); content = browserWindow.getBrowser(); + + // Load the frame script for e10s / IPC message support + if (content.getAttribute("remote") == "true") { + let contentScript = "data:,addEventListener('load', function(e) { " + + " if (e.originalTarget.defaultView == content) { " + + " sendAsyncMessage('PageLoader:Load', {}); " + + " content.wrappedJSObject.tpRecordTime = function(t) { sendAsyncMessage('PageLoader:RecordTime', { time: t }); } " + + " }" + + "}, true);" + content.messageManager.loadFrameScript(contentScript, false); + } + setTimeout(plLoadPage, 100); }, 500); }; @@ -178,7 +192,7 @@ content = document.getElementById('contentPageloader'); - setTimeout(plLoadPage, 250); + setTimeout(plLoadPage, delay); } } catch(e) { dumpLine(e); @@ -192,12 +206,16 @@ // load the current page, start timing var removeLastAddedListener = null; +var removeLastAddedMsgListener = null; function plLoadPage() { var pageName = pages[pageIndex].url.spec; if (removeLastAddedListener) removeLastAddedListener(); + if (removeLastAddedMsgListener) + removeLastAddedMsgListener(); + if (plPageFlags() & TEST_DOES_OWN_TIMING) { // if the page does its own timing, use a capturing handler // to make sure that we can set up the function for content to call @@ -217,6 +235,16 @@ }; } + // If the test browser is remote (e10s / IPC) we need to use messages to watch for page load + if (content.getAttribute("remote") == "true") { + content.messageManager.addMessageListener('PageLoader:Load', plLoadHandlerMessage); + content.messageManager.addMessageListener('PageLoader:RecordTime', plRecordTimeMessage); + removeLastAddedMsgListener = function() { + content.messageManager.removeMessageListener('PageLoader:Load', plLoadHandlerMessage); + content.messageManager.removeMessageListener('PageLoader:RecordTime', plRecordTimeMessage); + }; + } + if (timeout > 0) { timeoutEvent = setTimeout('loadFail()', timeout); } @@ -243,7 +271,7 @@ report.recordCCTime(tccend - tccstart); } - setTimeout(plLoadPage, 250); + setTimeout(plLoadPage, delay); } else { plStop(false); } @@ -281,7 +309,7 @@ // set up the function for content to call content.contentWindow.wrappedJSObject.tpRecordTime = function (time) { plRecordTime(time); - setTimeout(plNextPage, 250); + setTimeout(plNextPage, delay); }; } @@ -324,6 +352,34 @@ plNextPage(); } +// the onload handler used for remote (e10s) browser +function plLoadHandlerMessage(message) { + if (timeout > 0) { + clearTimeout(timeoutEvent); + } + + // does this page want to do its own timing? + // if so, let's bail + if (plPageFlags() & TEST_DOES_OWN_TIMING) + return; + + var end_time = Date.now(); + var time = (end_time - start_time); + + plRecordTime(time); + + if (doRenderTest) + runRenderTest(); + + plNextPage(); +} + +// the record time handler used for remote (e10s) browser +function plRecordTimeMessage(message) { + plRecordTime(message.json.time); + setTimeout(plNextPage, delay); +} + function runRenderTest() { const redrawsPerSample = 500; @@ -352,7 +408,7 @@ pageIndex = 0; if (cycle < NUM_CYCLES-1) { cycle++; - setTimeout(plLoadPage, 250); + setTimeout(plLoadPage, delay); return; } @@ -372,8 +428,11 @@ dumpLine(e); } - if (content) + if (content) { content.removeEventListener('load', plLoadHandler, true); + if (content.getAttribute("remote") == "true") + content.messageManager.removeMessageListener('PageLoader:Load', plLoadHandlerMessage); + } if (MozillaFileLogger) MozillaFileLogger.close();
--- a/components/tp-cmdline.js Fri Nov 05 09:56:58 2010 -0700 +++ b/components/tp-cmdline.js Sun Jan 30 10:21:05 2011 -0500 @@ -91,6 +91,7 @@ args.offline = cmdLine.handleFlag("tpoffline", false); args.noisy = cmdLine.handleFlag("tpnoisy", false); args.timeout = cmdLine.handleFlagWithParam("tptimeout", false); + args.delay = cmdLine.handleFlagWithParam("tpdelay", false); args.noForceCC = cmdLine.handleFlag("tpnoforcecc", false); } catch (e) { @@ -121,6 +122,7 @@ " -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" + + " -tpdelay Amount of time to wait between each pageload\n" + " -tpnoforcecc Don't force cycle collection between each pageload\n" };