Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2013-04-01 09:50:07 -04:00
commit 36c73b1f88
23 changed files with 275 additions and 237 deletions

View File

@ -58,7 +58,6 @@ 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;

View File

@ -9,8 +9,8 @@ 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){
@ -25,7 +25,7 @@ exports["test indexedDB is frozen"] = function(assert){
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");
});

View File

@ -308,7 +308,6 @@
#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"
@ -524,24 +523,6 @@ DOMCI_DATA_NO_CLASS(DOMConstructor)
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:
@ -1007,8 +988,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
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,
@ -2509,10 +2488,6 @@ nsDOMClassInfo::Init()
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)
@ -6035,92 +6010,6 @@ nsEventSH::PreserveWrapper(nsISupports* 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

View File

@ -236,7 +236,6 @@ DOMCI_CLASS(ChromeMessageSender)
DOMCI_CLASS(DesktopNotification)
DOMCI_CLASS(DesktopNotificationCenter)
DOMCI_CLASS(IDBFactory)
DOMCI_CLASS(IDBFileHandle)
DOMCI_CLASS(IDBRequest)
DOMCI_CLASS(IDBDatabase)

View File

@ -8844,7 +8844,7 @@ nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage)
//*****************************************************************************
NS_IMETHODIMP
nsGlobalWindow::GetIndexedDB(nsIIDBFactory** _retval)
nsGlobalWindow::GetIndexedDB(nsISupports** _retval)
{
if (!mIndexedDB) {
nsresult rv;
@ -8877,13 +8877,13 @@ nsGlobalWindow::GetIndexedDB(nsIIDBFactory** _retval)
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);
}

View File

@ -51,7 +51,6 @@
#include "nsIDOMStorageIndexedDB.h"
#include "nsIDOMOfflineResourceList.h"
#include "nsIArray.h"
#include "nsIIDBFactory.h"
#include "nsFrameMessageManager.h"
#include "mozilla/LinkedList.h"
#include "mozilla/TimeStamp.h"
@ -120,6 +119,9 @@ namespace mozilla {
namespace dom {
class Navigator;
class URL;
namespace indexedDB {
class IDBFactory;
} // namespace indexedDB
} // namespace dom
} // namespace mozilla
@ -1148,7 +1150,7 @@ protected:
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

View File

@ -493,6 +493,12 @@ DOMInterfaces = {
'nativeType' : 'mozilla::dom::HTMLSharedListElement'
},
'IDBFactory': {
'nativeType': 'mozilla::dom::indexedDB::IDBFactory',
'implicitJSContext': [ 'open', 'deleteDatabase', 'openForPrincipal',
'deleteForPrincipal' ],
},
'IDBVersionChangeEvent': {
'nativeType': 'mozilla::dom::indexedDB::IDBVersionChangeEvent',
'headerFile': 'IDBEvents.h',
@ -1389,6 +1395,7 @@ 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')

View File

@ -36,3 +36,4 @@ 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.")

View File

@ -17,6 +17,7 @@
#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"
@ -51,7 +52,10 @@ 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 {
@ -70,6 +74,7 @@ IDBFactory::IDBFactory()
: mOwningObject(nullptr), mActorChild(nullptr), mActorParent(nullptr),
mContentParent(nullptr), mRootedOwningObject(false)
{
SetIsDOMBinding();
}
IDBFactory::~IDBFactory()
@ -483,9 +488,8 @@ 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)
@ -494,6 +498,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBFactory)
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;
}
@ -505,18 +510,19 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBFactory)
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!");
@ -586,60 +592,102 @@ IDBFactory::OpenCommon(const nsAString& aName,
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;
}
*_retval = Key::CompareKeys(first, second);
return NS_OK;
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();
}
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();
}

View File

@ -10,13 +10,15 @@
#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 {
@ -35,7 +37,8 @@ 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;
@ -43,7 +46,6 @@ class IDBFactory MOZ_FINAL : public nsIIDBFactory
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,
@ -54,15 +56,9 @@ public:
// 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
@ -96,22 +92,22 @@ public:
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
@ -134,10 +130,50 @@ public:
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

View File

@ -162,8 +162,8 @@ IndexedDBParent::RecvPIndexedDBDatabaseConstructor(
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 =
@ -199,7 +199,7 @@ IndexedDBParent::RecvPIndexedDBDeleteDatabaseRequestConstructor(
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);

View File

@ -10,7 +10,6 @@ XPIDL_SOURCES += [
'nsIIDBCursor.idl',
'nsIIDBCursorWithValue.idl',
'nsIIDBDatabase.idl',
'nsIIDBFactory.idl',
'nsIIDBFileHandle.idl',
'nsIIDBIndex.idl',
'nsIIDBKeyRange.idl',

View File

@ -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);
};

View File

@ -72,6 +72,7 @@ MOCHITEST_FILES = \
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 \

View File

@ -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>

View File

@ -36,6 +36,7 @@ MOCHITEST_FILES = \
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 \

View File

@ -11,7 +11,6 @@ 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

View File

@ -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;
}

View File

@ -29,6 +29,7 @@ tail =
[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]

View File

@ -13,14 +13,12 @@
* 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;
};

View File

@ -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);
};

View File

@ -135,6 +135,7 @@ webidl_files = \
HTMLTitleElement.webidl \
HTMLUListElement.webidl \
HTMLVideoElement.webidl \
IDBFactory.webidl \
IDBVersionChangeEvent.webidl \
ImageData.webidl \
InspectorUtils.webidl \

View File

@ -206,7 +206,6 @@ members = [
'nsIIDBCursor.*',
'nsIIDBCursorWithValue.*',
'nsIIDBDatabase.*',
'nsIIDBFactory.*',
'nsIIDBFileHandle.*',
'nsIIDBIndex.*',
'nsIIDBKeyRange.*',