зеркало из https://github.com/mozilla/pjs.git
Bug 708701 - Implement HTML event ctors, r=jst
--HG-- extra : rebase_source : 4abb0185ea790c29ff7f2df0f032045777c898e0
This commit is contained in:
Родитель
4cd5f60af7
Коммит
a50f3c2e8d
|
@ -146,4 +146,8 @@ nsresult
|
||||||
NS_NewDOMCustomEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
|
NS_NewDOMCustomEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewDOMSmsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
|
NS_NewDOMSmsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
|
||||||
|
nsresult
|
||||||
|
NS_NewDOMPopStateEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
|
||||||
|
nsresult
|
||||||
|
NS_NewDOMHashChangeEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
|
||||||
#endif // nsIPrivateDOMEvent_h__
|
#endif // nsIPrivateDOMEvent_h__
|
||||||
|
|
|
@ -88,6 +88,34 @@ nsDOMCloseEvent::InitCloseEvent(const nsAString& aType,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsDOMCloseEvent::InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsICloseEventInit> eventInit = do_QueryInterface(aDict);
|
||||||
|
bool bubbles = false;
|
||||||
|
bool cancelable = false;
|
||||||
|
bool wasClean = false;
|
||||||
|
PRUint16 code = 0;
|
||||||
|
nsAutoString reason;
|
||||||
|
if (eventInit) {
|
||||||
|
nsresult rv = eventInit->GetBubbles(&bubbles);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = eventInit->GetCancelable(&cancelable);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = eventInit->GetWasClean(&wasClean);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = eventInit->GetCode(&code);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
JSBool found = JS_FALSE;
|
||||||
|
if (JS_HasProperty(aCx, aObj, "reason", &found) && found) {
|
||||||
|
rv = eventInit->GetReason(reason);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return InitCloseEvent(aType, bubbles, cancelable, wasClean, code, reason);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewDOMCloseEvent(nsIDOMEvent** aInstancePtrResult,
|
NS_NewDOMCloseEvent(nsIDOMEvent** aInstancePtrResult,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
|
|
|
@ -64,6 +64,9 @@ public:
|
||||||
|
|
||||||
NS_DECL_NSIDOMCLOSEEVENT
|
NS_DECL_NSIDOMCLOSEEVENT
|
||||||
|
|
||||||
|
virtual const nsIID& EventInitIID() { return NS_GET_IID(nsICloseEventInit); }
|
||||||
|
virtual nsresult InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj);
|
||||||
private:
|
private:
|
||||||
bool mWasClean;
|
bool mWasClean;
|
||||||
PRUint16 mReasonCode;
|
PRUint16 mReasonCode;
|
||||||
|
|
|
@ -79,7 +79,8 @@ nsDOMCustomEvent::InitCustomEvent(const nsAString& aType,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDOMCustomEvent::InitFromCtor(const nsAString& aType, nsISupports* aDict)
|
nsDOMCustomEvent::InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsICustomEventInit> eventInit = do_QueryInterface(aDict);
|
nsCOMPtr<nsICustomEventInit> eventInit = do_QueryInterface(aDict);
|
||||||
bool bubbles = false;
|
bool bubbles = false;
|
||||||
|
|
|
@ -60,7 +60,8 @@ public:
|
||||||
NS_FORWARD_TO_NSDOMEVENT
|
NS_FORWARD_TO_NSDOMEVENT
|
||||||
|
|
||||||
virtual const nsIID& EventInitIID() { return NS_GET_IID(nsICustomEventInit); }
|
virtual const nsIID& EventInitIID() { return NS_GET_IID(nsICustomEventInit); }
|
||||||
virtual nsresult InitFromCtor(const nsAString& aType, nsISupports* aDict);
|
virtual nsresult InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj);
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsIVariant> mDetail;
|
nsCOMPtr<nsIVariant> mDetail;
|
||||||
};
|
};
|
||||||
|
|
|
@ -411,12 +411,14 @@ nsDOMEvent::Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj,
|
||||||
NS_ENSURE_STATE(type.init(aCx, jsstr));
|
NS_ENSURE_STATE(type.init(aCx, jsstr));
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> dict;
|
nsCOMPtr<nsISupports> dict;
|
||||||
|
JSObject* obj = nsnull;
|
||||||
if (aArgc >= 2 && !JSVAL_IS_PRIMITIVE(aArgv[1])) {
|
if (aArgc >= 2 && !JSVAL_IS_PRIMITIVE(aArgv[1])) {
|
||||||
nsContentUtils::XPConnect()->WrapJS(aCx, JSVAL_TO_OBJECT(aArgv[1]),
|
obj = JSVAL_TO_OBJECT(aArgv[1]);
|
||||||
|
nsContentUtils::XPConnect()->WrapJS(aCx, obj,
|
||||||
EventInitIID(),
|
EventInitIID(),
|
||||||
getter_AddRefs(dict));
|
getter_AddRefs(dict));
|
||||||
}
|
}
|
||||||
nsresult rv = InitFromCtor(type, dict);
|
nsresult rv = InitFromCtor(type, dict, aCx, obj);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
SetTrusted(trusted);
|
SetTrusted(trusted);
|
||||||
|
@ -424,7 +426,8 @@ nsDOMEvent::Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDOMEvent::InitFromCtor(const nsAString& aType, nsISupports* aDict)
|
nsDOMEvent::InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIEventInit> eventInit = do_QueryInterface(aDict);
|
nsCOMPtr<nsIEventInit> eventInit = do_QueryInterface(aDict);
|
||||||
bool bubbles = false;
|
bool bubbles = false;
|
||||||
|
|
|
@ -53,6 +53,8 @@
|
||||||
|
|
||||||
class nsIContent;
|
class nsIContent;
|
||||||
class nsPresContext;
|
class nsPresContext;
|
||||||
|
class JSContext;
|
||||||
|
class JSObject;
|
||||||
|
|
||||||
class nsDOMEvent : public nsIDOMEvent,
|
class nsDOMEvent : public nsIDOMEvent,
|
||||||
public nsIDOMNSEvent,
|
public nsIDOMNSEvent,
|
||||||
|
@ -226,7 +228,8 @@ public:
|
||||||
PRUint32 aArgc, jsval* aArgv);
|
PRUint32 aArgc, jsval* aArgv);
|
||||||
|
|
||||||
virtual const nsIID& EventInitIID() { return NS_GET_IID(nsIEventInit); }
|
virtual const nsIID& EventInitIID() { return NS_GET_IID(nsIEventInit); }
|
||||||
virtual nsresult InitFromCtor(const nsAString& aType, nsISupports* aDict);
|
virtual nsresult InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj);
|
||||||
|
|
||||||
void InitPresContextData(nsPresContext* aPresContext);
|
void InitPresContextData(nsPresContext* aPresContext);
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,34 @@ nsDOMHashChangeEvent::InitHashChangeEvent(const nsAString &aTypeArg,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsDOMHashChangeEvent::InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIHashChangeEventInit> eventInit = do_QueryInterface(aDict);
|
||||||
|
bool bubbles = false;
|
||||||
|
bool cancelable = false;
|
||||||
|
nsAutoString oldURL;
|
||||||
|
nsAutoString newURL;
|
||||||
|
if (eventInit) {
|
||||||
|
nsresult rv = eventInit->GetBubbles(&bubbles);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = eventInit->GetCancelable(&cancelable);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
JSBool found = JS_FALSE;
|
||||||
|
if (JS_HasProperty(aCx, aObj, "oldURL", &found) && found) {
|
||||||
|
rv = eventInit->GetOldURL(oldURL);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
|
found = JS_FALSE;
|
||||||
|
if (JS_HasProperty(aCx, aObj, "newURL", &found) && found) {
|
||||||
|
rv = eventInit->GetNewURL(newURL);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return InitHashChangeEvent(aType, bubbles, cancelable, oldURL, newURL);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult NS_NewDOMHashChangeEvent(nsIDOMEvent** aInstancePtrResult,
|
nsresult NS_NewDOMHashChangeEvent(nsIDOMEvent** aInstancePtrResult,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
nsEvent* aEvent)
|
nsEvent* aEvent)
|
||||||
|
|
|
@ -58,13 +58,12 @@ public:
|
||||||
|
|
||||||
NS_FORWARD_TO_NSDOMEVENT
|
NS_FORWARD_TO_NSDOMEVENT
|
||||||
|
|
||||||
|
virtual const nsIID& EventInitIID() { return NS_GET_IID(nsIHashChangeEventInit); }
|
||||||
|
virtual nsresult InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj);
|
||||||
protected:
|
protected:
|
||||||
nsString mOldURL;
|
nsString mOldURL;
|
||||||
nsString mNewURL;
|
nsString mNewURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult NS_NewDOMHashChangeEvent(nsIDOMEvent** aInstancePtrResult,
|
|
||||||
nsPresContext* aPresContext,
|
|
||||||
nsEvent* aEvent);
|
|
||||||
|
|
||||||
#endif // nsDOMHashChangeEvent_h__
|
#endif // nsDOMHashChangeEvent_h__
|
||||||
|
|
|
@ -69,6 +69,25 @@ nsDOMPageTransitionEvent::InitPageTransitionEvent(const nsAString &aTypeArg,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsDOMPageTransitionEvent::InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIPageTransitionEventInit> eventInit = do_QueryInterface(aDict);
|
||||||
|
bool bubbles = false;
|
||||||
|
bool cancelable = false;
|
||||||
|
bool persisted = false;
|
||||||
|
if (eventInit) {
|
||||||
|
nsresult rv = eventInit->GetBubbles(&bubbles);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = eventInit->GetCancelable(&cancelable);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = eventInit->GetPersisted(&persisted);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
|
return InitPageTransitionEvent(aType, bubbles, cancelable, persisted);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult NS_NewDOMPageTransitionEvent(nsIDOMEvent** aInstancePtrResult,
|
nsresult NS_NewDOMPageTransitionEvent(nsIDOMEvent** aInstancePtrResult,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
nsEvent *aEvent)
|
nsEvent *aEvent)
|
||||||
|
|
|
@ -55,6 +55,10 @@ public:
|
||||||
|
|
||||||
// Forward to base class
|
// Forward to base class
|
||||||
NS_FORWARD_TO_NSDOMEVENT
|
NS_FORWARD_TO_NSDOMEVENT
|
||||||
|
|
||||||
|
virtual const nsIID& EventInitIID() { return NS_GET_IID(nsIPageTransitionEventInit); }
|
||||||
|
virtual nsresult InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj);
|
||||||
protected:
|
protected:
|
||||||
bool mPersisted;
|
bool mPersisted;
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,6 +83,25 @@ nsDOMPopStateEvent::InitPopStateEvent(const nsAString &aTypeArg,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsDOMPopStateEvent::InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIPopStateEventInit> eventInit = do_QueryInterface(aDict);
|
||||||
|
bool bubbles = false;
|
||||||
|
bool cancelable = false;
|
||||||
|
nsCOMPtr<nsIVariant> state;
|
||||||
|
if (eventInit) {
|
||||||
|
nsresult rv = eventInit->GetBubbles(&bubbles);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = eventInit->GetCancelable(&cancelable);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = eventInit->GetState(getter_AddRefs(state));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
|
return InitPopStateEvent(aType, bubbles, cancelable, state);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult NS_NewDOMPopStateEvent(nsIDOMEvent** aInstancePtrResult,
|
nsresult NS_NewDOMPopStateEvent(nsIDOMEvent** aInstancePtrResult,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
nsEvent* aEvent)
|
nsEvent* aEvent)
|
||||||
|
|
|
@ -60,12 +60,11 @@ public:
|
||||||
|
|
||||||
NS_FORWARD_TO_NSDOMEVENT
|
NS_FORWARD_TO_NSDOMEVENT
|
||||||
|
|
||||||
|
virtual const nsIID& EventInitIID() { return NS_GET_IID(nsIPopStateEventInit); }
|
||||||
|
virtual nsresult InitFromCtor(const nsAString& aType, nsISupports* aDict,
|
||||||
|
JSContext* aCx, JSObject* aObj);
|
||||||
protected:
|
protected:
|
||||||
nsCOMPtr<nsIVariant> mState;
|
nsCOMPtr<nsIVariant> mState;
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult NS_NewDOMPopStateEvent(nsIDOMEvent** aInstancePtrResult,
|
|
||||||
nsPresContext* aPresContext,
|
|
||||||
nsEvent* aEvent);
|
|
||||||
|
|
||||||
#endif // nsDOMPopStateEvent_h__
|
#endif // nsDOMPopStateEvent_h__
|
||||||
|
|
|
@ -109,6 +109,172 @@ try {
|
||||||
ok(ex, "Should have thrown an exception!");
|
ok(ex, "Should have thrown an exception!");
|
||||||
ex = false;
|
ex = false;
|
||||||
|
|
||||||
|
// CloseEvent
|
||||||
|
|
||||||
|
try {
|
||||||
|
e = new CloseEvent();
|
||||||
|
} catch(exp) {
|
||||||
|
ex = true;
|
||||||
|
}
|
||||||
|
ok(ex, "First parameter is required!");
|
||||||
|
ex = false;
|
||||||
|
|
||||||
|
e = new CloseEvent("hello");
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(!e.bubbles, "Event shouldn't bubble!");
|
||||||
|
ok(!e.cancelable, "Event shouldn't be cancelable!");
|
||||||
|
is(e.wasClean, false, "wasClean should be false!");
|
||||||
|
is(e.code, 0, "code should be 0!");
|
||||||
|
is(e.reason, "", "reason should be ''!");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
e = new CloseEvent("hello",
|
||||||
|
{ bubbles: true, cancelable: true, wasClean: true, code: 1, reason: "foo" });
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(e.bubbles, "Event should bubble!");
|
||||||
|
ok(e.cancelable, "Event should be cancelable!");
|
||||||
|
is(e.wasClean, true, "wasClean should be true!");
|
||||||
|
is(e.code, 1, "code should be 1!");
|
||||||
|
is(e.reason, "foo", "reason should be 'foo'!");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
e = new CloseEvent("hello",
|
||||||
|
{ bubbles: true, cancelable: true, wasClean: true, code: 1 });
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(e.bubbles, "Event should bubble!");
|
||||||
|
ok(e.cancelable, "Event should be cancelable!");
|
||||||
|
is(e.wasClean, true, "wasClean should be true!");
|
||||||
|
is(e.code, 1, "code should be 1!");
|
||||||
|
is(e.reason, "", "reason should be ''!");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
|
||||||
|
// HashChangeEvent
|
||||||
|
|
||||||
|
try {
|
||||||
|
e = new HashChangeEvent();
|
||||||
|
} catch(exp) {
|
||||||
|
ex = true;
|
||||||
|
}
|
||||||
|
ok(ex, "First parameter is required!");
|
||||||
|
ex = false;
|
||||||
|
|
||||||
|
e = new HashChangeEvent("hello");
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(!e.bubbles, "Event shouldn't bubble!");
|
||||||
|
ok(!e.cancelable, "Event shouldn't be cancelable!");
|
||||||
|
is(e.oldURL, "", "oldURL should be ''");
|
||||||
|
is(e.newURL, "", "newURL should be ''");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
e = new HashChangeEvent("hello",
|
||||||
|
{ bubbles: true, cancelable: true, oldURL: "old", newURL: "new" });
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(e.bubbles, "Event should bubble!");
|
||||||
|
ok(e.cancelable, "Event should be cancelable!");
|
||||||
|
is(e.oldURL, "old", "oldURL should be 'old'");
|
||||||
|
is(e.newURL, "new", "newURL should be 'new'");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
e = new HashChangeEvent("hello",
|
||||||
|
{ bubbles: true, cancelable: true, newURL: "new" });
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(e.bubbles, "Event should bubble!");
|
||||||
|
ok(e.cancelable, "Event should be cancelable!");
|
||||||
|
is(e.oldURL, "", "oldURL should be ''");
|
||||||
|
is(e.newURL, "new", "newURL should be 'new'");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
// PageTransitionEvent
|
||||||
|
|
||||||
|
try {
|
||||||
|
e = new PageTransitionEvent();
|
||||||
|
} catch(exp) {
|
||||||
|
ex = true;
|
||||||
|
}
|
||||||
|
ok(ex, "First parameter is required!");
|
||||||
|
ex = false;
|
||||||
|
|
||||||
|
e = new PageTransitionEvent("hello");
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(!e.bubbles, "Event shouldn't bubble!");
|
||||||
|
ok(!e.cancelable, "Event shouldn't be cancelable!");
|
||||||
|
is(e.persisted, false, "persisted should be false");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
e = new PageTransitionEvent("hello",
|
||||||
|
{ bubbles: true, cancelable: true, persisted: true});
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(e.bubbles, "Event should bubble!");
|
||||||
|
ok(e.cancelable, "Event should be cancelable!");
|
||||||
|
is(e.persisted, true, "persisted should be true");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
e = new PageTransitionEvent("hello", { persisted: true});
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(!e.bubbles, "Event shouldn't bubble!");
|
||||||
|
ok(!e.cancelable, "Event shouldn't be cancelable!");
|
||||||
|
is(e.persisted, true, "persisted should be true");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
// PopStateEvent
|
||||||
|
|
||||||
|
try {
|
||||||
|
e = new PopStateEvent();
|
||||||
|
} catch(exp) {
|
||||||
|
ex = true;
|
||||||
|
}
|
||||||
|
ok(ex, "First parameter is required!");
|
||||||
|
ex = false;
|
||||||
|
|
||||||
|
e = new PopStateEvent("hello");
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(!e.bubbles, "Event shouldn't bubble!");
|
||||||
|
ok(!e.cancelable, "Event shouldn't be cancelable!");
|
||||||
|
is(e.state, null, "persisted should be null");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
e = new PopStateEvent("hello",
|
||||||
|
{ bubbles: true, cancelable: true, state: window});
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(e.bubbles, "Event should bubble!");
|
||||||
|
ok(e.cancelable, "Event should be cancelable!");
|
||||||
|
is(e.state, window, "persisted should be window");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
|
||||||
|
e = new PopStateEvent("hello", { state: window});
|
||||||
|
ok(e.type, "hello", "Wrong event type!");
|
||||||
|
ok(!e.isTrusted, "Event shouldn't be trusted!");
|
||||||
|
ok(!e.bubbles, "Event shouldn't bubble!");
|
||||||
|
ok(!e.cancelable, "Event shouldn't be cancelable!");
|
||||||
|
is(e.state, window, "persisted should be window");
|
||||||
|
document.dispatchEvent(e);
|
||||||
|
is(receivedEvent, e, "Wrong event!");
|
||||||
|
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1587,6 +1587,10 @@ static const nsContractIDMapData kConstructorMap[] =
|
||||||
|
|
||||||
NS_DEFINE_EVENT_CTOR(Event)
|
NS_DEFINE_EVENT_CTOR(Event)
|
||||||
NS_DEFINE_EVENT_CTOR(CustomEvent)
|
NS_DEFINE_EVENT_CTOR(CustomEvent)
|
||||||
|
NS_DEFINE_EVENT_CTOR(PopStateEvent)
|
||||||
|
NS_DEFINE_EVENT_CTOR(HashChangeEvent)
|
||||||
|
NS_DEFINE_EVENT_CTOR(PageTransitionEvent)
|
||||||
|
NS_DEFINE_EVENT_CTOR(CloseEvent)
|
||||||
|
|
||||||
struct nsConstructorFuncMapData
|
struct nsConstructorFuncMapData
|
||||||
{
|
{
|
||||||
|
@ -1606,6 +1610,10 @@ static const nsConstructorFuncMapData kConstructorFuncMap[] =
|
||||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozBlobBuilder, NS_NewBlobBuilder)
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozBlobBuilder, NS_NewBlobBuilder)
|
||||||
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(Event)
|
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(Event)
|
||||||
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CustomEvent)
|
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CustomEvent)
|
||||||
|
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PopStateEvent)
|
||||||
|
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(HashChangeEvent)
|
||||||
|
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PageTransitionEvent)
|
||||||
|
NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CloseEvent)
|
||||||
};
|
};
|
||||||
|
|
||||||
nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
|
nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
|
||||||
|
|
|
@ -59,3 +59,11 @@ interface nsIDOMCloseEvent : nsIDOMEvent
|
||||||
in unsigned short aReasonCode,
|
in unsigned short aReasonCode,
|
||||||
in DOMString aReason);
|
in DOMString aReason);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[scriptable, uuid(148ed08e-14f1-4be5-b2f8-23f765738379)]
|
||||||
|
interface nsICloseEventInit : nsIEventInit
|
||||||
|
{
|
||||||
|
attribute boolean wasClean;
|
||||||
|
attribute unsigned short code;
|
||||||
|
attribute DOMString reason;
|
||||||
|
};
|
||||||
|
|
|
@ -46,3 +46,10 @@ interface nsIDOMHashChangeEvent : nsIDOMEvent
|
||||||
in DOMString oldURLArg,
|
in DOMString oldURLArg,
|
||||||
in DOMString newURLArg);
|
in DOMString newURLArg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[scriptable, uuid(e56881c1-3714-45bb-bca3-1453ea24ee90)]
|
||||||
|
interface nsIHashChangeEventInit : nsIEventInit
|
||||||
|
{
|
||||||
|
attribute DOMString oldURL;
|
||||||
|
attribute DOMString newURL;
|
||||||
|
};
|
||||||
|
|
|
@ -60,3 +60,9 @@ interface nsIDOMPageTransitionEvent : nsIDOMEvent
|
||||||
in boolean canCancelArg,
|
in boolean canCancelArg,
|
||||||
in boolean persisted);
|
in boolean persisted);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[scriptable, uuid(bf3eaa61-5048-48c4-b8b9-9bf833ca63d6)]
|
||||||
|
interface nsIPageTransitionEventInit : nsIEventInit
|
||||||
|
{
|
||||||
|
attribute boolean persisted;
|
||||||
|
};
|
||||||
|
|
|
@ -49,3 +49,9 @@ interface nsIDOMPopStateEvent : nsIDOMEvent
|
||||||
in boolean cancelableArg,
|
in boolean cancelableArg,
|
||||||
in nsIVariant stateArg);
|
in nsIVariant stateArg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[scriptable, uuid(2300bd68-f6e0-4c58-a1aa-45f94cdabfbd)]
|
||||||
|
interface nsIPopStateEventInit : nsIEventInit
|
||||||
|
{
|
||||||
|
attribute nsIVariant state;
|
||||||
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче