Merge m-c to inbound.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 01 Apr 2013 09:50:07 -0400
changeset 133270 9941a05c88d9725256beb11295ac95820c5fd3dd
parent 133269 284e11d6678af0a26c204467783d362421993fd4 (current diff)
parent 133203 0b7c27024048cdfbbd62005d1c4ad5e7f6edf8a8 (diff)
child 133271 42912b8b82d4c868a38c6fbd96bbb097192202fc
push idunknown
push userunknown
push dateunknown
milestone22.0a1
Merge m-c to inbound.
dom/indexedDB/nsIIDBFactory.idl
--- a/addon-sdk/source/lib/sdk/indexed-db.js
+++ b/addon-sdk/source/lib/sdk/indexed-db.js
@@ -53,12 +53,11 @@ exports.indexedDB = Object.freeze({
 
 exports.IDBKeyRange = IDBKeyRange;
 exports.DOMException = Ci.nsIDOMDOMException;
 exports.IDBCursor = Ci.nsIIDBCursor;
 exports.IDBTransaction = Ci.nsIIDBTransaction;
 exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
 exports.IDBVersionChangeEvent = Ci.nsIIDBVersionChangeEvent;
 exports.IDBDatabase = Ci.nsIIDBDatabase;
-exports.IDBFactory = Ci.nsIIDBFactory;
 exports.IDBIndex = Ci.nsIIDBIndex;
 exports.IDBObjectStore = Ci.nsIIDBObjectStore;
 exports.IDBRequest = Ci.nsIIDBRequest;
--- a/addon-sdk/source/test/test-indexed-db.js
+++ b/addon-sdk/source/test/test-indexed-db.js
@@ -4,33 +4,33 @@
 
 "use strict";
 
 let xulApp = require("sdk/system/xul-app");
 if (xulApp.versionInRange(xulApp.platformVersion, "16.0a1", "*")) {
 new function tests() {
 
 const { indexedDB, IDBKeyRange, DOMException, IDBCursor, IDBTransaction,
-        IDBOpenDBRequest, IDBVersionChangeEvent, IDBDatabase, IDBFactory,
-        IDBIndex, IDBObjectStore, IDBRequest
+        IDBOpenDBRequest, IDBVersionChangeEvent, IDBDatabase, IDBIndex,
+        IDBObjectStore, IDBRequest
       } = require("sdk/indexed-db");
 
 exports["test indexedDB is frozen"] = function(assert){
   let original = indexedDB.open;
   let f = function(){};
   assert.throws(function(){indexedDB.open = f});
   assert.equal(indexedDB.open,original);
   assert.notEqual(indexedDB.open,f);
 
 };
 
 exports["test db variables"] = function(assert) {
   [ indexedDB, IDBKeyRange, DOMException, IDBCursor, IDBTransaction,
     IDBOpenDBRequest, IDBOpenDBRequest, IDBVersionChangeEvent,
-    IDBDatabase, IDBFactory, IDBIndex, IDBObjectStore, IDBRequest
+    IDBDatabase, IDBIndex, IDBObjectStore, IDBRequest
   ].forEach(function(value) {
     assert.notEqual(typeof(value), "undefined", "variable is defined");
   });
 }
 
 exports["test open"] = function(assert, done) {
   let request = indexedDB.open("MyTestDatabase");
   request.onerror = function(event) {
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -303,17 +303,16 @@
 #include "nsIMessageManager.h"
 #include "mozilla/dom/Element.h"
 #include "nsHTMLSelectElement.h"
 #include "HTMLLegendElement.h"
 
 #include "DOMSVGStringList.h"
 
 #include "mozilla/dom/indexedDB/IDBWrapperCache.h"
-#include "mozilla/dom/indexedDB/IDBFactory.h"
 #include "mozilla/dom/indexedDB/IDBFileHandle.h"
 #include "mozilla/dom/indexedDB/IDBRequest.h"
 #include "mozilla/dom/indexedDB/IDBDatabase.h"
 #include "mozilla/dom/indexedDB/IDBEvents.h"
 #include "mozilla/dom/indexedDB/IDBObjectStore.h"
 #include "mozilla/dom/indexedDB/IDBTransaction.h"
 #include "mozilla/dom/indexedDB/IDBCursor.h"
 #include "mozilla/dom/indexedDB/IDBKeyRange.h"
@@ -519,34 +518,16 @@ DOMCI_DATA_NO_CLASS(DOMConstructor)
   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, _flags)
 
 #define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags)          \
   NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, \
                                                  _flags)
 
 namespace {
 
-class IDBFactorySH : public nsDOMGenericSH
-{
-protected:
-  IDBFactorySH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
-  { }
-
-  virtual ~IDBFactorySH()
-  { }
-
-public:
-  NS_IMETHOD PostCreatePrototype(JSContext * cx, JSObject * proto);
-
-  static nsIClassInfo *doCreate(nsDOMClassInfoData *aData)
-  {
-    return new IDBFactorySH(aData);
-  }
-};
-
 class IDBEventTargetSH : public nsEventTargetSH
 {
 protected:
   IDBEventTargetSH(nsDOMClassInfoData* aData) : nsEventTargetSH(aData)
   { }
 
   virtual ~IDBEventTargetSH()
   { }
@@ -1002,18 +983,16 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageSender, nsDOMGenericSH,
                                        DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(DesktopNotification, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(DesktopNotificationCenter, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
-  NS_DEFINE_CLASSINFO_DATA(IDBFactory, IDBFactorySH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(IDBFileHandle, FileHandle, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH,
                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH,
                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -2504,20 +2483,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN(DesktopNotification, nsIDOMDesktopNotification)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotification)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(DesktopNotificationCenter, nsIDOMDesktopNotificationCenter)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotificationCenter)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(IDBFactory, nsIIDBFactory)
-    DOM_CLASSINFO_MAP_ENTRY(nsIIDBFactory)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(IDBFileHandle, nsIDOMFileHandle)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileHandle)
     DOM_CLASSINFO_MAP_ENTRY(nsIIDBFileHandle)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(IDBRequest, nsIIDBRequest)
     DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
@@ -6030,102 +6005,16 @@ nsEventSH::AddProperty(nsIXPConnectWrapp
 void
 nsEventSH::PreserveWrapper(nsISupports* aNative)
 {
   nsDOMEvent* event =
     nsDOMEvent::FromSupports(aNative);
   nsContentUtils::PreserveWrapper(aNative, event);
 }
 
-// IDBFactory helper
-
-/* static */
-template<nsresult (*func)(JSContext *, unsigned, jsval *, bool), bool aDelete>
-JSBool
-IDBFNativeShim(JSContext *cx, unsigned argc, jsval *vp)
-{
-  nsresult rv = (*func)(cx, argc, vp, aDelete);
-  if (NS_FAILED(rv)) {
-    xpc::Throw(cx, rv);
-    return false;
-  }
-
-  return true;
-}
-
-/* static */ nsresult
-IDBFOpenForPrincipal(JSContext *cx, unsigned argc, JS::Value *vp, bool aDelete)
-{
-  // Just to be on the extra-safe side
-  if (!nsContentUtils::IsCallerChrome()) {
-    MOZ_NOT_REACHED("Shouldn't be possible to get here");
-    return NS_ERROR_FAILURE;
-  }
-
-  JSObject* principalJS;
-  JSString* nameJS;
-  uint32_t version = 0;
-  if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "oS/u",
-                           &principalJS, &nameJS, &version)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  if (version < 1 && argc >= 3) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  if (aDelete) {
-    version = 0;
-  }
-
-  nsDependentJSString name;
-  NS_ENSURE_TRUE(name.init(cx, nameJS), NS_ERROR_UNEXPECTED);
-
-  nsCOMPtr<nsIPrincipal> principal = do_QueryWrapper(cx, principalJS);
-  NS_ENSURE_TRUE(principal, NS_ERROR_NO_INTERFACE);
-
-  nsCString extendedOrigin;
-  nsresult rv = principal->GetExtendedOrigin(extendedOrigin);
-  NS_ENSURE_FALSE(extendedOrigin.IsEmpty(), NS_ERROR_UNEXPECTED);
-
-  nsCOMPtr<nsIIDBFactory> factory =
-    do_QueryWrapper(cx, JS_THIS_OBJECT(cx, vp));
-  NS_ENSURE_TRUE(factory, NS_ERROR_NO_INTERFACE);
-
-  nsRefPtr<indexedDB::IDBOpenDBRequest> request;
-  rv = static_cast<indexedDB::IDBFactory*>(factory.get())->
-    OpenCommon(name, version, extendedOrigin, aDelete, cx,
-               getter_AddRefs(request));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return WrapNative(cx, JS_GetGlobalForScopeChain(cx),
-                    static_cast<nsIIDBOpenDBRequest*>(request),
-                    &NS_GET_IID(nsIIDBOpenDBRequest), true, vp);
-}
-
-NS_IMETHODIMP
-IDBFactorySH::PostCreatePrototype(JSContext * cx, JSObject * proto)
-{
-  // set up our proto first
-  nsresult rv = nsDOMGenericSH::PostCreatePrototype(cx, proto);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(proto)) &&
-      (!JS_DefineFunction(cx, proto, "openForPrincipal",
-                          IDBFNativeShim<IDBFOpenForPrincipal, false>,
-                          3, JSPROP_ENUMERATE) ||
-       !JS_DefineFunction(cx, proto, "deleteForPrincipal",
-                          IDBFNativeShim<IDBFOpenForPrincipal, true>,
-                          2, JSPROP_ENUMERATE))) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  return rv;
-}
-
 // IDBEventTarget helper
 
 NS_IMETHODIMP
 IDBEventTargetSH::PreCreate(nsISupports *aNativeObj, JSContext *aCx,
                             JSObject *aGlobalObj, JSObject **aParentObj)
 {
   IDBWrapperCache *target = IDBWrapperCache::FromSupports(aNativeObj);
   JSObject *parent = target->GetParentObject();
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -231,17 +231,16 @@ DOMCI_CLASS(AnimationEvent)
 
 DOMCI_CLASS(ContentFrameMessageManager)
 DOMCI_CLASS(ChromeMessageBroadcaster)
 DOMCI_CLASS(ChromeMessageSender)
 
 DOMCI_CLASS(DesktopNotification)
 DOMCI_CLASS(DesktopNotificationCenter)
 
-DOMCI_CLASS(IDBFactory)
 DOMCI_CLASS(IDBFileHandle)
 DOMCI_CLASS(IDBRequest)
 DOMCI_CLASS(IDBDatabase)
 DOMCI_CLASS(IDBObjectStore)
 DOMCI_CLASS(IDBTransaction)
 DOMCI_CLASS(IDBCursor)
 DOMCI_CLASS(IDBCursorWithValue)
 DOMCI_CLASS(IDBKeyRange)
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -8839,17 +8839,17 @@ nsGlobalWindow::GetLocalStorage(nsIDOMSt
   return NS_OK;
 }
 
 //*****************************************************************************
 // nsGlobalWindow::nsIDOMStorageIndexedDB
 //*****************************************************************************
 
 NS_IMETHODIMP
-nsGlobalWindow::GetIndexedDB(nsIIDBFactory** _retval)
+nsGlobalWindow::GetIndexedDB(nsISupports** _retval)
 {
   if (!mIndexedDB) {
     nsresult rv;
 
     // If the document has the sandboxed origin flag set
     // don't allow access to indexedDB.
     if (mDoc && (mDoc->GetSandboxFlags() & SANDBOXED_ORIGIN)) {
       return NS_ERROR_DOM_SECURITY_ERR;
@@ -8872,23 +8872,23 @@ nsGlobalWindow::GetIndexedDB(nsIIDBFacto
     }
 
     // This may be null if being created from a file.
     rv = indexedDB::IDBFactory::Create(this, nullptr,
                                        getter_AddRefs(mIndexedDB));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  nsCOMPtr<nsIIDBFactory> request(mIndexedDB);
+  nsCOMPtr<nsISupports> request(mIndexedDB);
   request.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsGlobalWindow::GetMozIndexedDB(nsIIDBFactory** _retval)
+nsGlobalWindow::GetMozIndexedDB(nsISupports** _retval)
 {
   return GetIndexedDB(_retval);
 }
 
 //*****************************************************************************
 // nsGlobalWindow::nsIInterfaceRequestor
 //*****************************************************************************
 
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -46,17 +46,16 @@
 #include "nsRect.h"
 #include "mozFlushType.h"
 #include "prclist.h"
 #include "nsIDOMStorageObsolete.h"
 #include "nsIDOMStorageEvent.h"
 #include "nsIDOMStorageIndexedDB.h"
 #include "nsIDOMOfflineResourceList.h"
 #include "nsIArray.h"
-#include "nsIIDBFactory.h"
 #include "nsFrameMessageManager.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/TimeStamp.h"
 #include "nsIDOMTouchEvent.h"
 #include "nsIInlineEventHandlers.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsIIdleObserver.h"
 #include "nsIDOMWakeLock.h"
@@ -115,16 +114,19 @@ class nsDOMWindowUtils;
 class nsIIdleService;
 
 class nsWindowSizes;
 
 namespace mozilla {
 namespace dom {
 class Navigator;
 class URL;
+namespace indexedDB {
+class IDBFactory;
+} // namespace indexedDB
 } // namespace dom
 } // namespace mozilla
 
 extern nsresult
 NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow,
                           bool *aIsInterval,
                           int32_t *aInterval,
                           nsIScriptTimeoutHandler **aRet);
@@ -1143,17 +1145,17 @@ protected:
   bool mCleanedUp, mCallCleanUpAfterModalDialogCloses;
 
   nsCOMPtr<nsIDOMOfflineResourceList> mApplicationCache;
 
   nsDataHashtable<nsPtrHashKey<nsXBLPrototypeHandler>, JSObject*> mCachedXBLPrototypeHandlers;
 
   nsCOMPtr<nsIDocument> mSuspendedDoc;
 
-  nsCOMPtr<nsIIDBFactory> mIndexedDB;
+  nsRefPtr<mozilla::dom::indexedDB::IDBFactory> mIndexedDB;
 
   // This counts the number of windows that have been opened in rapid succession
   // (i.e. within dom.successive_dialog_time_limit of each other). It is reset
   // to 0 once a dialog is opened after dom.successive_dialog_time_limit seconds
   // have elapsed without any other dialogs.
   uint32_t                      mDialogAbuseCount;
 
   // This holds the time when the last modal dialog was shown. If more than
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -488,16 +488,22 @@ DOMInterfaces = {
         'sheet'
     ]
 },
 
 'HTMLUListElement': {
     'nativeType' : 'mozilla::dom::HTMLSharedListElement'
 },
 
+'IDBFactory': {
+    'nativeType': 'mozilla::dom::indexedDB::IDBFactory',
+    'implicitJSContext': [ 'open', 'deleteDatabase', 'openForPrincipal',
+                           'deleteForPrincipal' ],
+},
+
 'IDBVersionChangeEvent': {
     'nativeType': 'mozilla::dom::indexedDB::IDBVersionChangeEvent',
     'headerFile': 'IDBEvents.h',
 },
 
 'IID': [
 {
     'nativeType': 'nsIJSID',
@@ -1384,16 +1390,17 @@ addExternalIface('CanvasPattern', header
 addExternalIface('Counter')
 addExternalIface('CSSRule')
 addExternalIface('DOMError')
 addExternalIface('CSSRuleList')
 addExternalIface('DOMStringList')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement')
+addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
 addExternalIface('LockedFile')
 addExternalIface('MediaList')
 addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
 addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
 addExternalIface('MozControllers', nativeType='nsIControllers')
 addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
--- a/dom/bindings/Errors.msg
+++ b/dom/bindings/Errors.msg
@@ -31,8 +31,9 @@ MSG_DEF(MSG_ENFORCE_RANGE_NON_FINITE, 1,
 MSG_DEF(MSG_ENFORCE_RANGE_OUT_OF_RANGE, 1, "Value is out of range for {0}.")
 MSG_DEF(MSG_NOT_SEQUENCE, 0, "object can not be converted to a sequence")
 MSG_DEF(MSG_NOT_DICTIONARY, 0, "value can not be converted to a dictionary")
 MSG_DEF(MSG_INVALID_ARG, 2, "argument {0} is not valid for any of the {1}-argument overloads")
 MSG_DEF(MSG_GLOBAL_NOT_NATIVE, 0, "global is not a native object")
 MSG_DEF(MSG_ENCODING_NOT_SUPPORTED, 1, "The given encoding '{0}' is not supported.")
 MSG_DEF(MSG_DOM_ENCODING_NOT_UTF, 0, "The encoding must be utf-8, utf-16, or utf-16be.")
 MSG_DEF(MSG_NOT_FINITE, 0, "Floating-point value is not finite.")
+MSG_DEF(MSG_INVALID_VERSION, 0, "0 (Zero) is not a valid database version.")
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -12,16 +12,17 @@
 #include "nsIPrincipal.h"
 #include "nsIScriptContext.h"
 #include "nsIXPConnect.h"
 #include "nsIXPCScriptable.h"
 
 #include "jsdbgapi.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentChild.h"
+#include "mozilla/dom/IDBFactoryBinding.h"
 #include "mozilla/dom/PBrowserChild.h"
 #include "mozilla/dom/quota/OriginOrPatternString.h"
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/storage.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsCharSeparatedTokenizer.h"
@@ -46,17 +47,20 @@
 #include "ipc/IndexedDBChild.h"
 #include <algorithm>
 
 USING_INDEXEDDB_NAMESPACE
 USING_QUOTA_NAMESPACE
 
 using mozilla::dom::ContentChild;
 using mozilla::dom::ContentParent;
+using mozilla::dom::NonNull;
+using mozilla::dom::Optional;
 using mozilla::dom::TabChild;
+using mozilla::ErrorResult;
 
 namespace {
 
 struct ObjectStoreInfoMap
 {
   ObjectStoreInfoMap()
   : id(INT64_MIN), info(nullptr) { }
 
@@ -65,16 +69,17 @@ struct ObjectStoreInfoMap
 };
 
 } // anonymous namespace
 
 IDBFactory::IDBFactory()
 : mOwningObject(nullptr), mActorChild(nullptr), mActorParent(nullptr),
   mContentParent(nullptr), mRootedOwningObject(false)
 {
+  SetIsDOMBinding();
 }
 
 IDBFactory::~IDBFactory()
 {
   NS_ASSERTION(!mActorParent, "Actor parent owns us, how can we be dying?!");
   if (mActorChild) {
     NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
     mActorChild->Send__delete__(mActorChild);
@@ -478,50 +483,51 @@ IDBFactory::SetDatabaseMetadata(Database
 
   return NS_OK;
 }
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBFactory)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBFactory)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBFactory)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
-  NS_INTERFACE_MAP_ENTRY(nsIIDBFactory)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBFactory)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBFactory)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBFactory)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
   if (tmp->mOwningObject) {
     tmp->mOwningObject = nullptr;
   }
   if (tmp->mRootedOwningObject) {
     NS_DROP_JS_OBJECTS(tmp, IDBFactory);
     tmp->mRootedOwningObject = false;
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBFactory)
+  NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mOwningObject)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 DOMCI_DATA(IDBFactory, IDBFactory)
 
 nsresult
-IDBFactory::OpenCommon(const nsAString& aName,
-                       int64_t aVersion,
-                       const nsACString& aASCIIOrigin,
-                       bool aDeleting,
-                       JSContext* aCallingCx,
-                       IDBOpenDBRequest** _retval)
+IDBFactory::OpenInternal(const nsAString& aName,
+                         int64_t aVersion,
+                         const nsACString& aASCIIOrigin,
+                         bool aDeleting,
+                         JSContext* aCallingCx,
+                         IDBOpenDBRequest** _retval)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   NS_ASSERTION(mWindow || mOwningObject, "Must have one of these!");
 
   nsCOMPtr<nsPIDOMWindow> window;
   JSObject* scriptOwner = nullptr;
   StoragePrivilege privilege;
 
@@ -581,65 +587,107 @@ IDBFactory::OpenCommon(const nsAString& 
 
     dbActor->SetRequest(request);
   }
 
   request.forget(_retval);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-IDBFactory::Open(const nsAString& aName,
-                 int64_t aVersion,
-                 JSContext* aCx,
-                 uint8_t aArgc,
-                 nsIIDBOpenDBRequest** _retval)
+JSObject*
+IDBFactory::WrapObject(JSContext* aCx, JSObject* aScope)
 {
-  if (aVersion < 1 && aArgc) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  nsRefPtr<IDBOpenDBRequest> request;
-  nsresult rv = OpenCommon(aName, aVersion, false, aCx,
-                           getter_AddRefs(request));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  request.forget(_retval);
-  return NS_OK;
+  return IDBFactoryBinding::Wrap(aCx, aScope, this);
 }
 
-NS_IMETHODIMP
-IDBFactory::DeleteDatabase(const nsAString& aName,
-                           JSContext* aCx,
-                           nsIIDBOpenDBRequest** _retval)
-{
-  nsRefPtr<IDBOpenDBRequest> request;
-  nsresult rv = OpenCommon(aName, 0, true, aCx, getter_AddRefs(request));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  request.forget(_retval);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-IDBFactory::Cmp(const jsval& aFirst,
-                const jsval& aSecond,
-                JSContext* aCx,
-                int16_t* _retval)
+int16_t
+IDBFactory::Cmp(JSContext* aCx, JS::Value aFirst, JS::Value aSecond,
+                ErrorResult& aRv)
 {
   Key first, second;
   nsresult rv = first.SetFromJSVal(aCx, aFirst);
   if (NS_FAILED(rv)) {
-    return rv;
+    aRv.Throw(rv);
+    return 0;
   }
 
   rv = second.SetFromJSVal(aCx, aSecond);
   if (NS_FAILED(rv)) {
-    return rv;
+    aRv.Throw(rv);
+    return 0;
   }
 
   if (first.IsUnset() || second.IsUnset()) {
-    return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
+    aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
+    return 0;
+  }
+
+  return Key::CompareKeys(first, second);
+}
+
+already_AddRefed<nsIIDBOpenDBRequest>
+IDBFactory::OpenForPrincipal(JSContext* aCx, nsIPrincipal* aPrincipal,
+                             const NonNull<nsAString>& aName,
+                             const Optional<uint64_t>& aVersion,
+                             ErrorResult& aRv)
+{
+  // Just to be on the extra-safe side
+  if (!nsContentUtils::IsCallerChrome()) {
+    MOZ_CRASH();
+  }
+
+  return Open(aCx, aPrincipal, aName, aVersion, false, aRv);
+}
+
+already_AddRefed<nsIIDBOpenDBRequest>
+IDBFactory::DeleteForPrincipal(JSContext* aCx, nsIPrincipal* aPrincipal,
+                               const NonNull<nsAString>& aName,
+                               ErrorResult& aRv)
+{
+  // Just to be on the extra-safe side
+  if (!nsContentUtils::IsCallerChrome()) {
+    MOZ_CRASH();
   }
 
-  *_retval = Key::CompareKeys(first, second);
-  return NS_OK;
+  return Open(aCx, aPrincipal, aName, Optional<uint64_t>(), true, aRv);
 }
+
+already_AddRefed<nsIIDBOpenDBRequest>
+IDBFactory::Open(JSContext* aCx, nsIPrincipal* aPrincipal,
+                 const nsAString& aName, const Optional<uint64_t>& aVersion,
+                 bool aDelete, ErrorResult& aRv)
+{
+  nsresult rv;
+
+  nsCString origin;
+  if (aPrincipal) {
+    rv = QuotaManager::GetASCIIOriginFromPrincipal(aPrincipal, origin);
+    if (NS_FAILED(rv)) {
+      aRv.Throw(rv);
+      return nullptr;
+    }
+  }
+  else {
+    origin = mASCIIOrigin;
+  }
+
+  uint64_t version;
+  if (!aDelete && aVersion.WasPassed()) {
+    version = aVersion.Value();
+    if (version < 1) {
+      aRv.ThrowTypeError(MSG_INVALID_VERSION);
+      return nullptr;
+    }
+  }
+  else {
+    version = 0;
+  }
+
+  nsRefPtr<IDBOpenDBRequest> request;
+  rv = OpenInternal(aName, version, origin, aDelete, aCx,
+                    getter_AddRefs(request));
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
+
+  return request.forget();
+}
--- a/dom/indexedDB/IDBFactory.h
+++ b/dom/indexedDB/IDBFactory.h
@@ -5,23 +5,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_indexeddb_idbfactory_h__
 #define mozilla_dom_indexeddb_idbfactory_h__
 
 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
 
 #include "mozIStorageConnection.h"
-#include "nsIIDBFactory.h"
 
+#include "mozilla/dom/BindingUtils.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsWrapperCache.h"
 
 class nsIAtom;
 class nsIFile;
 class nsIFileURL;
+class nsIIDBOpenDBRequest;
 class nsPIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 class ContentParent;
 }
 }
 
@@ -30,44 +32,38 @@ BEGIN_INDEXEDDB_NAMESPACE
 struct DatabaseInfo;
 class IDBDatabase;
 class IDBOpenDBRequest;
 class IndexedDBChild;
 class IndexedDBParent;
 
 struct ObjectStoreInfo;
 
-class IDBFactory MOZ_FINAL : public nsIIDBFactory
+class IDBFactory MOZ_FINAL : public nsISupports,
+                             public nsWrapperCache
 {
   typedef mozilla::dom::ContentParent ContentParent;
   typedef nsTArray<nsRefPtr<ObjectStoreInfo> > ObjectStoreInfoArray;
 
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
-  NS_DECL_NSIIDBFACTORY
 
   // Called when using IndexedDB from a window in a different process.
   static nsresult Create(nsPIDOMWindow* aWindow,
                          const nsACString& aASCIIOrigin,
                          ContentParent* aContentParent,
                          IDBFactory** aFactory);
 
   // Called when using IndexedDB from a window in the current process.
   static nsresult Create(nsPIDOMWindow* aWindow,
                          ContentParent* aContentParent,
-                         nsIIDBFactory** aFactory)
+                         IDBFactory** aFactory)
   {
-    nsRefPtr<IDBFactory> factory;
-    nsresult rv =
-      Create(aWindow, EmptyCString(), aContentParent, getter_AddRefs(factory));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    factory.forget(aFactory);
-    return NS_OK;
+    return Create(aWindow, EmptyCString(), aContentParent, aFactory);
   }
 
   // Called when using IndexedDB from a JS component or a JSM in the current
   // process.
   static nsresult Create(JSContext* aCx,
                          JSObject* aOwningObject,
                          ContentParent* aContentParent,
                          IDBFactory** aFactory);
@@ -91,32 +87,32 @@ public:
                           ObjectStoreInfoArray& aObjectStores);
 
   static nsresult
   SetDatabaseMetadata(DatabaseInfo* aDatabaseInfo,
                       uint64_t aVersion,
                       ObjectStoreInfoArray& aObjectStores);
 
   nsresult
-  OpenCommon(const nsAString& aName,
-             int64_t aVersion,
-             const nsACString& aASCIIOrigin,
-             bool aDeleting,
-             JSContext* aCallingCx,
-             IDBOpenDBRequest** _retval);
+  OpenInternal(const nsAString& aName,
+               int64_t aVersion,
+               const nsACString& aASCIIOrigin,
+               bool aDeleting,
+               JSContext* aCallingCx,
+               IDBOpenDBRequest** _retval);
 
   nsresult
-  OpenCommon(const nsAString& aName,
-             int64_t aVersion,
-             bool aDeleting,
-             JSContext* aCallingCx,
-             IDBOpenDBRequest** _retval)
+  OpenInternal(const nsAString& aName,
+               int64_t aVersion,
+               bool aDeleting,
+               JSContext* aCallingCx,
+               IDBOpenDBRequest** _retval)
   {
-    return OpenCommon(aName, aVersion, mASCIIOrigin, aDeleting, aCallingCx,
-                      _retval);
+    return OpenInternal(aName, aVersion, mASCIIOrigin, aDeleting, aCallingCx,
+                        _retval);
   }
 
   void
   SetActor(IndexedDBChild* aActorChild)
   {
     NS_ASSERTION(!aActorChild || !mActorChild, "Shouldn't have more than one!");
     mActorChild = aActorChild;
   }
@@ -129,20 +125,60 @@ public:
   }
 
   const nsCString&
   GetASCIIOrigin() const
   {
     return mASCIIOrigin;
   }
 
+  // WrapperCache
+  nsPIDOMWindow* GetParentObject() const
+  {
+    return mWindow;
+  }
+
+  virtual JSObject*
+  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+
+  // WebIDL
+  already_AddRefed<nsIIDBOpenDBRequest>
+  Open(JSContext* aCx, const NonNull<nsAString>& aName,
+       const Optional<uint64_t>& aVersion, ErrorResult& aRv)
+  {
+    return Open(aCx, nullptr, aName, aVersion, false, aRv);
+  }
+
+  already_AddRefed<nsIIDBOpenDBRequest>
+  DeleteDatabase(JSContext* aCx, const NonNull<nsAString>& aName,
+                 ErrorResult& aRv)
+  {
+    return Open(aCx, nullptr, aName, Optional<uint64_t>(), true, aRv);
+  }
+
+  int16_t
+  Cmp(JSContext* aCx, JS::Value aFirst, JS::Value aSecond, ErrorResult& aRv);
+
+  already_AddRefed<nsIIDBOpenDBRequest>
+  OpenForPrincipal(JSContext* aCx, nsIPrincipal* aPrincipal,
+                   const NonNull<nsAString>& aName,
+                   const Optional<uint64_t>& aVersion, ErrorResult& aRv);
+
+  already_AddRefed<nsIIDBOpenDBRequest>
+  DeleteForPrincipal(JSContext* aCx, nsIPrincipal* aPrincipal,
+                     const NonNull<nsAString>& aName, ErrorResult& aRv);
+
 private:
   IDBFactory();
   ~IDBFactory();
 
+  already_AddRefed<nsIIDBOpenDBRequest>
+  Open(JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
+       const Optional<uint64_t>& aVersion, bool aDelete, ErrorResult& aRv);
+
   nsCString mASCIIOrigin;
 
   // If this factory lives on a window then mWindow must be non-null. Otherwise
   // mOwningObject must be non-null.
   nsCOMPtr<nsPIDOMWindow> mWindow;
   JSObject* mOwningObject;
 
   IndexedDBChild* mActorChild;
--- a/dom/indexedDB/ipc/IndexedDBParent.cpp
+++ b/dom/indexedDB/ipc/IndexedDBParent.cpp
@@ -157,18 +157,18 @@ IndexedDBParent::RecvPIndexedDBDatabaseC
   }
 
   if (!mFactory) {
     return true;
   }
 
   nsRefPtr<IDBOpenDBRequest> request;
   nsresult rv =
-    mFactory->OpenCommon(aName, aVersion, false, nullptr,
-                         getter_AddRefs(request));
+    mFactory->OpenInternal(aName, aVersion, false, nullptr,
+                           getter_AddRefs(request));
   NS_ENSURE_SUCCESS(rv, false);
 
   IndexedDBDatabaseParent* actor =
     static_cast<IndexedDBDatabaseParent*>(aActor);
 
   rv = actor->SetOpenRequest(request);
   NS_ENSURE_SUCCESS(rv, false);
 
@@ -194,17 +194,17 @@ IndexedDBParent::RecvPIndexedDBDeleteDat
   }
 
   IndexedDBDeleteDatabaseRequestParent* actor =
     static_cast<IndexedDBDeleteDatabaseRequestParent*>(aActor);
 
   nsRefPtr<IDBOpenDBRequest> request;
 
   nsresult rv =
-    mFactory->OpenCommon(aName, 0, true, nullptr, getter_AddRefs(request));
+    mFactory->OpenInternal(aName, 0, true, nullptr, getter_AddRefs(request));
   NS_ENSURE_SUCCESS(rv, false);
 
   rv = actor->SetOpenRequest(request);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
--- a/dom/indexedDB/moz.build
+++ b/dom/indexedDB/moz.build
@@ -5,17 +5,16 @@
 
 DIRS += ['ipc']
 TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
     'nsIIDBCursor.idl',
     'nsIIDBCursorWithValue.idl',
     'nsIIDBDatabase.idl',
-    'nsIIDBFactory.idl',
     'nsIIDBFileHandle.idl',
     'nsIIDBIndex.idl',
     'nsIIDBKeyRange.idl',
     'nsIIDBObjectStore.idl',
     'nsIIDBOpenDBRequest.idl',
     'nsIIDBRequest.idl',
     'nsIIDBTransaction.idl',
     'nsIIDBVersionChangeEvent.idl',
deleted file mode 100644
--- a/dom/indexedDB/nsIIDBFactory.idl
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 et sw=2 tw=80: */
-/* 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/. */
-
-#include "nsISupports.idl"
-
-interface nsIIDBKeyRange;
-interface nsIIDBOpenDBRequest;
-
-/**
- * Interface that defines the indexedDB property on a window.  See
- * http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBFactory
- * for more information.
- */
-[scriptable, builtinclass, uuid(3c763a8f-df53-491d-9635-e1d959e43c0c)]
-interface nsIIDBFactory : nsISupports
-{
-  [implicit_jscontext, optional_argc]
-  nsIIDBOpenDBRequest
-  open([Null(Stringify)] in DOMString name,
-       [optional] in long long version);
-
-  [implicit_jscontext]
-  nsIIDBOpenDBRequest
-  deleteDatabase(in AString name);
-
-  [implicit_jscontext]
-  short
-  cmp(in jsval first,
-      in jsval second);
-};
--- a/dom/indexedDB/test/Makefile.in
+++ b/dom/indexedDB/test/Makefile.in
@@ -67,16 +67,17 @@ MOCHITEST_FILES = \
   test_index_empty_keyPath.html \
   test_index_getAll.html \
   test_index_getAllObjects.html \
   test_index_object_cursors.html \
   test_index_update_delete.html \
   test_indexes.html \
   test_indexes_bad_values.html \
   test_indexes_funny_things.html \
+  test_invalid_version.html \
   test_key_requirements.html \
   test_keys.html \
   test_leaving_page.html \
   test_multientry.html \
   test_names_sorted.html \
   test_objectCursors.html \
   test_objectStore_inline_autoincrement_key_added_on_put.html \
   test_objectStore_remove_values.html \
new file mode 100644
--- /dev/null
+++ b/dom/indexedDB/test/test_invalid_version.html
@@ -0,0 +1,19 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+  <title>Indexed Database Property Test</title>
+
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+  <script type="text/javascript;version=1.7" src="unit/test_invalid_version.js"></script>
+  <script type="text/javascript;version=1.7" src="helpers.js"></script>
+
+</head>
+
+<body onload="runTest();"></body>
+
+</html>
--- a/dom/indexedDB/test/unit/Makefile.in
+++ b/dom/indexedDB/test/unit/Makefile.in
@@ -31,16 +31,17 @@ MOCHITEST_FILES = \
   test_index_empty_keyPath.js \
   test_index_getAll.js \
   test_index_getAllObjects.js \
   test_index_object_cursors.js \
   test_index_update_delete.js \
   test_indexes.js \
   test_indexes_bad_values.js \
   test_indexes_funny_things.js \
+  test_invalid_version.js \
   test_key_requirements.js \
   test_keys.js \
   test_multientry.js \
   test_names_sorted.js \
   test_object_identity.js \
   test_objectCursors.js \
   test_objectStore_inline_autoincrement_key_added_on_put.js \
   test_objectStore_remove_values.js \
--- a/dom/indexedDB/test/unit/head.js
+++ b/dom/indexedDB/test/unit/head.js
@@ -6,17 +6,16 @@
 const { 'classes': Cc, 'interfaces': Ci } = Components;
 
 const DOMException = Ci.nsIDOMDOMException;
 const IDBCursor = Ci.nsIIDBCursor;
 const IDBTransaction = Ci.nsIIDBTransaction;
 const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
 const IDBVersionChangeEvent = Ci.nsIIDBVersionChangeEvent
 const IDBDatabase = Ci.nsIIDBDatabase
-const IDBFactory = Ci.nsIIDBFactory
 const IDBIndex = Ci.nsIIDBIndex
 const IDBObjectStore = Ci.nsIIDBObjectStore
 const IDBRequest = Ci.nsIIDBRequest
 
 function is(a, b, msg) {
   dump("is(" + a + ", " + b + ", \"" + msg + "\")");
   do_check_eq(a, b, Components.stack.caller);
 }
new file mode 100644
--- /dev/null
+++ b/dom/indexedDB/test/unit/test_invalid_version.js
@@ -0,0 +1,32 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+var testGenerator = testSteps();
+
+function testSteps()
+{
+  const name = this.window ? window.location.pathname : "Splendid Test";
+
+  try {
+    indexedDB.open(name, 0);
+    ok(false, "Should have thrown!");
+  }
+  catch (e) {
+    ok(e instanceof TypeError, "Got TypeError.");
+    is(e.name, "TypeError", "Good error name.");
+  }
+
+  try {
+    indexedDB.open(name, -1);
+    ok(false, "Should have thrown!");
+  }
+  catch (e) {
+    ok(e instanceof TypeError, "Got TypeError.");
+    is(e.name, "TypeError", "Good error name.");
+  }
+
+  finishTest();
+  yield;
+}
--- a/dom/indexedDB/test/unit/xpcshell.ini
+++ b/dom/indexedDB/test/unit/xpcshell.ini
@@ -24,16 +24,17 @@ tail =
 [test_index_empty_keyPath.js]
 [test_index_getAll.js]
 [test_index_getAllObjects.js]
 [test_index_object_cursors.js]
 [test_index_update_delete.js]
 [test_indexes.js]
 [test_indexes_bad_values.js]
 [test_indexes_funny_things.js]
+[test_invalid_version.js]
 [test_key_requirements.js]
 [test_keys.js]
 [test_multientry.js]
 [test_names_sorted.js]
 [test_object_identity.js]
 [test_objectCursors.js]
 [test_objectStore_inline_autoincrement_key_added_on_put.js]
 [test_objectStore_remove_values.js]
--- a/dom/interfaces/storage/nsIDOMStorageIndexedDB.idl
+++ b/dom/interfaces/storage/nsIDOMStorageIndexedDB.idl
@@ -8,19 +8,17 @@
 /**
  * Interface for a client side storage. See
  * http://www.whatwg.org/specs/web-apps/current-work/#scs-client-side and
  * http://www.w3.org/TR/IndexedDB/ for more information.
  *
  * Allows access to contextual storage areas.
  */
 
-interface nsIIDBFactory;
-
-[scriptable, uuid(94ca74e8-9cff-456e-a7a4-a4071a32ff58)]
+[scriptable, uuid(f4deeef5-32d3-4048-bb56-883330fd8f35)]
 interface nsIDOMStorageIndexedDB : nsISupports
 {
   /**
    * Indexed Databases for the current browsing context.
    */
-  readonly attribute nsIIDBFactory indexedDB;
-  readonly attribute nsIIDBFactory mozIndexedDB;
+  readonly attribute nsISupports indexedDB;
+  readonly attribute nsISupports mozIndexedDB;
 };
new file mode 100644
--- /dev/null
+++ b/dom/webidl/IDBFactory.webidl
@@ -0,0 +1,40 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/.
+ */
+
+interface IDBOpenDBRequest;
+interface Principal;
+
+/**
+ * Interface that defines the indexedDB property on a window.  See
+ * http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBFactory
+ * for more information.
+ */
+interface IDBFactory {
+  [Throws]
+  IDBOpenDBRequest
+  open(DOMString name,
+       [EnforceRange] optional unsigned long long version);
+
+  [Throws]
+  IDBOpenDBRequest
+  deleteDatabase(DOMString name);
+
+  [Throws]
+  short
+  cmp(any first,
+      any second);
+
+  [Throws, ChromeOnly]
+  IDBOpenDBRequest
+  openForPrincipal(Principal principal,
+                   DOMString name,
+                   [EnforceRange] optional unsigned long long version);
+
+  [Throws, ChromeOnly]
+  IDBOpenDBRequest
+  deleteForPrincipal(Principal principal,
+                     DOMString name);
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -130,16 +130,17 @@ webidl_files = \
   HTMLTableRowElement.webidl \
   HTMLTableSectionElement.webidl \
   HTMLTemplateElement.webidl \
   HTMLTextAreaElement.webidl \
   HTMLTimeElement.webidl \
   HTMLTitleElement.webidl \
   HTMLUListElement.webidl \
   HTMLVideoElement.webidl \
+  IDBFactory.webidl \
   IDBVersionChangeEvent.webidl \
   ImageData.webidl \
   InspectorUtils.webidl \
   LinkStyle.webidl \
   LocalMediaStream.webidl \
   Location.webidl \
   MediaStream.webidl \
   MessageEvent.webidl \
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -201,17 +201,16 @@ members = [
     'nsIDOMNotifyAudioAvailableEvent.frameBuffer',
     'nsIDOMNotifyAudioAvailableEvent.time',
     'nsIDOMHTMLAudioElement.mozWriteAudio',
 
     # dom/indexedDB
     'nsIIDBCursor.*',
     'nsIIDBCursorWithValue.*',
     'nsIIDBDatabase.*',
-    'nsIIDBFactory.*',
     'nsIIDBFileHandle.*',
     'nsIIDBIndex.*',
     'nsIIDBKeyRange.*',
     'nsIIDBObjectStore.*',
     'nsIIDBRequest.*',
     'nsIIDBTransaction.*',
     'nsIIDBOpenDBRequest.*',
     'nsIIDBVersionChangeEvent.*',