From 43ef3e73fda94419b3c4ca2e070b330aa0b7c721 Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Fri, 19 Jun 2009 20:17:55 +0200 Subject: [PATCH] Bug 471579 - reftests timeout very frequently when run on maemo device; r=(dbaron + ted.mielczarek) --- layout/tools/reftest/reftest.js | 24 +++++++++++++++++++----- layout/tools/reftest/runreftest.py | 10 ++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index de89a405059c..008b5a1bcc82 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -57,7 +57,7 @@ const NS_XREAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1"; -const LOAD_FAILURE_TIMEOUT = 10000; // ms +var gLoadTimeout = 0; // "" const BLANK_URL_FOR_CLEARING = "data:text/html,%3C%21%2D%2DCLEAR%2D%2D%3E"; @@ -141,6 +141,16 @@ function OnRefTestLoad() { gBrowser = document.getElementById("browser"); + /* set the gLoadTimeout */ + try { + var prefs = Components.classes["@mozilla.org/preferences-service;1"]. + getService(Components.interfaces.nsIPrefBranch2); + gLoadTimeout = prefs.getIntPref("reftest.timeout"); + } + catch(e) { + gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518 + } + gBrowser.addEventListener("load", OnDocumentLoad, true); try { @@ -247,9 +257,13 @@ function ReadManifest(aURL) var sandbox = new Components.utils.Sandbox(aURL.spec); var xr = CC[NS_XREAPPINFO_CONTRACTID].getService(CI.nsIXULRuntime); sandbox.MOZ_WIDGET_TOOLKIT = xr.widgetToolkit; - sandbox.xulRuntime = {widgetToolkit: xr.widgetToolkit, - OS: xr.OS, - XPCOMABI: xr.XPCOMABI}; + sandbox.xulRuntime = {widgetToolkit: xr.widgettoolkit, OS: xr.OS}; + + // xr.XPCOMABI throws exception for configurations without full ABI support (mobile builds on ARM) + try { + sandbox.XPCOMABI = xr.XPCOMABI; + } catch(e) {} + var hh = CC[NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX + "http"]. getService(CI.nsIHttpProtocolHandler); sandbox.http = {}; @@ -496,7 +510,7 @@ function StartCurrentURI(aState) "| program error managing timeouts\n"); ++gTestResults.Exception; } - gFailureTimeout = setTimeout(LoadFailed, LOAD_FAILURE_TIMEOUT); + gFailureTimeout = setTimeout(LoadFailed, gLoadTimeout); gFailureReason = "timed out waiting for onload to fire"; gState = aState; diff --git a/layout/tools/reftest/runreftest.py b/layout/tools/reftest/runreftest.py index 87e2d864c7a1..3ce6a6a3c259 100644 --- a/layout/tools/reftest/runreftest.py +++ b/layout/tools/reftest/runreftest.py @@ -55,7 +55,7 @@ def getFullPath(path): "Get an absolute path relative to oldcwd." return os.path.normpath(os.path.join(oldcwd, os.path.expanduser(path))) -def createReftestProfile(profileDir): +def createReftestProfile(options, profileDir): "Sets up a clean profile for reftest." # Start with a clean slate. @@ -65,6 +65,8 @@ def createReftestProfile(profileDir): prefsFile = open(os.path.join(profileDir, "user.js"), "w") prefsFile.write("""user_pref("browser.dom.window.dump.enabled", true); """) + prefsFile.write('user_pref("reftest.timeout", %d);' % options.timeout) + prefsFile.close() # install the reftest extension bits into the profile profileExtensionsPath = os.path.join(profileDir, "extensions") @@ -87,6 +89,10 @@ def main(): action = "append", dest = "extraProfileFiles", default = [], help = "copy specified files/dirs to testing profile") + parser.add_option("--timeout", + action = "store", dest = "timeout", type = "int", + default = 5 * 60 * 1000, # 5 minutes per bug 479518 + help = "reftest will timeout in specified number of milleseconds. [default %default ms].") parser.add_option("--leak-threshold", action = "store", type = "int", dest = "leakThreshold", default = 0, @@ -117,7 +123,7 @@ Are you executing $objdir/_tests/reftest/runreftest.py?""" \ profileDir = None try: profileDir = mkdtemp() - createReftestProfile(profileDir) + createReftestProfile(options, profileDir) copyExtraFilesToProfile(options, profileDir) # browser environment