Backout c707e4f15fd4 (bug 767905), cad3e0609835 (bug 767894) for various devicestorage test failures
authorEd Morley <emorley@mozilla.com>
Tue, 26 Jun 2012 16:21:37 +0100
changeset 97703 610161cc263b291c2de4f02e88c964cbcd42c7e4
parent 97702 c94c8777d7ebfb8f084fa0f8a35a68c52b0e5d21
child 97704 c74442257e60fa4eadbce075ac42de871efff7cb
push id22993
push useremorley@mozilla.com
push dateWed, 27 Jun 2012 10:31:27 +0000
treeherdermozilla-central@1a56f1f011c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs767905, 767894
milestone16.0a1
backs outc707e4f15fd41182e2aea567e4fa96fe6a3f0ce6
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
Backout c707e4f15fd4 (bug 767905), cad3e0609835 (bug 767894) for various devicestorage test failures
dom/devicestorage/Makefile.in
dom/devicestorage/nsDeviceStorage.cpp
dom/devicestorage/test/Makefile.in
dom/devicestorage/test/devicestorage_common.js
dom/devicestorage/test/test_basic.html
dom/devicestorage/test/test_dotdot.html
dom/devicestorage/test/test_enumerate.html
dom/devicestorage/test/test_enumerateMultipleContinue.html
dom/devicestorage/test/test_enumerateNoParam.html
dom/devicestorage/test/test_enumerateOptions.html
dom/devicestorage/test/test_lastModificationFilter.html
dom/devicestorage/test/test_overwrite.html
dom/devicestorage/test/test_sanity.html
dom/tests/mochitest/Makefile.in
dom/tests/mochitest/devicestorage/Makefile.in
dom/tests/mochitest/devicestorage/devicestorage_common.js
dom/tests/mochitest/devicestorage/test_basic.html
dom/tests/mochitest/devicestorage/test_dotdot.html
dom/tests/mochitest/devicestorage/test_enumerate.html
dom/tests/mochitest/devicestorage/test_enumerateMultipleContinue.html
dom/tests/mochitest/devicestorage/test_enumerateNoParam.html
dom/tests/mochitest/devicestorage/test_enumerateOptions.html
dom/tests/mochitest/devicestorage/test_lastModificationFilter.html
dom/tests/mochitest/devicestorage/test_overwrite.html
dom/tests/mochitest/devicestorage/test_sanity.html
--- a/dom/devicestorage/Makefile.in
+++ b/dom/devicestorage/Makefile.in
@@ -27,16 +27,14 @@ EXPORTS         = \
 
 LOCAL_INCLUDES = \
 		-I$(topsrcdir)/dom/base \
 		-I$(topsrcdir)/dom/ipc \
 		-I$(topsrcdir)/content/base/src \
 		-I$(topsrcdir)/content/events/src \
 		$(NULL)
 
-TEST_DIRS += test
-
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -D_IMPL_NS_LAYOUT
 
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -23,52 +23,44 @@ using namespace mozilla::dom;
 
 #include "nsDirectoryServiceDefs.h"
 
 class DeviceStorageFile MOZ_FINAL : public nsISupports {
 public:
 
   nsCOMPtr<nsIFile> mFile;
   nsString mPath;
-  bool mEditable;
 
   DeviceStorageFile(nsIFile* aFile, const nsAString& aPath)
   : mPath(aPath)
-  , mEditable(false)
   {
     NS_ASSERTION(aFile, "Must not create a DeviceStorageFile with a null nsIFile");
     // always take a clone
     nsCOMPtr<nsIFile> file;
     aFile->Clone(getter_AddRefs(mFile));
 
     AppendRelativePath();
 
     NormalizeFilePath();
   }
 
   DeviceStorageFile(nsIFile* aFile)
-  : mEditable(false)
   {
     NS_ASSERTION(aFile, "Must not create a DeviceStorageFile with a null nsIFile");
     // always take a clone
     nsCOMPtr<nsIFile> file;
     aFile->Clone(getter_AddRefs(mFile));
   }
 
   void
   setPath(const nsAString& aPath) {
     mPath.Assign(aPath);
     NormalizeFilePath();
   }
 
-  void
-  setEditable(bool aEditable) {
-    mEditable = aEditable;
-  }
-
   NS_DECL_ISUPPORTS
 
   // we want to make sure that the names of file can't reach
   // outside of the type of storage the user asked for.
   bool
   isSafePath()
   {
     nsAString::const_iterator start, end;
@@ -223,22 +215,22 @@ nsDOMDeviceStorage::SetRootFileForType(c
       dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
     }
   } 
 
   mFile = f;
   return typeResult;
 }
 
-static jsval nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile)
+static jsval nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile, bool aEditable)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   NS_ASSERTION(aWindow, "Null Window");
 
-  if (aFile->mEditable) {
+  if (aEditable) {
     // TODO - needs janv's file handle support.
     return JSVAL_NULL;
   }
 
   if (aFile == nsnull) {
     return JSVAL_NULL;
   }
 
@@ -312,27 +304,29 @@ class nsDOMDeviceStorageCursor
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSICONTENTPERMISSIONREQUEST
   NS_DECL_NSIDOMDEVICESTORAGECURSOR
 
   nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
                            nsIURI* aURI,
                            DeviceStorageFile* aFile,
+                           bool aEditable,
                            PRUint64 aSince);
 
 private:
   ~nsDOMDeviceStorageCursor();
 
 protected:
   nsTArray<nsRefPtr<DeviceStorageFile> > mFiles;
 
   bool mOkToCallContinue;
   nsRefPtr<DeviceStorageFile> mFile;
   nsCOMPtr<nsIURI> mURI;
+  bool mEditable;
   PRUint64 mSince;
 
   // to access mFiles
   friend class InitCursorEvent;
   friend class ContinueCursorEvent;
 };
 
 class DeviceStorageCursorRequest MOZ_FINAL : public nsIContentPermissionRequest
@@ -454,17 +448,17 @@ public:
 
     nsDOMDeviceStorageCursor* cursor = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());
     if (cursor->mFiles.Length() == 0) {
       val = JSVAL_NULL;
     }
     else {
       nsRefPtr<DeviceStorageFile> file = cursor->mFiles[0];
       cursor->mFiles.RemoveElementAt(0);
-      val = nsIFileToJsval(cursor->GetOwner(), file);
+      val = nsIFileToJsval(cursor->GetOwner(), file, cursor->mEditable);
       cursor->mOkToCallContinue = true;
     }
 
     mRequest->FireSuccess(val);
     mRequest = nsnull;
     return NS_OK;
   }
 
@@ -579,21 +573,23 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_
 NS_INTERFACE_MAP_END_INHERITING(DOMRequest)
 
 NS_IMPL_ADDREF_INHERITED(nsDOMDeviceStorageCursor, DOMRequest)
 NS_IMPL_RELEASE_INHERITED(nsDOMDeviceStorageCursor, DOMRequest)
 
 nsDOMDeviceStorageCursor::nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
                                                    nsIURI* aURI,
                                                    DeviceStorageFile* aFile,
+                                                   bool aEditable,
                                                    PRUint64 aSince)
   : DOMRequest(aWindow)
   , mOkToCallContinue(false)
   , mFile(aFile)
   , mURI(aURI)
+  , mEditable(aEditable)
   , mSince(aSince)
 {
 }
 
 nsDOMDeviceStorageCursor::~nsDOMDeviceStorageCursor()
 {
 }
 
@@ -676,18 +672,19 @@ nsDOMDeviceStorageCursor::Continue()
   mOkToCallContinue = false;
   return NS_OK;
 }
 
 
 class PostResultEvent : public nsRunnable
 {
 public:
-  PostResultEvent(nsRefPtr<DOMRequest>& aRequest, DeviceStorageFile* aFile)
-    : mFile(aFile)
+  PostResultEvent(nsRefPtr<DOMRequest>& aRequest, bool aEditable, DeviceStorageFile* aFile)
+    : mEditable(aEditable)
+    , mFile(aFile)
     {
       mRequest.swap(aRequest);
     }
 
   PostResultEvent(nsRefPtr<DOMRequest>& aRequest, const nsAString & aPath)
     : mPath(aPath)
     {
       mRequest.swap(aRequest);
@@ -696,27 +693,28 @@ public:
   ~PostResultEvent() {}
 
   NS_IMETHOD Run() 
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
     jsval result = JSVAL_NULL;
     if (mFile) {
-      result = nsIFileToJsval(mRequest->GetOwner(), mFile);
+      result = nsIFileToJsval(mRequest->GetOwner(), mFile, mEditable);
     } else {
       result = StringToJsval(mRequest->GetOwner(), mPath);
     }
 
     mRequest->FireSuccess(result);
     mRequest = nsnull;
     return NS_OK;
   }
 
 private:
+  bool mEditable;
   nsRefPtr<DeviceStorageFile> mFile;
   nsString mPath;
   nsRefPtr<DOMRequest> mRequest;
 };
 
 class WriteFileEvent : public nsRunnable
 {
 public:
@@ -805,51 +803,56 @@ public:
     return NS_OK;
   }
 
 private:
   nsCOMPtr<nsIDOMBlob> mBlob;
   nsRefPtr<DeviceStorageFile> mFile;
   nsRefPtr<DOMRequest> mRequest;
 };
+
+
 class ReadFileEvent : public nsRunnable
 {
 public:
     ReadFileEvent(DeviceStorageFile* aFile,
+                  bool aEditable,
                   nsRefPtr<DOMRequest>& aRequest)
   : mFile(aFile)
+  , mEditable(aEditable)
     {
       mRequest.swap(aRequest);
     }
 
   ~ReadFileEvent() {}
 
   NS_IMETHOD Run() 
   {
     NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
 
     nsRefPtr<nsRunnable> r;
 
-    if (!mFile->mEditable) {
+    if (!mEditable) {
       bool check = false;
       mFile->mFile->Exists(&check);
       if (!check) {
         r = new PostErrorEvent(mRequest, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST, mFile);
       }
     }
 
     if (!r) {
-      r = new PostResultEvent(mRequest, mFile);
+      r = new PostResultEvent(mRequest, mEditable, mFile);
     }
     NS_DispatchToMainThread(r);
     return NS_OK;
   }
 
 private:
   nsRefPtr<DeviceStorageFile> mFile;
+  bool mEditable;
   nsRefPtr<DOMRequest> mRequest;
 };
 
 class DeleteFileEvent : public nsRunnable
 {
 public:
   DeleteFileEvent(DeviceStorageFile* aFile,
                   nsRefPtr<DOMRequest>& aRequest)
@@ -894,22 +897,24 @@ public:
         DEVICE_STORAGE_REQUEST_WRITE,
         DEVICE_STORAGE_REQUEST_DELETE
     };
     DeviceStorageRequest(const PRInt32 aRequestType,
                          nsPIDOMWindow *aWindow,
                          nsIURI *aURI,
                          DeviceStorageFile *aFile,
                          DOMRequest* aRequest,
+                         bool aEditable,
                          nsIDOMBlob *aBlob = nsnull)
         : mRequestType(aRequestType)
         , mWindow(aWindow)
         , mURI(aURI)
         , mFile(aFile)
         , mRequest(aRequest)
+        , mEditable(aEditable)
         , mBlob(aBlob) {}
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(DeviceStorageRequest, nsIContentPermissionRequest)
 
   NS_IMETHOD Run() {
 
     if (mozilla::Preferences::GetBool("device.storage.prompt.testing", false)) {
@@ -972,17 +977,17 @@ public:
           return NS_ERROR_FAILURE;
         }
 
         r = new WriteFileEvent(mBlob, mFile, mRequest);
         break;
       }
       case DEVICE_STORAGE_REQUEST_READ:
       {
-        r = new ReadFileEvent(mFile, mRequest);
+        r = new ReadFileEvent(mFile, mEditable, mRequest);
         break;
       }
       case DEVICE_STORAGE_REQUEST_DELETE:
       {
         r = new DeleteFileEvent(mFile, mRequest);
         break;
       }
     }
@@ -997,16 +1002,17 @@ public:
 
 private:
   PRInt32 mRequestType;
   nsCOMPtr<nsPIDOMWindow> mWindow;
   nsCOMPtr<nsIURI> mURI;
   nsRefPtr<DeviceStorageFile> mFile;
 
   nsRefPtr<DOMRequest> mRequest;
