Bug 1156985 - Fix crashing xpcshell test_signed_inject.js. r=dveditz, a=sledru
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 11 May 2015 12:29:44 -0700
changeset 274703 290048f1bb9a4cf4b269861b0dfc87a5a5fbd869
parent 274702 b91621794c1c0ab439116446089482a33cb0b76f
child 274704 eed3673082b14f1cf6b1aa8d758d722f64c764cc
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz, sledru
bugs1156985
milestone40.0a2
Bug 1156985 - Fix crashing xpcshell test_signed_inject.js. r=dveditz, a=sledru
toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
@@ -44,16 +44,23 @@ function resetPrefs() {
   Services.prefs.setIntPref("bootstraptest.install_reason", -1);
   Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
   Services.prefs.setIntPref("bootstraptest.startup_oldversion", -1);
   Services.prefs.setIntPref("bootstraptest.shutdown_newversion", -1);
   Services.prefs.setIntPref("bootstraptest.install_oldversion", -1);
   Services.prefs.setIntPref("bootstraptest.uninstall_newversion", -1);
 }
 
+function clearCache(file) {
+  if (TEST_UNPACKED)
+    return;
+
+  Services.obs.notifyObservers(file, "flush-cache-entry", null);
+}
+
 function getActiveVersion() {
   return Services.prefs.getIntPref("bootstraptest.active_version");
 }
 
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
 
   // Start and stop the manager to initialise everything in the profile before
