Clean up setting of preferences for reftest. (Bug 608030) r=roc a=blocking2.0:betaN+
☠☠ backed out by 80266029824b ☠ ☠
authorL. David Baron <dbaron@dbaron.org>
Sun, 23 Jan 2011 20:21:40 -0800
changeset 61155 ffebdc3ddb6272691777d1c99f13b12c8947bfa5
parent 61154 54913bb4cb03cefef0392e2fe85fdff8c786359b
child 61156 3248feddc867e210b7490618e7a4e7c5dd035803
push id18251
push userdbaron@mozilla.com
push dateMon, 24 Jan 2011 04:21:58 +0000
treeherdermozilla-central@bc2fda9a8b32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocking2
bugs608030
milestone2.0b10pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Clean up setting of preferences for reftest. (Bug 608030) r=roc a=blocking2.0:betaN+
layout/tools/reftest/reftest-cmdline.js
layout/tools/reftest/reftest.js
layout/tools/reftest/runreftest.py
--- a/layout/tools/reftest/reftest-cmdline.js
+++ b/layout/tools/reftest/reftest-cmdline.js
@@ -87,21 +87,34 @@ RefTestCmdLineHandler.prototype =
     }
 
     /* Ignore the platform's online/offline status while running reftests. */
     var ios = Components.classes["@mozilla.org/network/io-service;1"]
               .getService(Components.interfaces.nsIIOService2);
     ios.manageOfflineStatus = false;
     ios.offline = false;
 
-    /* Force sRGB as an output profile for color management before we load a
-       window. */
+    /**
+     * Manipulate preferences by adding to the *default* branch.  Adding
+     * to the default branch means the changes we make won't get written
+     * back to user preferences.
+     *
+     * We want to do this here rather than in reftest.js because it's
+     * important to force sRGB as an output profile for color management
+     * before we load a window.
+     */
     var prefs = Components.classes["@mozilla.org/preferences-service;1"].
-                getService(Components.interfaces.nsIPrefBranch2);
-    prefs.setBoolPref("gfx.color_management.force_srgb", true);
+                getService(Components.interfaces.nsIPrefService);
+    var branch = prefs.getDefaultBranch("");
+    branch.setBoolPref("gfx.color_management.force_srgb", true);
+    branch.setBoolPref("browser.dom.window.dump.enabled", true);
+    branch.setIntPref("ui.caretBlinkTime", -1);
+    // no slow script dialogs
+    branch.setIntPref("dom.max_script_run_time", 0);
+    branch.setIntPref("dom.max_chrome_script_run_time", 0);
 
     var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
                            .getService(nsIWindowWatcher);
     wwatch.openWindow(null, "chrome://reftest/content/reftest.xul", "_blank",
                       "chrome,dialog=no,all", args);
     cmdLine.preventDefault = true;
   },
 
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -354,21 +354,16 @@ function StartTests()
         ++gTestResults.Exception;
         gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + ex + "\n");
         DoneTests();
     }
 }
 
 function OnRefTestUnload()
 {
-    /* Clear the sRGB forcing pref to leave the profile as we found it. */
-    var prefs = Components.classes["@mozilla.org/preferences-service;1"].
-                getService(Components.interfaces.nsIPrefBranch2);
-    prefs.clearUserPref("gfx.color_management.force_srgb");
-
     gBrowser.removeEventListener("load", OnDocumentLoad, true);
     MozillaFileLogger.close();
 }
 
 // Read all available data from an input stream and return it
 // as a string.
 function getStreamContent(inputStream)
 {
--- a/layout/tools/reftest/runreftest.py
+++ b/layout/tools/reftest/runreftest.py
@@ -66,40 +66,36 @@ class RefTest(object):
     return self.getFullPath(path)
 
   def createReftestProfile(self, options, profileDir):
     "Sets up a profile for reftest."
 
     self.automation.setupPermissionsDatabase(profileDir,
       {'allowXULXBL': [('localhost', True), ('<file>', True)]})
 
-    # Set preferences.
+    # Set preferences for communication between our command line arguments
+    # and the reftest harness.  Preferences that are required for reftest
+    # to work should instead be set in reftest-cmdline.js .
     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);\n' % (options.timeout * 1000))
-    prefsFile.write('user_pref("ui.caretBlinkTime", -1);\n')
 
     if options.totalChunks != None:
       prefsFile.write('user_pref("reftest.totalChunks", %d);\n' % options.totalChunks)
     if options.thisChunk != None:
       prefsFile.write('user_pref("reftest.thisChunk", %d);\n' % options.thisChunk)
     if options.logFile != None:
       prefsFile.write('user_pref("reftest.logFile", "%s");\n' % options.logFile)
 
     for v in options.extraPrefs:
       thispref = v.split("=")
       if len(thispref) < 2:
         print "Error: syntax error in --setpref=" + v
         sys.exit(1)
       part = 'user_pref("%s", %s);\n' % (thispref[0], thispref[1])
       prefsFile.write(part)
-    # no slow script dialogs
-    prefsFile.write('user_pref("dom.max_script_run_time", 0);')
-    prefsFile.write('user_pref("dom.max_chrome_script_run_time", 0);')
     prefsFile.close()
 
     # install the reftest extension bits into the profile
     self.automation.installExtension(os.path.join(SCRIPT_DIRECTORY, "reftest"),
                                                   profileDir,
                                                   "reftest@mozilla.org")