Bug 1135627 - Add implementation of DragEvent constructor. r=jdm r=smaug

This commit is contained in:
Timur Valeev 2015-03-04 17:52:03 +03:00
parent 4da8d623df
commit f3a3ed962d
6 changed files with 46 additions and 42 deletions

View File

@ -131,6 +131,26 @@ DragEvent::GetDataTransfer()
return dragEvent->dataTransfer;
}
// static
already_AddRefed<DragEvent>
DragEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const DragEventInit& aParam,
ErrorResult& aRv)
{
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<DragEvent> e = new DragEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitDragEvent(aType, aParam.mBubbles, aParam.mCancelable,
aParam.mView, aParam.mDetail, aParam.mScreenX,
aParam.mScreenY, aParam.mClientX, aParam.mClientY,
aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey,
aParam.mMetaKey, aParam.mButton, aParam.mRelatedTarget,
aParam.mDataTransfer);
e->SetTrusted(trusted);
return e.forget();
}
} // namespace dom
} // namespace mozilla

View File

@ -48,6 +48,11 @@ public:
DataTransfer* aDataTransfer,
ErrorResult& aError);
static already_AddRefed<DragEvent> Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const DragEventInit& aParam,
ErrorResult& aRv);
protected:
~DragEvent() {}
};

View File

@ -824,6 +824,21 @@ while (testWheelProps.length) {
}
}
// DragEvent
try {
e = new DragEvent();
} catch(exp) {
ex = true;
}
ok(ex, "DragEvent: First parameter is required!");
ex = false;
e = new DragEvent("hello");
is(e.type, "hello", "DragEvent: Wrong event type!");
document.dispatchEvent(e);
is(receivedEvent, e, "DragEvent: Wrong event!");
// TransitionEvent
e = new TransitionEvent("hello", { propertyName: "color", elapsedTime: 3.5, pseudoElement: "", foobar: "baz" })
is("propertyName" in e, true, "Transition events have propertyName property");

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type, optional DragEventInit eventInitDict)]
interface DragEvent : MouseEvent
{
readonly attribute DataTransfer? dataTransfer;
@ -26,3 +27,8 @@ interface DragEvent : MouseEvent
EventTarget? aRelatedTarget,
DataTransfer? aDataTransfer);
};
dictionary DragEventInit : MouseEventInit
{
DataTransfer? dataTransfer = null;
};

View File

@ -2220,9 +2220,6 @@
[DataTransferItem interface: operation getAsFile()]
expected: FAIL
[DragEvent interface object length]
expected: FAIL
[Window interface: existence and properties of interface prototype object]
expected: FAIL

View File

@ -6,42 +6,3 @@
[DragEvent should have all of the inherited init*Event methods]
expected: FAIL
[initMouseEvent should not throw]
expected: FAIL
[initUIEvent should not throw]
expected: FAIL
[initEvent should not throw]
expected: FAIL
[DragEvent constructor with null as the dataTransfer parameter should be able to fire the event]
expected: FAIL
[DragEvent constructor with undefined as the dataTransfer parameter should be able to fire the event]
expected: FAIL
[initMouseEvent should be able to fire the event]
expected: FAIL
[initUIEvent should be able to fire the event]
expected: FAIL
[initEvent should be able to fire the event]
expected: FAIL
[DragEvent constructor with null as the dataTransfer parameter should give null as the dataTransfer]
expected: FAIL
[DragEvent constructor with undefined as the dataTransfer parameter should give null as the dataTransfer]
expected: FAIL
[initMouseEvent should give null as the dataTransfer]
expected: FAIL
[initUIEvent should give null as the dataTransfer]
expected: FAIL
[initEvent should give null as the dataTransfer]
expected: FAIL