Bug 1173320 - patch 8/8 - Fix e10s tests for DeviceStorage API, r=smaug
☠☠ backed out by bd8284e36c7c ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 19 Mar 2016 14:35:16 +0100
changeset 313240 e5c224d964bcfe9f79be206aed262211348d4c57
parent 313239 db971ba7c26de1d0849afb6640dd5232b8d9a80f
child 313241 bd8284e36c7c03dbf2309dc9417eb1b62eecf25a
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1173320
milestone48.0a1
Bug 1173320 - patch 8/8 - Fix e10s tests for DeviceStorage API, r=smaug
dom/devicestorage/DeviceStorageStatics.cpp
dom/devicestorage/test/devicestorage_common.js
dom/devicestorage/test/test_overrideDir.html
--- a/dom/devicestorage/DeviceStorageStatics.cpp
+++ b/dom/devicestorage/DeviceStorageStatics.cpp
@@ -577,35 +577,35 @@ DeviceStorageStatics::Deregister()
 void
 DeviceStorageStatics::ResetOverrideRootDir()
 {
   MOZ_ASSERT(NS_IsMainThread());
   sMutex.AssertCurrentThreadOwns();
   nsCOMPtr<nsIFile> f;
   DS_LOG_INFO("");
 
-  if (Preferences::GetBool(kPrefTesting, false)) {
+  // For users running on desktop, it's convenient to be able to override
+  // all of the directories to point to a single tree, much like what happens
+  // on a real device.
+  const nsAdoptingString& overrideRootDir =
+    mozilla::Preferences::GetString(kPrefOverrideRootDir);
+  if (overrideRootDir && !overrideRootDir.IsEmpty()) {
+    NS_NewLocalFile(overrideRootDir, false, getter_AddRefs(f));
+  }
+
+  if (!f && Preferences::GetBool(kPrefTesting, false)) {
     DS_LOG_INFO("temp");
     nsCOMPtr<nsIProperties> dirService
       = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
     MOZ_ASSERT(dirService);
     dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
     if (f) {
       f->AppendRelativeNativePath(
         NS_LITERAL_CSTRING("device-storage-testing"));
     }
-  } else {
-    // For users running on desktop, it's convenient to be able to override
-    // all of the directories to point to a single tree, much like what happens
-    // on a real device.
-    const nsAdoptingString& overrideRootDir =
-      mozilla::Preferences::GetString(kPrefOverrideRootDir);
-    if (overrideRootDir && !overrideRootDir.IsEmpty()) {
-      NS_NewLocalFile(overrideRootDir, false, getter_AddRefs(f));
-    }
   }
 
   if (f) {
     if (XRE_IsParentProcess()) {
       // Only the parent process can create directories. In testing, because
       // the preference is updated after startup, its entirely possible that
       // the preference updated notification will be received by a child
       // prior to the parent.
--- a/dom/devicestorage/test/devicestorage_common.js
+++ b/dom/devicestorage/test/devicestorage_common.js
@@ -15,22 +15,30 @@ Object.defineProperty(Array.prototype, "
     this.length = from < 0 ? this.length + from : from;
     return this.push.apply(this, rest);
   }
 });
 
 function devicestorage_setup(callback) {
   SimpleTest.waitForExplicitFinish();
 
+  const Cc = SpecialPowers.Cc;
+  const Ci = SpecialPowers.Ci;
+  var directoryService = Cc["@mozilla.org/file/directory_service;1"]
+                           .getService(Ci.nsIProperties);
+  var f = directoryService.get("TmpD", Ci.nsIFile);
+  f.appendRelativePath("device-storage-testing");
+
   let script = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('remove_testing_directory.js'));
 
   script.addMessageListener('directory-removed', function listener () {
     script.removeMessageListener('directory-removed', listener);
     var prefs = [["device.storage.enabled", true],
                  ["device.storage.testing", true],
+                 ["device.storage.overrideRootDir", f.path],
                  ["device.storage.prompt.testing", true]];
     SpecialPowers.pushPrefEnv({"set": prefs}, callback);
   });
 }
 
 function getRandomBuffer() {
   var size = 1024;
   var buffer = new ArrayBuffer(size);
--- a/dom/devicestorage/test/test_overrideDir.html
+++ b/dom/devicestorage/test/test_overrideDir.html
@@ -144,18 +144,17 @@ try {
   const Ci = SpecialPowers.Ci;
   var directoryService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
   var f = directoryService.get("TmpD", Ci.nsIFile);
   f.appendRelativePath("device-storage-sdcard");
   try {
     // The remove will fail if the directory doesn't exist, which is fine.
     f.remove(true);
   } catch (e) {}
-  SpecialPowers.pushPrefEnv({'set': [["device.storage.overrideRootDir", f.path],
-                                     ["device.storage.testing", false]]},
+  SpecialPowers.pushPrefEnv({'set': [["device.storage.overrideRootDir", f.path]]},
     function() {
       startTest();
     });
 } catch(e) {}
 
 });
 
 </script>