зеркало из https://github.com/mozilla/gecko-dev.git
Bug 656954 - Add defaultPrevented to nsIDOMEvent, r=sicking
--HG-- extra : rebase_source : f491aa3d1b40980ca0f6b8cc38a5e9e60d80b9e7
This commit is contained in:
Родитель
9d24f296ab
Коммит
eccbe478ef
|
@ -1390,6 +1390,12 @@ nsDOMEvent::GetPreventDefault(PRBool* aReturn)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetDefaultPrevented(PRBool* aReturn)
|
||||
{
|
||||
return GetPreventDefault(aReturn);
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMEvent::Serialize(IPC::Message* aMsg, PRBool aSerializeInterfaceType)
|
||||
{
|
||||
|
|
|
@ -105,6 +105,7 @@ _TEST_FILES = \
|
|||
test_bug641477.html \
|
||||
test_bug648573.html \
|
||||
test_bug615597.html \
|
||||
test_bug656954.html \
|
||||
$(NULL)
|
||||
|
||||
#bug 585630
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=656954
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 656954</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=656954">Mozilla Bug 656954</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 656954 **/
|
||||
|
||||
var e = document.createEvent("Event");
|
||||
is(e.defaultPrevented, false,
|
||||
"After creating event defaultPrevented should be true");
|
||||
e.initEvent("foo", true, true);
|
||||
var el = document.createElement("div");
|
||||
el.addEventListener("foo",
|
||||
function(evt) {
|
||||
evt.preventDefault();
|
||||
}, false);
|
||||
el.dispatchEvent(e);
|
||||
is(e.defaultPrevented, true, "preventDefault() should have been called!");
|
||||
|
||||
e = document.createEvent("Event");
|
||||
e.initEvent("foo", true, false);
|
||||
el.dispatchEvent(e);
|
||||
is(e.defaultPrevented, false, "preventDefault() should not have any effect!");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -49,7 +49,7 @@ interface nsIDOMEventTarget;
|
|||
* http://www.w3.org/TR/DOM-Level-2-Events/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(a66b7b80-ff46-bd97-0080-5f8ae38add32)]
|
||||
[scriptable, uuid(548137e8-fd2c-48c4-8635-3033f7db79e0)]
|
||||
interface nsIDOMEvent : nsISupports
|
||||
{
|
||||
// PhaseType
|
||||
|
@ -169,4 +169,9 @@ interface nsIDOMEvent : nsISupports
|
|||
void initEvent(in DOMString eventTypeArg,
|
||||
in boolean canBubbleArg,
|
||||
in boolean cancelableArg);
|
||||
|
||||
/**
|
||||
* Used to indicate whether preventDefault() has been called for this event.
|
||||
*/
|
||||
readonly attribute boolean defaultPrevented;
|
||||
};
|
||||
|
|
|
@ -105,6 +105,13 @@ nsDOMWorkerPrivateEvent::PreventDefault()
|
|||
return mEvent->PreventDefault();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWorkerPrivateEvent::GetDefaultPrevented(PRBool* aRetVal)
|
||||
{
|
||||
*aRetVal = mPreventDefaultCalled;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWorkerPrivateEvent::InitEvent(const nsAString& aEventType,
|
||||
PRBool aCanBubble,
|
||||
|
@ -242,6 +249,13 @@ nsDOMWorkerEvent::PreventDefault()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWorkerEvent::GetDefaultPrevented(PRBool* aRetVal)
|
||||
{
|
||||
*aRetVal = mPreventDefaultCalled;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWorkerEvent::InitEvent(const nsAString& aEventTypeArg,
|
||||
PRBool aCanBubbleArg,
|
||||
|
|
|
@ -160,6 +160,8 @@ public:
|
|||
const nsAString& aFilenameArg,
|
||||
PRUint32 aLinenoArg);
|
||||
|
||||
NS_IMETHOD GetDefaultPrevented(PRBool* aRetVal);
|
||||
|
||||
virtual PRBool PreventDefaultCalled();
|
||||
|
||||
private:
|
||||
|
|
|
@ -238,6 +238,12 @@ NS_IMETHODIMP nsSmartCardEvent::PreventDefault()
|
|||
return mInner->PreventDefault();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSmartCardEvent::GetDefaultPrevented(PRBool* aReturn)
|
||||
{
|
||||
NS_ASSERTION(mInner, "SmartCardEvent called without Init");
|
||||
return mInner->GetDefaultPrevented(aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSmartCardEvent::InitEvent(const nsAString & eventTypeArg, PRBool canBubbleArg, PRBool cancelableArg)
|
||||
{
|
||||
NS_ASSERTION(mInner, "SmartCardEvent called without Init");
|
||||
|
|
Загрузка…
Ссылка в новой задаче