@@ -62,97 +69,101 @@ function run_test() {
   shutdownManager();
   resetPrefs();
 
   run_next_test();
 }
 
 // Injecting into profile (bootstrap)
 add_task(function*() {
-  manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.unsigned), profileDir, ID);
+  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.unsigned), profileDir, ID);
 
   startupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_true(addon.appDisabled);
   do_check_false(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
   do_check_eq(getActiveVersion(), -1);
 
   addon.uninstall();
   yield promiseShutdownManager();
   resetPrefs();
 
-  do_check_false(getFileForAddon(profileDir, ID).exists());
+  do_check_false(file.exists());
+  clearCache(file);
 });
 
 add_task(function*() {
-  manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
-  breakAddon(getFileForAddon(profileDir, ID));
+  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
+  breakAddon(file);
 
   startupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_true(addon.appDisabled);
   do_check_false(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   do_check_eq(getActiveVersion(), -1);
 
   addon.uninstall();
   yield promiseShutdownManager();
   resetPrefs();
 
-  do_check_false(getFileForAddon(profileDir, ID).exists());
+  do_check_false(file.exists());
+  clearCache(file);
 });
 
 add_task(function*() {
-  manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.badid), profileDir, ID);
+  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.badid), profileDir, ID);
 
   startupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_true(addon.appDisabled);
   do_check_false(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   do_check_eq(getActiveVersion(), -1);
 
   addon.uninstall();
   yield promiseShutdownManager();
   resetPrefs();
 
-  do_check_false(getFileForAddon(profileDir, ID).exists());
+  do_check_false(file.exists());
+  clearCache(file);
 });
 
 // Installs a signed add-on then modifies it in place breaking its signing
 add_task(function*() {
-  manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
+  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
 
   // Make it appear to come from the past so when we modify it later it is
   // detected during startup. Obviously malware can bypass this method of
   // detection but the periodic scan will catch that
-  yield promiseSetExtensionModifiedTime(getFileForAddon(profileDir, ID).path, Date.now() - 600000);
+  yield promiseSetExtensionModifiedTime(file.path, Date.now() - 600000);
 
   startupManager();
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_false(addon.appDisabled);
   do_check_true(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
   do_check_eq(getActiveVersion(), 2);
 
   yield promiseShutdownManager();
   do_check_eq(getActiveVersion(), 0);
 
-  breakAddon(getFileForAddon(profileDir, ID));
+  clearCache(file);
+  breakAddon(file);
   resetPrefs();
 
   startupManager();
 
   addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_true(addon.appDisabled);
   do_check_false(addon.isActive);
@@ -162,101 +173,106 @@ add_task(function*() {
   let ids = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
   do_check_eq(ids.length, 1);
   do_check_eq(ids[0], ID);
 
   addon.uninstall();
   yield promiseShutdownManager();
   resetPrefs();
 
-  do_check_false(getFileForAddon(profileDir, ID).exists());
+  do_check_false(file.exists());
+  clearCache(file);
 });
 
 // Injecting into profile (non-bootstrap)
 add_task(function*() {
-  manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.unsigned), profileDir, ID);
+  let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.unsigned), profileDir, ID);
 
   startupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_true(addon.appDisabled);
   do_check_false(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
   do_check_false(isExtensionInAddonsList(profileDir, ID));
 
   addon.uninstall();
   yield promiseRestartManager();
   yield promiseShutdownManager();
 
-  do_check_false(getFileForAddon(profileDir, ID).exists());
+  do_check_false(file.exists());
+  clearCache(file);
 });
 
 add_task(function*() {
-  manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
-  breakAddon(getFileForAddon(profileDir, ID));
+  let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
+  breakAddon(file);
 
   startupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_true(addon.appDisabled);
   do_check_false(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   do_check_false(isExtensionInAddonsList(profileDir, ID));
 
   addon.uninstall();
   yield promiseRestartManager();
   yield promiseShutdownManager();
 
-  do_check_false(getFileForAddon(profileDir, ID).exists());
+  do_check_false(file.exists());
+  clearCache(file);
 });
 
 add_task(function*() {
-  manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.badid), profileDir, ID);
+  let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.badid), profileDir, ID);
 
   startupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_true(addon.appDisabled);
   do_check_false(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   do_check_false(isExtensionInAddonsList(profileDir, ID));
 
   addon.uninstall();
   yield promiseRestartManager();
   yield promiseShutdownManager();
 
-  do_check_false(getFileForAddon(profileDir, ID).exists());
+  do_check_false(file.exists());
+  clearCache(file);
 });
 
 // Installs a signed add-on then modifies it in place breaking its signing
 add_task(function*() {
-  manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
+  let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
 
   // Make it appear to come from the past so when we modify it later it is
   // detected during startup. Obviously malware can bypass this method of
   // detection but the periodic scan will catch that
-  yield promiseSetExtensionModifiedTime(getFileForAddon(profileDir, ID).path, Date.now() - 60000);
+  yield promiseSetExtensionModifiedTime(file.path, Date.now() - 60000);
 
   startupManager();
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_false(addon.appDisabled);
   do_check_true(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
   do_check_true(isExtensionInAddonsList(profileDir, ID));
 
   yield promiseShutdownManager();
 
-  breakAddon(getFileForAddon(profileDir, ID));
+  clearCache(file);
+  breakAddon(file);
 
   startupManager();
 
   addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
   do_check_true(addon.appDisabled);
   do_check_false(addon.isActive);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
@@ -265,17 +281,18 @@ add_task(function*() {
   let ids = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
   do_check_eq(ids.length, 1);
   do_check_eq(ids[0], ID);
 
   addon.uninstall();
   yield promiseRestartManager();
   yield promiseShutdownManager();
 
-  do_check_false(getFileForAddon(profileDir, ID).exists());
+  do_check_false(file.exists());
+  clearCache(file);
 });
 
 // Stage install then modify before startup (non-bootstrap)
 add_task(function*() {
   startupManager();
   yield promiseInstallAllFiles([do_get_file(DATA + ADDONS.nonbootstrap.signed)]);
   yield promiseShutdownManager();
 
@@ -286,18 +303,17 @@ add_task(function*() {
 
   breakAddon(staged);
   startupManager();
 
   // Should have refused to install the broken staged version
   let addon = yield promiseAddonByID(ID);
   do_check_eq(addon, null);
 
-  let install = getFileForAddon(profileDir, ID);
-  do_check_false(install.exists());
+  clearCache(staged);
 
   yield promiseShutdownManager();
 });
 
 // Manufacture staged install (bootstrap)
 add_task(function*() {
   let stage = profileDir.clone();
   stage.append("staged");
@@ -307,14 +323,14 @@ add_task(function*() {
 
   startupManager();
 
   // Should have refused to install the broken staged version
   let addon = yield promiseAddonByID(ID);
   do_check_eq(addon, null);
   do_check_eq(getActiveVersion(), -1);
 
-  let install = getFileForAddon(profileDir, ID);
-  do_check_false(install.exists());
+  do_check_false(file.exists());
+  clearCache(file);
 
   yield promiseShutdownManager();
   resetPrefs();
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
@@ -233,17 +233,16 @@ skip-if = os == "android"
 [test_pluginBlocklistCtp.js]
 # Bug 676992: test consistently fails on Android
 fail-if = buildapp == "mulet" || os == "android"
 [test_pref_properties.js]
 [test_registry.js]
 [test_safemode.js]
 [test_signed_verify.js]
 [test_signed_inject.js]
-skip-if = true
 [test_signed_install.js]
 run-sequentially = Uses hardcoded ports in xpi files.
 [test_signed_migrate.js]
 [test_startup.js]
 # Bug 676992: test consistently fails on Android
 fail-if = os == "android"
 [test_syncGUID.js]
 [test_strictcompatibility.js]