зеркало из https://github.com/mozilla/gecko-dev.git
Bug 890382 - Implement a Web IDL event constructor for IDBVersionChangeEvent; r=smaug
This commit is contained in:
Родитель
35e2448a4e
Коммит
fd1d2f2354
|
@ -57,7 +57,7 @@ mozilla::dom::indexedDB::CreateGenericEvent(mozilla::dom::EventTarget* aOwner,
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
already_AddRefed<nsDOMEvent>
|
already_AddRefed<IDBVersionChangeEvent>
|
||||||
IDBVersionChangeEvent::CreateInternal(mozilla::dom::EventTarget* aOwner,
|
IDBVersionChangeEvent::CreateInternal(mozilla::dom::EventTarget* aOwner,
|
||||||
const nsAString& aType,
|
const nsAString& aType,
|
||||||
uint64_t aOldVersion,
|
uint64_t aOldVersion,
|
||||||
|
|
|
@ -57,6 +57,20 @@ public:
|
||||||
return mozilla::dom::IDBVersionChangeEventBinding::Wrap(aCx, aScope, this);
|
return mozilla::dom::IDBVersionChangeEventBinding::Wrap(aCx, aScope, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static already_AddRefed<IDBVersionChangeEvent>
|
||||||
|
Constructor(const GlobalObject& aGlobal,
|
||||||
|
const NonNull<nsAString>& aType,
|
||||||
|
const IDBVersionChangeEventInit& aOptions,
|
||||||
|
ErrorResult& aRv)
|
||||||
|
{
|
||||||
|
uint64_t newVersion = 0;
|
||||||
|
if (!aOptions.mNewVersion.IsNull()) {
|
||||||
|
newVersion = aOptions.mNewVersion.Value();
|
||||||
|
}
|
||||||
|
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.Get());
|
||||||
|
return CreateInternal(target, aType, aOptions.mOldVersion, newVersion);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t OldVersion()
|
uint64_t OldVersion()
|
||||||
{
|
{
|
||||||
return mOldVersion;
|
return mOldVersion;
|
||||||
|
@ -126,7 +140,7 @@ protected:
|
||||||
}
|
}
|
||||||
virtual ~IDBVersionChangeEvent() { }
|
virtual ~IDBVersionChangeEvent() { }
|
||||||
|
|
||||||
static already_AddRefed<nsDOMEvent>
|
static already_AddRefed<IDBVersionChangeEvent>
|
||||||
CreateInternal(mozilla::dom::EventTarget* aOwner,
|
CreateInternal(mozilla::dom::EventTarget* aOwner,
|
||||||
const nsAString& aType,
|
const nsAString& aType,
|
||||||
uint64_t aOldVersion,
|
uint64_t aOldVersion,
|
||||||
|
|
|
@ -9,7 +9,6 @@ const DOMException = Ci.nsIDOMDOMException;
|
||||||
const IDBCursor = Ci.nsIIDBCursor;
|
const IDBCursor = Ci.nsIIDBCursor;
|
||||||
const IDBTransaction = Ci.nsIIDBTransaction;
|
const IDBTransaction = Ci.nsIIDBTransaction;
|
||||||
const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
|
const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
|
||||||
const IDBVersionChangeEvent = Ci.nsIIDBVersionChangeEvent
|
|
||||||
const IDBDatabase = Ci.nsIIDBDatabase
|
const IDBDatabase = Ci.nsIIDBDatabase
|
||||||
const IDBIndex = Ci.nsIIDBIndex
|
const IDBIndex = Ci.nsIIDBIndex
|
||||||
const IDBObjectStore = Ci.nsIIDBObjectStore
|
const IDBObjectStore = Ci.nsIIDBObjectStore
|
||||||
|
|
|
@ -157,6 +157,21 @@ function testSteps()
|
||||||
|
|
||||||
is(versionChangeEventCount, 3, "Saw all expected events");
|
is(versionChangeEventCount, 3, "Saw all expected events");
|
||||||
|
|
||||||
|
event = new IDBVersionChangeEvent("versionchange");
|
||||||
|
ok(event, "Should be able to create an event with just passing in the type");
|
||||||
|
event = new IDBVersionChangeEvent("versionchange", {oldVersion: 1});
|
||||||
|
ok(event, "Should be able to create an event with just the old version");
|
||||||
|
is(event.oldVersion, 1, "Correct old version");
|
||||||
|
is(event.newVersion, null, "Correct new version");
|
||||||
|
event = new IDBVersionChangeEvent("versionchange", {newVersion: 1});
|
||||||
|
ok(event, "Should be able to create an event with just the new version");
|
||||||
|
is(event.oldVersion, 0, "Correct old version");
|
||||||
|
is(event.newVersion, 1, "Correct new version");
|
||||||
|
event = new IDBVersionChangeEvent("versionchange", {oldVersion: 1, newVersion: 2});
|
||||||
|
ok(event, "Should be able to create an event with both versions");
|
||||||
|
is(event.oldVersion, 1, "Correct old version");
|
||||||
|
is(event.newVersion, 2, "Correct new version");
|
||||||
|
|
||||||
finishTest();
|
finishTest();
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,21 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* 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/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*
|
*
|
||||||
* IDBVersionChangeEvent is defined in:
|
* The origin of this IDL file is
|
||||||
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html
|
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBVersionChangeEvent
|
||||||
*
|
*
|
||||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||||
* liability, trademark and document use rules apply.
|
* liability, trademark and document use rules apply.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface IDBVersionChangeEvent : Event {
|
dictionary IDBVersionChangeEventInit : EventInit {
|
||||||
readonly attribute unsigned long long oldVersion;
|
unsigned long long oldVersion = 0;
|
||||||
readonly attribute unsigned long long? newVersion;
|
unsigned long long? newVersion = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[Constructor(DOMString type, optional IDBVersionChangeEventInit eventInitDict)]
|
||||||
|
interface IDBVersionChangeEvent : Event {
|
||||||
|
readonly attribute unsigned long long oldVersion;
|
||||||
|
readonly attribute unsigned long long? newVersion;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "XPCQuickStubs.h"
|
#include "XPCQuickStubs.h"
|
||||||
|
|
||||||
#include "mozilla/dom/BindingUtils.h"
|
#include "mozilla/dom/BindingUtils.h"
|
||||||
|
#include "mozilla/dom/IDBVersionChangeEventBinding.h"
|
||||||
#include "mozilla/dom/TextDecoderBinding.h"
|
#include "mozilla/dom/TextDecoderBinding.h"
|
||||||
#include "mozilla/dom/TextEncoderBinding.h"
|
#include "mozilla/dom/TextEncoderBinding.h"
|
||||||
#include "mozilla/dom/DOMErrorBinding.h"
|
#include "mozilla/dom/DOMErrorBinding.h"
|
||||||
|
@ -480,7 +481,8 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
|
||||||
MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
|
MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
|
||||||
|
|
||||||
// Init WebIDL binding constructors wanted on all XPConnect globals.
|
// Init WebIDL binding constructors wanted on all XPConnect globals.
|
||||||
if (!TextDecoderBinding::GetConstructorObject(aJSContext, global) ||
|
if (!IDBVersionChangeEventBinding::GetConstructorObject(aJSContext, global) ||
|
||||||
|
!TextDecoderBinding::GetConstructorObject(aJSContext, global) ||
|
||||||
!TextEncoderBinding::GetConstructorObject(aJSContext, global) ||
|
!TextEncoderBinding::GetConstructorObject(aJSContext, global) ||
|
||||||
!DOMErrorBinding::GetConstructorObject(aJSContext, global)) {
|
!DOMErrorBinding::GetConstructorObject(aJSContext, global)) {
|
||||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче