Bug 929816 - Allow devicestorage testing mode to work on travis. r=mikeh
authorDave Hylands <dhylands@mozilla.com>
Wed, 23 Oct 2013 15:03:03 -0700
changeset 151804 354e00efe670b860cc5fd606ff47543c2be3acae
parent 151803 1b1567b456a53fdc64c21048629d92a8c8ec72a2
child 151805 ed1936907636c49714ec1b07961d0ba8cc10c118
push id1791
push userdhylands@mozilla.com
push dateWed, 23 Oct 2013 22:04:31 +0000
treeherderb2g-inbound@354e00efe670 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikeh
bugs929816
milestone27.0a1
Bug 929816 - Allow devicestorage testing mode to work on travis. r=mikeh
dom/devicestorage/nsDeviceStorage.cpp
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -757,20 +757,26 @@ DeviceStorageFile::GetRootDirectoryForTy
 #else
      f = sDirs->sdcard;
 #endif
   }
 
   // crash reports directory.
   else if (aStorageType.EqualsLiteral(DEVICESTORAGE_CRASHES)) {
     f = sDirs->crashes;
+  } else {
+    // Not a storage type that we recognize. Return null
+    return;
   }
 
-  // in testing, we default all device storage types to a temp directory
-  if (f && sDirs->temp) {
+  // In testing, we default all device storage types to a temp directory.
+  // sDirs->temp will only have been initialized (in InitDirs) if the
+  // preference device.storage.testing was set to true. We can't test the
+  // preference directly here, since we may not be on the main thread.
+  if (sDirs->temp) {
     f = sDirs->temp;
   }
 
   if (f) {
     f->Clone(aFile);
   }
 }