Bug 1637637 - disable fast shutdown for the test_prefs_store.js and test_prefs_tracker.js tests where it crashes, r=gbrown.
authorFlorian Quèze <florian@queze.net>
Wed, 20 May 2020 16:35:51 +0000
changeset 531319 566d54746a9a4e886039ebcc9da6dd1b78e2ec6b
parent 531318 a8d65c8b993b73d3b04722875fc4b61e0f768f46
child 531320 2e77f3c6d7f105099f14646e3e30ccde8e7adc19
push id37437
push usernerli@mozilla.com
push dateThu, 21 May 2020 02:34:41 +0000
treeherdermozilla-central@3d91ba9e1d25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1637637
milestone78.0a1
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
Bug 1637637 - disable fast shutdown for the test_prefs_store.js and test_prefs_tracker.js tests where it crashes, r=gbrown. Depends on D72407 Differential Revision: https://phabricator.services.mozilla.com/D76167
services/sync/tests/unit/test_prefs_store.js
services/sync/tests/unit/test_prefs_tracker.js
testing/xpcshell/head.js
--- a/services/sync/tests/unit/test_prefs_store.js
+++ b/services/sync/tests/unit/test_prefs_store.js
@@ -18,16 +18,22 @@ AddonTestUtils.init(this);
 AddonTestUtils.createAppInfo(
   "xpcshell@tests.mozilla.org",
   "XPCShell",
   "1",
   "1.9.2"
 );
 AddonTestUtils.overrideCertDB();
 
+// Attempting to set the
+// security.turn_off_all_security_so_that_viruses_can_take_over_this_computer
+// preference to enable Cu.exitIfInAutomation crashes, probably due to
+// shutdown behaviors faked by AddonTestUtils.jsm's cleanup function.
+do_disable_fast_shutdown();
+
 add_task(async function run_test() {
   _("Test fixtures.");
   // Part of this test ensures the default theme, via the preference
   // extensions.activeThemeID, is synced correctly - so we do a little
   // addons initialization to allow this to work.
 
   // Enable application scopes to ensure the builtin theme is going to
   // be installed as part of the the addon manager startup.
--- a/services/sync/tests/unit/test_prefs_tracker.js
+++ b/services/sync/tests/unit/test_prefs_tracker.js
@@ -1,16 +1,22 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const { Preferences } = ChromeUtils.import(
   "resource://gre/modules/Preferences.jsm"
 );
 const { Service } = ChromeUtils.import("resource://services-sync/service.js");
 
+// Attempting to set the
+// security.turn_off_all_security_so_that_viruses_can_take_over_this_computer
+// preference to enable Cu.exitIfInAutomation crashes, probably due to
+// shutdown behaviors faked by AddonTestUtils.jsm's cleanup function.
+do_disable_fast_shutdown();
+
 add_task(async function run_test() {
   let engine = Service.engineManager.get("prefs");
   let tracker = engine._tracker;
 
   let prefs = new Preferences();
 
   try {
     _("tracker.modified corresponds to preference.");
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -29,16 +29,17 @@
 /* globals run_test */
 
 var _quit = false;
 var _passed = true;
 var _tests_pending = 0;
 var _cleanupFunctions = [];
 var _pendingTimers = [];
 var _profileInitialized = false;
+var _fastShutdownDisabled = false;
 
 // Assigned in do_load_child_test_harness.
 var _XPCSHELL_PROCESS;
 
 // Register the testing-common resource protocol early, to have access to its
 // modules.
 var _Services = ChromeUtils.import("resource://gre/modules/Services.jsm", null)
   .Services;
@@ -688,16 +689,21 @@ function _execute_test() {
   if (
     runningInParent &&
     !_AppConstants.RELEASE_OR_BETA &&
     !_AppConstants.DEBUG &&
     !_AppConstants.MOZ_CODE_COVERAGE &&
     !_AppConstants.ASAN &&
     !_AppConstants.TSAN
   ) {
+    if (_fastShutdownDisabled) {
+      _testLogger.info("fast shutdown disabled by the test.");
+      return;
+    }
+
     // Setting this pref is required for Cu.isInAutomation to return true.
     _Services.prefs.setBoolPref(
       "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
       true
     );
     Cu.exitIfInAutomation();
   }
 }
@@ -1181,16 +1187,24 @@ function do_parse_document(aPath, aType)
  * @param aFunction
  *        The function to be called when the test harness has finished running.
  */
 function registerCleanupFunction(aFunction) {
   _cleanupFunctions.push(aFunction);
 }
 
 /**
+ * Ensure the test finishes with a normal shutdown even when it could have
+ * otherwise used the fast Cu.exitIfInAutomation shutdown.
+ */
+function do_disable_fast_shutdown() {
+  _fastShutdownDisabled = true;
+}
+
+/**
  * Returns the directory for a temp dir, which is created by the
  * test harness. Every test gets its own temp dir.
  *
  * @return nsIFile of the temporary directory
  */
 function do_get_tempdir() {
   let env = Cc["@mozilla.org/process/environment;1"].getService(
     Ci.nsIEnvironment