+  bool mEditable;
   nsCOMPtr<nsIDOMBlob> mBlob;
 };
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeviceStorageRequest)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentPermissionRequest)
   NS_INTERFACE_MAP_ENTRY(nsIContentPermissionRequest)
   NS_INTERFACE_MAP_ENTRY(nsIRunnable)
 NS_INTERFACE_MAP_END
@@ -1154,17 +1160,17 @@ nsDOMDeviceStorage::AddNamed(nsIDOMBlob 
 
   nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mFile, aPath);
 
   if (!dsf->isSafePath()) {
     r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_FILE_NAME, dsf);
   }
   else {
     r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_WRITE,
-                                 win, mURI, dsf, request, aBlob);
+                                 win, mURI, dsf, request, true, aBlob);
   }
   NS_DispatchToMainThread(r);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::Get(const JS::Value & aPath,
                         JSContext* aCx,
@@ -1204,23 +1210,22 @@ nsDOMDeviceStorage::GetInternal(const JS
     r = new PostErrorEvent(request,
                            POST_ERROR_EVENT_NON_STRING_TYPE_UNSUPPORTED,
                            dsf);
     NS_DispatchToMainThread(r);
     return NS_OK;
   }
 
   nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mFile, path);
-  dsf->setEditable(aEditable);
 
   if (!dsf->isSafePath()) {
     r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_FILE_NAME, dsf);
   } else {
     r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_READ,
-                                 win, mURI, dsf, request);
+                                 win, mURI, dsf, request, aEditable);
   }
   NS_DispatchToMainThread(r);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::Delete(const JS::Value & aPath, JSContext* aCx, nsIDOMDOMRequest * *_retval NS_OUTPARAM)
 {
@@ -1245,17 +1250,17 @@ nsDOMDeviceStorage::Delete(const JS::Val
 
   nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mFile, path);
 
   if (!dsf->isSafePath()) {
     r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_FILE_NAME, dsf);
   }
   else {
     r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_DELETE,
-                                 win, mURI, dsf, request);
+                                 win, mURI, dsf, request, true);
   }
   NS_DispatchToMainThread(r);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::Enumerate(const JS::Value & aName,
                              const JS::Value & aOptions,
@@ -1326,19 +1331,17 @@ nsDOMDeviceStorage::EnumerateInternal(co
       
     if (aArgc == 2 && (JSVAL_IS_VOID(aOptions) || aOptions.isNull() || !aOptions.isObject())) {
       return NS_ERROR_FAILURE;
     }
     since = ExtractDateFromOptions(aCx, aOptions);
   }
   
   nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mFile, path);
-  dsf->setEditable(aEditable);
-
-  nsRefPtr<nsDOMDeviceStorageCursor> cursor = new nsDOMDeviceStorageCursor(win, mURI, dsf, since);
+  nsRefPtr<nsDOMDeviceStorageCursor> cursor = new nsDOMDeviceStorageCursor(win, mURI, dsf, aEditable, since);
   nsRefPtr<DeviceStorageCursorRequest> r = new DeviceStorageCursorRequest(cursor);
 
   NS_ADDREF(*aRetval = cursor);
 
   if (mozilla::Preferences::GetBool("device.storage.prompt.testing", false)) {
     r->Allow();
     return NS_OK;
   }
deleted file mode 100644
--- a/dom/devicestorage/test/Makefile.in
+++ /dev/null
@@ -1,29 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this file,
-# You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DEPTH		= ../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-relativesrcdir	= dom/devicestorage/test/
-
-include $(DEPTH)/config/autoconf.mk
-
-include $(topsrcdir)/config/rules.mk
-
-_TEST_FILES	= \
-		test_sanity.html \
-		test_basic.html \
-		test_enumerate.html \
-		test_enumerateMultipleContinue.html \
-		test_overwrite.html \
-		test_dotdot.html \
-		test_enumerateOptions.html \
-		test_lastModificationFilter.html \
-		devicestorage_common.js \
-		$(NULL)
-
-libs:: 	$(_TEST_FILES)
-	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
-
deleted file mode 100644
--- a/dom/devicestorage/test/devicestorage_common.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-var oldVal = false;
-  
-// Array Remove - By John Resig (MIT Licensed)
-Array.prototype.remove = function(from, to) {
-  var rest = this.slice((to || from) + 1 || this.length);
-  this.length = from < 0 ? this.length + from : from;
-  return this.push.apply(this, rest);
-};
-
-function devicestorage_setup() {
-  SimpleTest.waitForExplicitFinish();
-  try {
-    oldVal = SpecialPowers.getBoolPref("device.storage.enabled");
-  } catch(e) {}
-  SpecialPowers.setBoolPref("device.storage.enabled", true);
-  SpecialPowers.setBoolPref("device.storage.testing", true);
-  SpecialPowers.setBoolPref("device.storage.prompt.testing", true);
-}
-
-function devicestorage_cleanup() {
-  SpecialPowers.setBoolPref("device.storage.enabled", oldVal);
-  SpecialPowers.setBoolPref("device.storage.testing", false);
-  SpecialPowers.setBoolPref("device.storage.prompt.testing", false);
-  SimpleTest.finish();
-}
-
-function getRandomBuffer() {
-  var size = 1024;
-  var buffer = new ArrayBuffer(size);
-  var view = new Uint8Array(buffer);
-  for (var i = 0; i < size; i++) {
-    view[i] = parseInt(Math.random() * 255);
-  }
-  return buffer;
-}
-
-function createRandomBlob() {
- return blob = new Blob([getRandomBuffer()], {type: 'binary/random'});
-}
-
-function randomFilename(l) {
-    var set = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
-    var result = "";
-    for (var i=0; i<l; i++) {
-	var r = Math.floor(set.length * Math.random());
-	result += set.substring(r, r + 1);
-    }
-    return result;
-}
-
-function reportErrorAndQuit(e) {
-  ok(false, "handleError was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
deleted file mode 100644
--- a/dom/devicestorage/test/test_basic.html
+++ /dev/null
@@ -1,102 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html> <!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-devicestorage_setup();
-
-var gFileName = "devicestorage/hi";
-
-function getAfterDeleteSuccess(e) {
-  ok(false, "file was deleted not successfully");
-  devicestorage_cleanup();
-}
-
-function getAfterDeleteError(e) {
-  ok(true, "file was deleted successfully");
-  devicestorage_cleanup();
-}
-
-function deleteSuccess(e) {
-
-  ok(e.target.result == gFileName, "File name should match");
-
-  var storage = navigator.getDeviceStorage("profile");
-  request = storage[0].get(e.target.result);
-  request.onsuccess = getAfterDeleteSuccess;
-  request.onerror = getAfterDeleteError;
-
-}
-
-function deleteError(e) {
-  ok(false, "deleteError was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
-
-function getSuccess(e) {
-  var storage = navigator.getDeviceStorage("profile");
-  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
-
-  ok(e.target.result.name == gFileName, "File name should match");
-
-  request = storage[0].delete(e.target.result.name)
-  request.onsuccess = deleteSuccess;
-  request.onerror = deleteError;
-}
-
-function getError(e) {
-  ok(false, "getError was called : " + e.target.error.name);
-  SpecialPowers.setBoolPref("device.storage.enabled", oldVal);
-  SimpleTest.finish();
-}
-
-function addSuccess(e) {
-
-  ok(e.target.result == gFileName, "File name should match");
-
-  var storage = navigator.getDeviceStorage("profile");
-  request = storage[0].get(gFileName);
-  request.onsuccess = getSuccess;
-  request.onerror = getError;
-
-  ok(true, "addSuccess was called");
-}
-
-function addError(e) {
-  ok(false, "addError was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
-
-var storage = navigator.getDeviceStorage("profile");
-ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
-
-request = storage[0].addNamed(createRandomBlob(), "devicestorage/hi");
-ok(request, "Should have a non-null request");
-
-request.onsuccess = addSuccess;
-request.onerror = addError;
-
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/devicestorage/test/test_dotdot.html
+++ /dev/null
@@ -1,71 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html> <!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-devicestorage_setup();
-
-function profileStorage() {
-  return navigator.getDeviceStorage("profile")[0];
-}
-
-var tests = [
-  function () { return profileStorage().addNamed(createRandomBlob(), gFileName); },
-  function () { return profileStorage().delete(gFileName); },
-  function () { return profileStorage().get(gFileName); },
-  function () { var r = profileStorage().enumerate("../"); return r; }
-];
-
-var gFileName = "../owned";
-
-function fail(e) {
-  ok(false, "addSuccess was called");
-  dump(request);
-  devicestorage_cleanup();
-}
-
-function next(e) {
-
-  if (e != undefined)
-    ok(true, "addError was called");
-  
-  var f = tests.pop();
-
-  if (f == undefined) {
-    devicestorage_cleanup();
-    return;
-  }
-
-  request = f();
-  request.onsuccess = fail;
-  request.onerror = next;
-}
-
-next();
-
-
-
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/devicestorage/test/test_enumerate.html
+++ /dev/null
@@ -1,91 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html> <!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-devicestorage_setup();
-
-function enumerateSuccess(e) {
-
-  if (e.target.result == null) {
-    ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
-    dump("We still have length = " + files.length);
-    devicestorage_cleanup();
-    return;
-  }
-  
-  var filename = e.target.result.name;
-
-  var index = files.indexOf(filename);
-  files.remove(index);
-
-  ok(index > -1, "filename should be in the enumeration : " + e.target.result.name);
-
-  // clean up
-  var cleanup = storage[0].delete(prefix + "/" + filename);
-  cleanup.onsuccess = function(e) {}  // todo - can i remove this?
-
-  e.target.continue();
-}
-
-function handleError(e) {
-  ok(false, "handleError was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
-
-function addSuccess(e) {
-  addedSoFar = addedSoFar + 1;
-  if (addedSoFar == files.length) {
-
-    var cursor = storage[0].enumerate(prefix);
-    cursor.onsuccess = enumerateSuccess;
-    cursor.onerror = handleError;
-  }
-}
-
-function addError(e) {
-  ok(false, "addError was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
-
-var storage = navigator.getDeviceStorage("profile");
-ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
-var prefix = "devicestorage/" + randomFilename(12)
-
-var files = [ "a", "b", "c", "d/a", "d/b", "d/c", "d/d", "The/quick/brown/fox/jumps/over/the/lazy/dog"]
-var addedSoFar = 0;
-
-
-for (var i=0; i<files.length; i++) {
-
- request = storage[0].addNamed(createRandomBlob(), prefix + '/' + files[i]);
-
- ok(request, "Should have a non-null request");
- request.onsuccess = addSuccess;
- request.onerror = addError;
-}
-
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/devicestorage/test/test_enumerateMultipleContinue.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html> <!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-devicestorage_setup();
-
-function enumerateSuccess(e) {
-}
-
-function enumerateFailure(e) {
-}
-
-var cursor = navigator.getDeviceStorage("profile")[0].enumerate();
-cursor.onsuccess = enumerateSuccess;
-cursor.onerror = enumerateFailure;
-
-try {
- cursor.continue();
-}
-catch (e) {
-  ok(true, "Calling continue before enumerateSuccess fires should throw");
-  devicestorage_cleanup();
-}
-
-
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/devicestorage/test/test_enumerateNoParam.html
+++ /dev/null
@@ -1,95 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html> <!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-// Array Remove - By John Resig (MIT Licensed)
-Array.prototype.remove = function(from, to) {
-  var rest = this.slice((to || from) + 1 || this.length);
-  this.length = from < 0 ? this.length + from : from;
-  return this.push.apply(this, rest);
-};
-
-devicestorage_setup();
-
-function enumerateSuccess(e) {
-
-  if (e.target.result == null) {
-    ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
-    devicestorage_cleanup();
-  }
-  
-  var filename = e.target.result.name;
-  var index = files.indexOf(filename);
-  files.remove(index);
-
-  ok(index > -1, "filename should be in the enumeration : " + e.target.result.name);
-
-  // clean up
-  var cleanup = storage[0].delete(prefix + "/" + filename);
-  cleanup.onsuccess = function(e) {}  // todo - can i remove this?
-
-  e.target.continue();
-}
-
-function handleError(e) {
-  ok(false, "handleError was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
-
-function addSuccess(e) {
-  addedSoFar = addedSoFar + 1;
-  if (addedSoFar == files.length) {
-
-    var cursor = storage[0].enumerate();
-    cursor.onsuccess = enumerateSuccess;
-    cursor.onerror = handleError;
-  }
-}
-
-function addError(e) {
-  ok(false, "addError was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
-
-var storage = navigator.getDeviceStorage("profile");
-ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
-var prefix = "devicestorage/" + randomFilename(12)
-
-var files = [ "a", "b", "c" ]
-var addedSoFar = 0;
-
-
-for (var i=0; i<files.length; i++) {
-
- request = storage[0].addNamed(createRandomBlob(), prefix + '/' + files[i]);
-
- ok(request, "Should have a non-null request");
- request.onsuccess = addSuccess;
- request.onerror = addError;
-}
-
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/devicestorage/test/test_enumerateOptions.html
+++ /dev/null
@@ -1,81 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for basic sanity of the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-devicestorage_setup()
-
-storage = navigator.getDeviceStorage("profile");
-
-
-throws = false;
-try {
-var cursor = storage[0].enumerate();
-} catch(e) {throws = true}
-ok(!throws, "enumerate no parameter");
-
-throws = false;
-try {
-var cursor = storage[0].enumerate("string");
-} catch(e) {throws = true}
-ok(!throws, "enumerate one string parameter");
-
-throws = false;
-try {
-var cursor = storage[0].enumerate("string", "string2");
-} catch(e) {throws = true}
-ok(throws, "enumerate two string parameter");
-
-throws = false;
-try {
-var cursor = storage[0].enumerate("string", {"since": 1});
-} catch(e) {throws = true}
-ok(!throws, "enumerate a string and object parameter");
-
-throws = false;
-try {
-var cursor = storage[0].enumerate({"path": "a"});
-} catch(e) {throws = true}
-ok(!throws, "enumerate object parameter with path");
-
-throws = false;
-try {
-var cursor = storage[0].enumerate({}, "string");
-} catch(e) {throws = true}
-ok(throws, "enumerate object then a string");
-
-throws = false;
-try {
-var cursor = storage[0].enumerate({"path": "a", "since": 0});
-} catch(e) {throws = true}
-ok(!throws, "enumerate object parameter with path");
-
-
-
-
-devicestorage_cleanup()
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/devicestorage/test/test_lastModificationFilter.html
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html> <!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-
-
-function verifyAndDelete(prefix, files, e) {
-
-  if (e.target.result == null) {
-    ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
-    dump("We still have length = " + files.length + "\n");
-    dump(files + "\n");
-    devicestorage_cleanup();
-    return;
-  }
-
-  var filename = e.target.result.name;
-
-  var index = files.indexOf(filename);
-  ok(index > -1, "filename should be in the enumeration : " + e.target.result.name);
-  if (index == -1)
-    return;
-
-  files.remove(index);
-
-  // clean up
-  var storage = navigator.getDeviceStorage("profile");
-  var cleanup = storage[0].delete(prefix + "/" + filename);
-  cleanup.onsuccess = function(e) {}
-}
-
-function addFiles(prefix, files, date, callback) {
-
-  const Cc = SpecialPowers.wrap(Components).classes;
-  const Ci = Components.interfaces;
-
-  var directoryService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
-
-  for (var i=0; i<files.length; i++) {
-    var f = directoryService.get("ProfD", Components.interfaces.nsIFile);
-    var path = prefix + '/' + files[i];
-    path.split("/").forEach(function(p) {
-      f.appendRelativePath(p);
-    });
-    f.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
-    f.lastModifiedTime = date;
-  }
-  callback();
-}
-
-
-devicestorage_setup();
-
-var prefix = "devicestorage/" + randomFilename(12)
-
-var oldFiles = ["a", "b", "c"];
-var newFiles = ["d", "e", "f"];
-
-// 157795200 is a long long time ago.
-addFiles(prefix, oldFiles, 157795200, addNewFiles);
-
-function enumerateNew() {
-
-  var storage = navigator.getDeviceStorage("profile");
-  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
-
-// 836031600 is a long time ago
-  var cursor = storage[0].enumerate(prefix, {"since": new Date(836031600)});
-  cursor.onsuccess = function(e) {
-    verifyAndDelete(prefix, newFiles, e);
-    if (e.target.result) {
-      e.target.continue();
-    }
-  }
-
-  cursor.onerror = function (e) {
-    ok(false, "handleError was called : " + e.target.error.name);
-    devicestorage_cleanup();
-  }
-}
-
-function addNewFiles() {
-  addFiles(prefix, newFiles, Date.now(), enumerateNew);
-}
-
-
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/devicestorage/test/test_overwrite.html
+++ /dev/null
@@ -1,90 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for basic sanity of the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-var filename = "devicestorage/aaaa"
-
-devicestorage_setup();
-
-
-function deleteSuccess(e) {
-  devicestorage_cleanup();
-}
-
-function deleteError(e) {
-  ok(false, "deleteError was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
-
-function addOverwritingSuccess(e) {
-  ok(false, "addOverwritingSuccess was called.");
-}
-
-function addOverwritingError(e) {
-  ok(true, "Adding to the same location should fail");
-
-  var storage = navigator.getDeviceStorage("profile");
-  request = storage[0].delete(filename)
-  request.onsuccess = deleteSuccess;
-  request.onerror = deleteError;
-}
-
-function addSuccess(e) {
-  ok(true, "addSuccess was called");
-
-  var storage = navigator.getDeviceStorage("profile");
-  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
-
-  request = storage[0].addNamed(createRandomBlob(), filename);
-  ok(request, "Should have a non-null request");
-
-  request.onsuccess = addOverwritingSuccess;
-  request.onerror = addOverwritingError;
-}
-
-function addError(e) {
-  // test file is already exists.  clean it up and try again..
-  var storage = navigator.getDeviceStorage("profile");
-  request = storage[0].delete(filename)
-  request.onsuccess = runtest;
-}
-
-function runtest() {
-  var storage = navigator.getDeviceStorage("profile");
-  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
-
-  request = storage[0].addNamed(createRandomBlob(), filename);
-  ok(request, "Should have a non-null request");
-
-  request.onsuccess = addSuccess;
-  request.onerror = addError;
-}
-
-runtest();
-
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/devicestorage/test/test_sanity.html
+++ /dev/null
@@ -1,72 +0,0 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=717103
--->
-<head>
-  <title>Test for basic sanity of the device storage API </title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="devicestorage_common.js"></script>
-
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-devicestorage_setup()
-
-ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
-
-var storage;
-
-var throws = false;
-try {
- storage = navigator.getDeviceStorage();
-} catch(e) {throws = true}
-ok(throws, "getDeviceStorage takes one arg");
-
-storage = navigator.getDeviceStorage("kilimanjaro");
-ok(!storage, "kilimanjaro - Should not have this type of storage");
-
-storage = navigator.getDeviceStorage("temp");
-ok(storage, "temp - Should have getDeviceStorage");
-
-storage = navigator.getDeviceStorage("profile");
-ok(storage, "profile - Should have getDeviceStorage");
-
-var cursor = storage[0].enumerate();
-ok(cursor, "Should have a non-null cursor");
-
-var i = 4;
-cursor.onsuccess = function(e) {
-  i = i - 1;
-  if (i > 0) {
-    ok(true, "onsuccess was called");
-    e.target.continue();
-  }
-  else {
-    ok(true, "onsuccess was called 4 times");
-    devicestorage_cleanup();
-  }
-}
-
-cursor.onerror = function(e) {
-  ok(false, "onerror was called : " + e.target.error.name);
-  devicestorage_cleanup();
-}
-
-</script>
-</pre>
-</body>
-</html>
-
--- a/dom/tests/mochitest/Makefile.in
+++ b/dom/tests/mochitest/Makefile.in
@@ -13,16 +13,17 @@ include $(DEPTH)/config/autoconf.mk
 DIRS	+= \
 	dom-level0 \
 	dom-level1-core \
 	dom-level2-core \
 	dom-level2-html \
 	ajax \
 	bugs \
 	chrome \
+	devicestorage \
 	general \
 	whatwg \
 	geolocation \
 	localstorage \
 	orientation \
 	sessionstorage \
 	storageevent \
 	pointerlock \
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/Makefile.in
@@ -0,0 +1,29 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+DEPTH		= ../../../..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+relativesrcdir	= dom/tests/mochitest/devicestorage
+
+include $(DEPTH)/config/autoconf.mk
+
+include $(topsrcdir)/config/rules.mk
+
+_TEST_FILES	= \
+		test_sanity.html \
+		test_basic.html \
+		test_enumerate.html \
+		test_enumerateMultipleContinue.html \
+		test_overwrite.html \
+		test_dotdot.html \
+		test_enumerateOptions.html \
+		test_lastModificationFilter.html \
+		devicestorage_common.js \
+		$(NULL)
+
+libs:: 	$(_TEST_FILES)
+	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/devicestorage_common.js
@@ -0,0 +1,59 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+var oldVal = false;
+  
+// Array Remove - By John Resig (MIT Licensed)
+Array.prototype.remove = function(from, to) {
+  var rest = this.slice((to || from) + 1 || this.length);
+  this.length = from < 0 ? this.length + from : from;
+  return this.push.apply(this, rest);
+};
+
+function devicestorage_setup() {
+  SimpleTest.waitForExplicitFinish();
+  try {
+    oldVal = SpecialPowers.getBoolPref("device.storage.enabled");
+  } catch(e) {}
+  SpecialPowers.setBoolPref("device.storage.enabled", true);
+  SpecialPowers.setBoolPref("device.storage.testing", true);
+  SpecialPowers.setBoolPref("device.storage.prompt.testing", true);
+}
+
+function devicestorage_cleanup() {
+  SpecialPowers.setBoolPref("device.storage.enabled", oldVal);
+  SpecialPowers.setBoolPref("device.storage.testing", false);
+  SpecialPowers.setBoolPref("device.storage.prompt.testing", false);
+  SimpleTest.finish();
+}
+
+function getRandomBuffer() {
+  var size = 1024;
+  var buffer = new ArrayBuffer(size);
+  var view = new Uint8Array(buffer);
+  for (var i = 0; i < size; i++) {
+    view[i] = parseInt(Math.random() * 255);
+  }
+  return buffer;
+}
+
+function createRandomBlob() {
+ return blob = new Blob([getRandomBuffer()], {type: 'binary/random'});
+}
+
+function randomFilename(l) {
+    var set = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
+    var result = "";
+    for (var i=0; i<l; i++) {
+	var r = Math.floor(set.length * Math.random());
+	result += set.substring(r, r + 1);
+    }
+    return result;
+}
+
+function reportErrorAndQuit(e) {
+  ok(false, "handleError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_basic.html
@@ -0,0 +1,102 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html> <!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+devicestorage_setup();
+
+var gFileName = "devicestorage/hi";
+
+function getAfterDeleteSuccess(e) {
+  ok(false, "file was deleted not successfully");
+  devicestorage_cleanup();
+}
+
+function getAfterDeleteError(e) {
+  ok(true, "file was deleted successfully");
+  devicestorage_cleanup();
+}
+
+function deleteSuccess(e) {
+
+  ok(e.target.result == gFileName, "File name should match");
+
+  var storage = navigator.getDeviceStorage("profile");
+  request = storage[0].get(e.target.result);
+  request.onsuccess = getAfterDeleteSuccess;
+  request.onerror = getAfterDeleteError;
+
+}
+
+function deleteError(e) {
+  ok(false, "deleteError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+function getSuccess(e) {
+  var storage = navigator.getDeviceStorage("profile");
+  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+
+  ok(e.target.result.name == gFileName, "File name should match");
+
+  request = storage[0].delete(e.target.result.name)
+  request.onsuccess = deleteSuccess;
+  request.onerror = deleteError;
+}
+
+function getError(e) {
+  ok(false, "getError was called : " + e.target.error.name);
+  SpecialPowers.setBoolPref("device.storage.enabled", oldVal);
+  SimpleTest.finish();
+}
+
+function addSuccess(e) {
+
+  ok(e.target.result == gFileName, "File name should match");
+
+  var storage = navigator.getDeviceStorage("profile");
+  request = storage[0].get(gFileName);
+  request.onsuccess = getSuccess;
+  request.onerror = getError;
+
+  ok(true, "addSuccess was called");
+}
+
+function addError(e) {
+  ok(false, "addError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+var storage = navigator.getDeviceStorage("profile");
+ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+
+request = storage[0].addNamed(createRandomBlob(), "devicestorage/hi");
+ok(request, "Should have a non-null request");
+
+request.onsuccess = addSuccess;
+request.onerror = addError;
+
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_dotdot.html
@@ -0,0 +1,71 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html> <!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+devicestorage_setup();
+
+function profileStorage() {
+  return navigator.getDeviceStorage("profile")[0];
+}
+
+var tests = [
+  function () { return profileStorage().addNamed(createRandomBlob(), gFileName); },
+  function () { return profileStorage().delete(gFileName); },
+  function () { return profileStorage().get(gFileName); },
+  function () { var r = profileStorage().enumerate("../"); return r; }
+];
+
+var gFileName = "../owned";
+
+function fail(e) {
+  ok(false, "addSuccess was called");
+  dump(request);
+  devicestorage_cleanup();
+}
+
+function next(e) {
+
+  if (e != undefined)
+    ok(true, "addError was called");
+  
+  var f = tests.pop();
+
+  if (f == undefined) {
+    devicestorage_cleanup();
+    return;
+  }
+
+  request = f();
+  request.onsuccess = fail;
+  request.onerror = next;
+}
+
+next();
+
+
+
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_enumerate.html
@@ -0,0 +1,91 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html> <!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+devicestorage_setup();
+
+function enumerateSuccess(e) {
+
+  if (e.target.result == null) {
+    ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
+    dump("We still have length = " + files.length);
+    devicestorage_cleanup();
+    return;
+  }
+  
+  var filename = e.target.result.name;
+
+  var index = files.indexOf(filename);
+  files.remove(index);
+
+  ok(index > -1, "filename should be in the enumeration : " + e.target.result.name);
+
+  // clean up
+  var cleanup = storage[0].delete(prefix + "/" + filename);
+  cleanup.onsuccess = function(e) {}  // todo - can i remove this?
+
+  e.target.continue();
+}
+
+function handleError(e) {
+  ok(false, "handleError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+function addSuccess(e) {
+  addedSoFar = addedSoFar + 1;
+  if (addedSoFar == files.length) {
+
+    var cursor = storage[0].enumerate(prefix);
+    cursor.onsuccess = enumerateSuccess;
+    cursor.onerror = handleError;
+  }
+}
+
+function addError(e) {
+  ok(false, "addError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+var storage = navigator.getDeviceStorage("profile");
+ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+var prefix = "devicestorage/" + randomFilename(12)
+
+var files = [ "a", "b", "c", "d/a", "d/b", "d/c", "d/d", "The/quick/brown/fox/jumps/over/the/lazy/dog"]
+var addedSoFar = 0;
+
+
+for (var i=0; i<files.length; i++) {
+
+ request = storage[0].addNamed(createRandomBlob(), prefix + '/' + files[i]);
+
+ ok(request, "Should have a non-null request");
+ request.onsuccess = addSuccess;
+ request.onerror = addError;
+}
+
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_enumerateMultipleContinue.html
@@ -0,0 +1,50 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html> <!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+devicestorage_setup();
+
+function enumerateSuccess(e) {
+}
+
+function enumerateFailure(e) {
+}
+
+var cursor = navigator.getDeviceStorage("profile")[0].enumerate();
+cursor.onsuccess = enumerateSuccess;
+cursor.onerror = enumerateFailure;
+
+try {
+ cursor.continue();
+}
+catch (e) {
+  ok(true, "Calling continue before enumerateSuccess fires should throw");
+  devicestorage_cleanup();
+}
+
+
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_enumerateNoParam.html
@@ -0,0 +1,95 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html> <!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+// Array Remove - By John Resig (MIT Licensed)
+Array.prototype.remove = function(from, to) {
+  var rest = this.slice((to || from) + 1 || this.length);
+  this.length = from < 0 ? this.length + from : from;
+  return this.push.apply(this, rest);
+};
+
+devicestorage_setup();
+
+function enumerateSuccess(e) {
+
+  if (e.target.result == null) {
+    ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
+    devicestorage_cleanup();
+  }
+  
+  var filename = e.target.result.name;
+  var index = files.indexOf(filename);
+  files.remove(index);
+
+  ok(index > -1, "filename should be in the enumeration : " + e.target.result.name);
+
+  // clean up
+  var cleanup = storage[0].delete(prefix + "/" + filename);
+  cleanup.onsuccess = function(e) {}  // todo - can i remove this?
+
+  e.target.continue();
+}
+
+function handleError(e) {
+  ok(false, "handleError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+function addSuccess(e) {
+  addedSoFar = addedSoFar + 1;
+  if (addedSoFar == files.length) {
+
+    var cursor = storage[0].enumerate();
+    cursor.onsuccess = enumerateSuccess;
+    cursor.onerror = handleError;
+  }
+}
+
+function addError(e) {
+  ok(false, "addError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+var storage = navigator.getDeviceStorage("profile");
+ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+var prefix = "devicestorage/" + randomFilename(12)
+
+var files = [ "a", "b", "c" ]
+var addedSoFar = 0;
+
+
+for (var i=0; i<files.length; i++) {
+
+ request = storage[0].addNamed(createRandomBlob(), prefix + '/' + files[i]);
+
+ ok(request, "Should have a non-null request");
+ request.onsuccess = addSuccess;
+ request.onerror = addError;
+}
+
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_enumerateOptions.html
@@ -0,0 +1,81 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for basic sanity of the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+devicestorage_setup()
+
+storage = navigator.getDeviceStorage("profile");
+
+
+throws = false;
+try {
+var cursor = storage[0].enumerate();
+} catch(e) {throws = true}
+ok(!throws, "enumerate no parameter");
+
+throws = false;
+try {
+var cursor = storage[0].enumerate("string");
+} catch(e) {throws = true}
+ok(!throws, "enumerate one string parameter");
+
+throws = false;
+try {
+var cursor = storage[0].enumerate("string", "string2");
+} catch(e) {throws = true}
+ok(throws, "enumerate two string parameter");
+
+throws = false;
+try {
+var cursor = storage[0].enumerate("string", {"since": 1});
+} catch(e) {throws = true}
+ok(!throws, "enumerate a string and object parameter");
+
+throws = false;
+try {
+var cursor = storage[0].enumerate({"path": "a"});
+} catch(e) {throws = true}
+ok(!throws, "enumerate object parameter with path");
+
+throws = false;
+try {
+var cursor = storage[0].enumerate({}, "string");
+} catch(e) {throws = true}
+ok(throws, "enumerate object then a string");
+
+throws = false;
+try {
+var cursor = storage[0].enumerate({"path": "a", "since": 0});
+} catch(e) {throws = true}
+ok(!throws, "enumerate object parameter with path");
+
+
+
+
+devicestorage_cleanup()
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_lastModificationFilter.html
@@ -0,0 +1,111 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html> <!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+
+
+function verifyAndDelete(prefix, files, e) {
+
+  if (e.target.result == null) {
+    ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
+    dump("We still have length = " + files.length + "\n");
+    dump(files + "\n");
+    devicestorage_cleanup();
+    return;
+  }
+
+  var filename = e.target.result.name;
+
+  var index = files.indexOf(filename);
+  ok(index > -1, "filename should be in the enumeration : " + e.target.result.name);
+  if (index == -1)
+    return;
+
+  files.remove(index);
+
+  // clean up
+  var storage = navigator.getDeviceStorage("profile");
+  var cleanup = storage[0].delete(prefix + "/" + filename);
+  cleanup.onsuccess = function(e) {}
+}
+
+function addFiles(prefix, files, date, callback) {
+
+  const Cc = SpecialPowers.wrap(Components).classes;
+  const Ci = Components.interfaces;
+
+  var directoryService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
+
+  for (var i=0; i<files.length; i++) {
+    var f = directoryService.get("ProfD", Components.interfaces.nsIFile);
+    var path = prefix + '/' + files[i];
+    path.split("/").forEach(function(p) {
+      f.appendRelativePath(p);
+    });
+    f.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
+    f.lastModifiedTime = date;
+  }
+  callback();
+}
+
+
+devicestorage_setup();
+
+var prefix = "devicestorage/" + randomFilename(12)
+
+var oldFiles = ["a", "b", "c"];
+var newFiles = ["d", "e", "f"];
+
+// 157795200 is a long long time ago.
+addFiles(prefix, oldFiles, 157795200, addNewFiles);
+
+function enumerateNew() {
+
+  var storage = navigator.getDeviceStorage("profile");
+  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+
+// 836031600 is a long time ago
+  var cursor = storage[0].enumerate(prefix, {"since": new Date(836031600)});
+  cursor.onsuccess = function(e) {
+    verifyAndDelete(prefix, newFiles, e);
+    if (e.target.result) {
+      e.target.continue();
+    }
+  }
+
+  cursor.onerror = function (e) {
+    ok(false, "handleError was called : " + e.target.error.name);
+    devicestorage_cleanup();
+  }
+}
+
+function addNewFiles() {
+  addFiles(prefix, newFiles, Date.now(), enumerateNew);
+}
+
+
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_overwrite.html
@@ -0,0 +1,90 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for basic sanity of the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+var filename = "devicestorage/aaaa"
+
+devicestorage_setup();
+
+
+function deleteSuccess(e) {
+  devicestorage_cleanup();
+}
+
+function deleteError(e) {
+  ok(false, "deleteError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+function addOverwritingSuccess(e) {
+  ok(false, "addOverwritingSuccess was called.");
+}
+
+function addOverwritingError(e) {
+  ok(true, "Adding to the same location should fail");
+
+  var storage = navigator.getDeviceStorage("profile");
+  request = storage[0].delete(filename)
+  request.onsuccess = deleteSuccess;
+  request.onerror = deleteError;
+}
+
+function addSuccess(e) {
+  ok(true, "addSuccess was called");
+
+  var storage = navigator.getDeviceStorage("profile");
+  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+
+  request = storage[0].addNamed(createRandomBlob(), filename);
+  ok(request, "Should have a non-null request");
+
+  request.onsuccess = addOverwritingSuccess;
+  request.onerror = addOverwritingError;
+}
+
+function addError(e) {
+  // test file is already exists.  clean it up and try again..
+  var storage = navigator.getDeviceStorage("profile");
+  request = storage[0].delete(filename)
+  request.onsuccess = runtest;
+}
+
+function runtest() {
+  var storage = navigator.getDeviceStorage("profile");
+  ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+
+  request = storage[0].addNamed(createRandomBlob(), filename);
+  ok(request, "Should have a non-null request");
+
+  request.onsuccess = addSuccess;
+  request.onerror = addError;
+}
+
+runtest();
+
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/devicestorage/test_sanity.html
@@ -0,0 +1,72 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717103
+-->
+<head>
+  <title>Test for basic sanity of the device storage API </title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="devicestorage_common.js"></script>
+
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+devicestorage_setup()
+
+ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+
+var storage;
+
+var throws = false;
+try {
+ storage = navigator.getDeviceStorage();
+} catch(e) {throws = true}
+ok(throws, "getDeviceStorage takes one arg");
+
+storage = navigator.getDeviceStorage("kilimanjaro");
+ok(!storage, "kilimanjaro - Should not have this type of storage");
+
+storage = navigator.getDeviceStorage("temp");
+ok(storage, "temp - Should have getDeviceStorage");
+
+storage = navigator.getDeviceStorage("profile");
+ok(storage, "profile - Should have getDeviceStorage");
+
+var cursor = storage[0].enumerate();
+ok(cursor, "Should have a non-null cursor");
+
+var i = 4;
+cursor.onsuccess = function(e) {
+  i = i - 1;
+  if (i > 0) {
+    ok(true, "onsuccess was called");
+    e.target.continue();
+  }
+  else {
+    ok(true, "onsuccess was called 4 times");
+    devicestorage_cleanup();
+  }
+}
+
+cursor.onerror = function(e) {
+  ok(false, "onerror was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+</script>
+</pre>
+</body>
+</html>
+