Bug 1251198 - Remove various obsolete events from document.createEvent r=smaug

Other browsers do not support any of these (IIRC), telemetry reports
essentially zero usage, and supporting them is contrary to the DOM spec.

Notes on specific events:

CommandEvent and SimpleGestureEvent: These are not supposed to be
web-exposed APIs, so I hid the interfaces from web content too
(necessary to avoid test_all_synthetic_events.html failures).

DataContainerEvent: This was a non-standard substitute for CustomEvent
that seemed to have only one user, so I removed it entirely and switched
the user (MozillaFileLogger.js) to CustomEvent.

ScrollAreaEvent: This is entirely non-standard, but we apparently expose
it deliberately to web content, so I didn't see any reason to remove it
from createEvent.

SimpleGestureEvent and XULCommandEvent: Can still be created from
createEvent(), but not by content.

TimeEvent: This is still in because it has no constructor, so there's no
other way to create it.  Ideally we'd update the SMIL spec to add a
constructor.  I did remove TimeEvents.

MozReview-Commit-ID: 7Yi2oCl9SM2

--HG--
extra : rebase_source : 199ab921acfc531b8b85e77f90fcd799b03c887b
This commit is contained in:
Aryeh Gregor 2017-04-20 15:45:37 +03:00
Родитель e7e00b58d2
Коммит af57d2df0f
34 изменённых файлов: 62 добавлений и 633 удалений

Просмотреть файл

@ -57,6 +57,7 @@
#include "mozilla/dom/TextDecoder.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/XULCommandEvent.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/EventDispatcher.h"
@ -132,7 +133,6 @@
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMWindowUtils.h"
#include "nsIDOMXULCommandEvent.h"
#include "nsIDragService.h"
#include "nsIEditor.h"
#include "nsIFormControl.h"
@ -6367,28 +6367,27 @@ nsContentUtils::DispatchXULCommand(nsIContent* aTarget,
{
NS_ENSURE_STATE(aTarget);
nsIDocument* doc = aTarget->OwnerDoc();
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(doc);
NS_ENSURE_STATE(domDoc);
nsCOMPtr<nsIDOMEvent> event;
domDoc->CreateEvent(NS_LITERAL_STRING("xulcommandevent"),
getter_AddRefs(event));
nsCOMPtr<nsIDOMXULCommandEvent> xulCommand = do_QueryInterface(event);
nsresult rv = xulCommand->InitCommandEvent(NS_LITERAL_STRING("command"),
true, true, doc->GetInnerWindow(),
0, aCtrl, aAlt, aShift, aMeta,
aSourceEvent);
NS_ENSURE_SUCCESS(rv, rv);
nsIPresShell* shell = doc->GetShell();
nsPresContext* presContext = nullptr;
if (shell) {
presContext = shell->GetPresContext();
}
RefPtr<XULCommandEvent> xulCommand = new XULCommandEvent(doc, presContext,
nullptr);
xulCommand->InitCommandEvent(NS_LITERAL_STRING("command"), true, true,
doc->GetInnerWindow(), 0, aCtrl, aAlt, aShift,
aMeta, aSourceEvent);
if (aShell) {
nsEventStatus status = nsEventStatus_eIgnore;
nsCOMPtr<nsIPresShell> kungFuDeathGrip = aShell;
return aShell->HandleDOMEventWithTarget(aTarget, event, &status);
return aShell->HandleDOMEventWithTarget(aTarget, xulCommand, &status);
}
nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
NS_ENSURE_STATE(target);
bool dummy;
return target->DispatchEvent(event, &dummy);
return target->DispatchEvent(xulCommand, &dummy);
}
// static

Просмотреть файл

@ -37,7 +37,6 @@ DEPRECATED_OPERATION(ChromeUseOfDOM3LoadMethod)
DEPRECATED_OPERATION(ShowModalDialog)
DEPRECATED_OPERATION(Window_Content)
DEPRECATED_OPERATION(SyncXMLHttpRequest)
DEPRECATED_OPERATION(DataContainerEvent)
DEPRECATED_OPERATION(Window_Controllers)
DEPRECATED_OPERATION(ImportXULIntoContent)
DEPRECATED_OPERATION(PannerNodeDoppler)

Просмотреть файл

@ -8008,12 +8008,14 @@ nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
ErrorResult rv;
*aReturn = nsIDocument::CreateEvent(aEventType, rv).take();
*aReturn = nsIDocument::CreateEvent(aEventType, CallerType::System,
rv).take();
return rv.StealNSResult();
}
already_AddRefed<Event>
nsIDocument::CreateEvent(const nsAString& aEventType, ErrorResult& rv) const
nsIDocument::CreateEvent(const nsAString& aEventType, CallerType aCallerType,
ErrorResult& rv) const
{
nsIPresShell *shell = GetShell();
@ -8027,7 +8029,7 @@ nsIDocument::CreateEvent(const nsAString& aEventType, ErrorResult& rv) const
// Create event even without presContext.
RefPtr<Event> ev =
EventDispatcher::CreateEvent(const_cast<nsIDocument*>(this), presContext,
nullptr, aEventType);
nullptr, aEventType, aCallerType);
if (!ev) {
rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;

Просмотреть файл

@ -6562,7 +6562,8 @@ nsGlobalWindow::DispatchResizeEvent(const CSSIntSize& aSize)
ErrorResult res;
RefPtr<Event> domEvent =
mDoc->CreateEvent(NS_LITERAL_STRING("CustomEvent"), res);
mDoc->CreateEvent(NS_LITERAL_STRING("CustomEvent"), CallerType::System,
res);
if (res.Failed()) {
return false;
}

Просмотреть файл

@ -2627,7 +2627,9 @@ public:
ImportNode(nsINode& aNode, bool aDeep, mozilla::ErrorResult& rv) const;
nsINode* AdoptNode(nsINode& aNode, mozilla::ErrorResult& rv);
already_AddRefed<mozilla::dom::Event>
CreateEvent(const nsAString& aEventType, mozilla::ErrorResult& rv) const;
CreateEvent(const nsAString& aEventType,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& rv) const;
already_AddRefed<nsRange> CreateRange(mozilla::ErrorResult& rv);
already_AddRefed<mozilla::dom::NodeIterator>
CreateNodeIterator(nsINode& aRoot, uint32_t aWhatToShow,

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/Preferences.h"
#include "mozilla/Sprintf.h"
#include "nsIDOMDataContainerEvent.h"
#include "nsIDOMEvent.h"
#include "nsIScriptSecurityManager.h"
#include "nsIVariant.h"

Просмотреть файл

@ -1,98 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 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 "mozilla/dom/DataContainerEvent.h"
#include "nsContentUtils.h"
#include "nsIDocument.h"
#include "nsIXPConnect.h"
namespace mozilla {
namespace dom {
DataContainerEvent::DataContainerEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent)
: Event(aOwner, aPresContext, aEvent)
{
if (nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aOwner)) {
if (nsIDocument* doc = win->GetExtantDoc()) {
doc->WarnOnceAbout(nsIDocument::eDataContainerEvent);
}
}
}
NS_IMPL_CYCLE_COLLECTION_CLASS(DataContainerEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DataContainerEvent, Event)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DataContainerEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_ADDREF_INHERITED(DataContainerEvent, Event)
NS_IMPL_RELEASE_INHERITED(DataContainerEvent, Event)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DataContainerEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMDataContainerEvent)
NS_INTERFACE_MAP_END_INHERITING(Event)
NS_IMETHODIMP
DataContainerEvent::GetData(const nsAString& aKey, nsIVariant** aData)
{
NS_ENSURE_ARG_POINTER(aData);
mData.Get(aKey, aData);
return NS_OK;
}
NS_IMETHODIMP
DataContainerEvent::SetData(const nsAString& aKey, nsIVariant* aData)
{
NS_ENSURE_ARG(aData);
// Make sure this event isn't already being dispatched.
NS_ENSURE_STATE(!mEvent->mFlags.mIsBeingDispatched);
mData.Put(aKey, aData);
return NS_OK;
}
void
DataContainerEvent::SetData(JSContext* aCx, const nsAString& aKey,
JS::Handle<JS::Value> aVal,
ErrorResult& aRv)
{
if (!nsContentUtils::XPConnect()) {
aRv = NS_ERROR_FAILURE;
return;
}
nsCOMPtr<nsIVariant> val;
nsresult rv =
nsContentUtils::XPConnect()->JSToVariant(aCx, aVal, getter_AddRefs(val));
if (NS_FAILED(rv)) {
aRv = rv;
return;
}
aRv = SetData(aKey, val);
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
already_AddRefed<DataContainerEvent>
NS_NewDOMDataContainerEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent)
{
RefPtr<DataContainerEvent> it =
new DataContainerEvent(aOwner, aPresContext, aEvent);
return it.forget();
}

Просмотреть файл

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 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/. */
#ifndef mozilla_dom_DataContainerEvent_h_
#define mozilla_dom_DataContainerEvent_h_
#include "mozilla/dom/DataContainerEventBinding.h"
#include "mozilla/dom/Event.h"
#include "nsIDOMDataContainerEvent.h"
#include "nsInterfaceHashtable.h"
namespace mozilla {
namespace dom {
class DataContainerEvent : public Event,
public nsIDOMDataContainerEvent
{
public:
DataContainerEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DataContainerEvent, Event)
NS_FORWARD_TO_EVENT
NS_DECL_NSIDOMDATACONTAINEREVENT
virtual JSObject*
WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
{
return DataContainerEventBinding::Wrap(aCx, this, aGivenProto);
}
already_AddRefed<nsIVariant> GetData(const nsAString& aKey)
{
nsCOMPtr<nsIVariant> val;
GetData(aKey, getter_AddRefs(val));
return val.forget();
}
void SetData(JSContext* aCx, const nsAString& aKey,
JS::Handle<JS::Value> aVal, ErrorResult& aRv);
protected:
~DataContainerEvent() {}
private:
nsInterfaceHashtable<nsStringHashKey, nsIVariant> mData;
};
} // namespace dom
} // namespace mozilla
already_AddRefed<mozilla::dom::DataContainerEvent>
NS_NewDOMDataContainerEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent);
#endif // mozilla_dom_DataContainerEvent_h_

Просмотреть файл

@ -17,7 +17,6 @@
#include "ClipboardEvent.h"
#include "CommandEvent.h"
#include "CompositionEvent.h"
#include "DataContainerEvent.h"
#include "DeviceMotionEvent.h"
#include "DragEvent.h"
#include "GeckoProfiler.h"
@ -902,7 +901,8 @@ EventDispatcher::DispatchDOMEvent(nsISupports* aTarget,
EventDispatcher::CreateEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
const nsAString& aEventType)
const nsAString& aEventType,
CallerType aCallerType)
{
if (aEvent) {
switch(aEvent->mClass) {
@ -978,10 +978,6 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
LOG_EVENT_CREATION(MOUSEEVENTS);
return NS_NewDOMMouseEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("popupevents")) {
LOG_EVENT_CREATION(POPUPEVENTS);
return NS_NewDOMMouseEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("mousescrollevents")) {
LOG_EVENT_CREATION(MOUSESCROLLEVENTS);
return NS_NewDOMMouseScrollEvent(aOwner, aPresContext, nullptr);
@ -990,10 +986,6 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
LOG_EVENT_CREATION(DRAGEVENT);
return NS_NewDOMDragEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("dragevents")) {
LOG_EVENT_CREATION(DRAGEVENTS);
return NS_NewDOMDragEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("keyboardevent")) {
LOG_EVENT_CREATION(KEYBOARDEVENT);
return NS_NewDOMKeyboardEvent(aOwner, aPresContext, nullptr);
@ -1010,10 +1002,6 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
LOG_EVENT_CREATION(TEXTEVENT);
return NS_NewDOMCompositionEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("textevents")) {
LOG_EVENT_CREATION(TEXTEVENTS);
return NS_NewDOMCompositionEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("mutationevent")) {
LOG_EVENT_CREATION(MUTATIONEVENT);
return NS_NewDOMMutationEvent(aOwner, aPresContext, nullptr);
@ -1054,10 +1042,6 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
LOG_EVENT_CREATION(HTMLEVENTS);
return NS_NewDOMEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("svgevent")) {
LOG_EVENT_CREATION(SVGEVENT);
return NS_NewDOMEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("svgevents")) {
LOG_EVENT_CREATION(SVGEVENTS);
return NS_NewDOMEvent(aOwner, aPresContext, nullptr);
@ -1066,60 +1050,15 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
LOG_EVENT_CREATION(TIMEEVENT);
return NS_NewDOMTimeEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("timeevents")) {
LOG_EVENT_CREATION(TIMEEVENTS);
return NS_NewDOMTimeEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("xulcommandevent")) {
LOG_EVENT_CREATION(XULCOMMANDEVENT);
return NS_NewDOMXULCommandEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("xulcommandevents")) {
LOG_EVENT_CREATION(XULCOMMANDEVENTS);
return NS_NewDOMXULCommandEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("commandevent")) {
LOG_EVENT_CREATION(COMMANDEVENT);
return NS_NewDOMCommandEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("commandevents")) {
LOG_EVENT_CREATION(COMMANDEVENTS);
return NS_NewDOMCommandEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("datacontainerevent")) {
LOG_EVENT_CREATION(DATACONTAINEREVENT);
return NS_NewDOMDataContainerEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("datacontainerevents")) {
LOG_EVENT_CREATION(DATACONTAINEREVENTS);
return NS_NewDOMDataContainerEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("messageevent")) {
LOG_EVENT_CREATION(MESSAGEEVENT);
RefPtr<Event> event = new MessageEvent(aOwner, aPresContext, nullptr);
return event.forget();
}
if (aEventType.LowerCaseEqualsLiteral("notifypaintevent")) {
LOG_EVENT_CREATION(NOTIFYPAINTEVENT);
return NS_NewDOMNotifyPaintEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("simplegestureevent")) {
LOG_EVENT_CREATION(SIMPLEGESTUREEVENT);
return NS_NewDOMSimpleGestureEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("beforeunloadevent")) {
LOG_EVENT_CREATION(BEFOREUNLOADEVENT);
return NS_NewDOMBeforeUnloadEvent(aOwner, aPresContext, nullptr);
}
// XXXkhuey this is broken
if (aEventType.LowerCaseEqualsLiteral("pagetransition")) {
LOG_EVENT_CREATION(PAGETRANSITION);
PageTransitionEventInit init;
RefPtr<Event> event =
PageTransitionEvent::Constructor(aOwner, EmptyString(), init);
event->MarkUninitialized();
return event.forget();
}
if (aEventType.LowerCaseEqualsLiteral("scrollareaevent")) {
LOG_EVENT_CREATION(SCROLLAREAEVENT);
return NS_NewDOMScrollAreaEvent(aOwner, aPresContext, nullptr);
@ -1169,6 +1108,21 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
return event.forget();
}
// Only allow these events for chrome
if (aCallerType == CallerType::System) {
if (aEventType.LowerCaseEqualsLiteral("simplegestureevent")) {
return NS_NewDOMSimpleGestureEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("xulcommandevent")) {
LOG_EVENT_CREATION(XULCOMMANDEVENT);
return NS_NewDOMXULCommandEvent(aOwner, aPresContext, nullptr);
}
if (aEventType.LowerCaseEqualsLiteral("xulcommandevents")) {
LOG_EVENT_CREATION(XULCOMMANDEVENTS);
return NS_NewDOMXULCommandEvent(aOwner, aPresContext, nullptr);
}
}
#undef LOG_EVENT_CREATION
// NEW EVENT TYPES SHOULD NOT BE ADDED HERE; THEY SHOULD USE ONLY EVENT

Просмотреть файл

@ -8,6 +8,7 @@
#ifndef mozilla_EventDispatcher_h_
#define mozilla_EventDispatcher_h_
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/EventForwards.h"
#include "nsCOMPtr.h"
#include "nsTArray.h"
@ -286,7 +287,9 @@ public:
static already_AddRefed<dom::Event> CreateEvent(dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
const nsAString& aEventType);
const nsAString& aEventType,
dom::CallerType aCallerType =
dom::CallerType::System);
/**
* Called at shutting down.

Просмотреть файл

@ -44,7 +44,6 @@ EXPORTS.mozilla.dom += [
'CommandEvent.h',
'CompositionEvent.h',
'CustomEvent.h',
'DataContainerEvent.h',
'DataTransfer.h',
'DataTransferItem.h',
'DataTransferItemList.h',
@ -87,7 +86,6 @@ UNIFIED_SOURCES += [
'CompositionEvent.cpp',
'ContentEventHandler.cpp',
'CustomEvent.cpp',
'DataContainerEvent.cpp',
'DataTransfer.cpp',
'DataTransferItem.cpp',
'DataTransferItemList.cpp',

Просмотреть файл

@ -11,7 +11,6 @@ support-files =
test_bug336682.js
[test_bug336682_2.xul]
[test_bug368835.html]
[test_bug415498.xul]
[test_bug418986-3.xul]
[test_bug524674.xul]

Просмотреть файл

@ -28,7 +28,6 @@ support-files =
[test_bug336682_1.html]
support-files = test_bug336682.js
[test_bug367781.html]
[test_bug368835.html]
[test_bug379120.html]
[test_bug391568.xhtml]
[test_bug402089.html]

Просмотреть файл

@ -68,13 +68,6 @@ const kEventConstructors = {
return new ClipboardEvent(aName, aProps);
},
},
CommandEvent: { create: function (aName, aProps) {
var e = document.createEvent("commandevent");
e.initCommandEvent(aName, aProps.bubbles, aProps.cancelable,
aProps.command);
return e;
},
},
CompositionEvent: { create: function (aName, aProps) {
var e = document.createEvent("compositionevent");
e.initCompositionEvent(aName, aProps.bubbles, aProps.cancelable,
@ -90,12 +83,6 @@ const kEventConstructors = {
return new DataErrorEvent(aName, aProps);
},
},
DataContainerEvent: { create: function (aName, aProps) {
var e = document.createEvent("datacontainerevent");
e.initEvent(aName, aProps.bubbles, aProps.cancelable);
return e;
},
},
DeviceLightEvent: { create: function (aName, aProps) {
return new DeviceLightEvent(aName, aProps);
},
@ -271,12 +258,6 @@ const kEventConstructors = {
return e;
},
},
NotifyPaintEvent: { create: function (aName, aProps) {
var e = document.createEvent("notifypaintevent");
e.initEvent(aName, aProps.bubbles, aProps.cancelable);
return e;
},
},
OfflineAudioCompletionEvent: { create: "AudioContext" in self
? function (aName, aProps) {
var ac = new AudioContext();
@ -334,19 +315,6 @@ const kEventConstructors = {
return e;
},
},
SimpleGestureEvent: { create: function (aName, aProps) {
var e = document.createEvent("simplegestureevent");
e.initSimpleGestureEvent(aName, aProps.bubbles, aProps.cancelable,
aProps.view, aProps.detail,
aProps.screenX, aProps.screenY,
aProps.clientX, aProps.clientY,
aProps.ctrlKey, aProps.altKey, aProps.shiftKey, aProps.metaKey,
aProps.button, aProps.relatedTarget,
aProps.allowedDirections, aProps.direction, aProps.delta || 0.0,
aProps.clickCount);
return e;
},
},
SpeechRecognitionError: { create: function (aName, aProps) {
return new SpeechRecognitionError(aName, aProps);
},

Просмотреть файл

@ -1,101 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=368835
-->
<head>
<title>Test for Bug 368835</title>
<link rel="stylesheet" type="text/css" href="http://mochi.test:8888/tests/SimpleTest/test.css" />
<script type="text/javascript" src="http://mochi.test:8888/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=368835">
Mozilla Bug 368835
</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
function dataContainerEventHandler(aEvent)
{
var value = "";
var isPassed = true;
try {
value = aEvent.getData("data1");
isPassed = true;
} catch (e) {
isPassed = false;
}
ok(isPassed, "getData shouldn't fail.");
ok(value == "data1", "Wrong value of data.");
is(aEvent.getData("document"), document);
is(aEvent.getData("window"), window);
is(aEvent.getData("event"), aEvent);
is(aEvent.getData("null"), null);
is(aEvent.getData("1"), 1);
is(aEvent.getData("1.1"), 1.1);
is(aEvent.getData("true"), true);
try {
aEvent.setData("data3", "data3");
isPassed = false;
} catch (e) {
isPassed = true;
}
ok(isPassed, "setData should fail during event dispatching.");
}
function doTest()
{
var isPassed;
var event = null;
try {
event = document.createEvent("datacontainerevents");
isPassed = true;
} catch (e) {
isPassed = false;
}
ok(isPassed, "Document should know about 'datacontainerevents' event class.");
ok(("setData" in event), "nsIDOMDataContainerEvent isn't available.");
event.initEvent("dataContainerEvent", true, true);
try {
event.setData("data1", "data1");
event.setData("document", document);
event.setData("window", window);
event.setData("event", event);
event.setData("null", null);
event.setData("1", 1);
event.setData("1.1", 1.1);
event.setData("true", true);
isPassed = true;
} catch (e) {
isPassed = false;
}
ok(isPassed, "setData shouldn't fail when event is initialized.");
document.body.addEventListener("dataContainerEvent",
dataContainerEventHandler, true);
document.body.dispatchEvent(event);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -13,7 +13,6 @@ XPIDL_SOURCES += [
'nsIDOMClipboardEvent.idl',
'nsIDOMCommandEvent.idl',
'nsIDOMCustomEvent.idl',
'nsIDOMDataContainerEvent.idl',
'nsIDOMDataTransfer.idl',
'nsIDOMDragEvent.idl',
'nsIDOMEvent.idl',

Просмотреть файл

@ -1,30 +0,0 @@
/* -*- Mode: C++; 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/. */
#include "nsISupports.idl"
#include "nsIVariant.idl"
[builtinclass, uuid(a9f1f528-d106-4fea-8663-2d7f64b627a9)]
interface nsIDOMDataContainerEvent : nsISupports
{
/**
* Return the data associated with the given key.
*
* @param key the key
* @return the data associated with the key
*/
nsIVariant getData(in DOMString key);
/**
* Set the data for the given key.
*
* @param key the data key
* @param data the data
* @throws NS_ERROR_UNEXPECTED if the method is called during event
* dispatch
*/
void setData(in DOMString key, in nsIVariant data);
};

Просмотреть файл

@ -183,8 +183,6 @@ Window_ContentWarning=window._content is deprecated. Please use window.content
# LOCALIZATION NOTE: Do not translate "XMLHttpRequest"
SyncXMLHttpRequestWarning=Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end users experience. For more help http://xhr.spec.whatwg.org/
ImplicitMetaViewportTagFallback=No meta-viewport tag found. Please explicitly specify one to prevent unexpected behavioural changes in future versions. For more help https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag
# LOCALIZATION NOTE: Do not translate "DataContainerEvent" or "CustomEvent"
DataContainerEventWarning=Use of DataContainerEvent is deprecated. Use CustomEvent instead.
# LOCALIZATION NOTE: Do not translate "window.controllers"
Window_ControllersWarning=window.controllers is deprecated. Do not use it for UA detection.
ImportXULIntoContentWarning=Importing XUL nodes into a content document is deprecated. This functionality may be removed soon.

Просмотреть файл

@ -148,7 +148,7 @@ function testCreateEvent()
{
var evt;
try {
evt = document.createEvent("TimeEvents");
evt = document.createEvent("TimeEvent");
} catch (e) {
ok(false, "Failed to create TimeEvent via script: " + e);
return;

Просмотреть файл

@ -188,7 +188,7 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
"CloseEvent",
// IMPORTANT: Do not change this list without review from a DOM peer!
"CommandEvent",
{name: "CommandEvent", xbl: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
"Comment",
// IMPORTANT: Do not change this list without review from a DOM peer!
@ -849,7 +849,7 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
"SharedWorker",
// IMPORTANT: Do not change this list without review from a DOM peer!
"SimpleGestureEvent",
{name: "SimpleGestureEvent", xbl: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "SimpleTest", xbl: false},
// IMPORTANT: Do not change this list without review from a DOM peer!

Просмотреть файл

@ -4,6 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Func="IsChromeOrXBL"]
interface CommandEvent : Event {
readonly attribute DOMString? command;

Просмотреть файл

@ -1,30 +0,0 @@
/* -*- 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 nsIVariant;
[ChromeOnly]
interface DataContainerEvent : Event {
/**
* Return the data associated with the given key.
*
* @param key the key
* @return the data associated with the key
*/
nsIVariant? getData(DOMString? key);
/**
* Set the data for the given key.
*
* @param key the data key
* @param data the data
* @throws NS_ERROR_UNEXPECTED if the method is called during event
* dispatch
*/
[Throws]
void setData(DOMString? key, any data);
};

Просмотреть файл

@ -73,7 +73,7 @@ interface Document : Node {
[Throws]
Node adoptNode(Node node);
[NewObject, Throws]
[NewObject, Throws, NeedsCallerType]
Event createEvent(DOMString interface);
[NewObject, Throws]

Просмотреть файл

@ -6,6 +6,7 @@
* For more information see nsIDOMSimpleGestureEvent.idl.
*/
[Func="IsChromeOrXBL"]
interface SimpleGestureEvent : MouseEvent
{
const unsigned long DIRECTION_UP = 1;

Просмотреть файл

@ -475,7 +475,6 @@ WEBIDL_FILES = [
'CSSValue.webidl',
'CSSValueList.webidl',
'CustomElementRegistry.webidl',
'DataContainerEvent.webidl',
'DataTransfer.webidl',
'DataTransferItem.webidl',
'DataTransferItemList.webidl',

Просмотреть файл

@ -32,7 +32,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=790732
is(Ci.nsIDOMMouseEvent, MouseEvent);
is(Ci.nsIDOMMouseScrollEvent, MouseScrollEvent);
is(Ci.nsIDOMMutationEvent, MutationEvent);
is(Ci.nsIDOMSimpleGestureEvent, SimpleGestureEvent);
// XXX We can't test this here because it's only exposed to chrome
//is(Ci.nsIDOMSimpleGestureEvent, SimpleGestureEvent);
is(Ci.nsIDOMUIEvent, UIEvent);
is(Ci.nsIDOMHTMLMediaElement, HTMLMediaElement);
is(Ci.nsIDOMOfflineResourceList, OfflineResourceList);

Просмотреть файл

@ -9,11 +9,10 @@ function contentDispatchEvent(type, data, sync) {
data = {};
}
var element = document.createEvent("datacontainerevent");
element.initEvent("contentEvent", true, false);
element.setData("sync", sync);
element.setData("type", type);
element.setData("data", JSON.stringify(data));
var element = new CustomEvent("contentEvent", {
bubbles: true,
detail: { sync: sync, type: type, data: JSON.stringify(data) }
});
document.dispatchEvent(element);
}

Просмотреть файл

@ -48,10 +48,6 @@
expected: FAIL
bug: https://github.com/whatwg/dom/issues/362, 1314303
[Should throw NOT_SUPPORTED_ERR for pluralized legacy event interface "DragEvents"]
expected: FAIL
bug: 1251198
[FocusEvent should be an alias for FocusEvent.]
expected: FAIL
bug: https://github.com/whatwg/dom/issues/362, 1314303
@ -148,10 +144,6 @@
expected: FAIL
bug: https://github.com/whatwg/dom/issues/362, 1314303
[Should throw NOT_SUPPORTED_ERR for pluralized legacy event interface "TextEvents"]
expected: FAIL
bug: 1251198
[TrackEvent should be an alias for TrackEvent.]
expected: FAIL
bug: https://github.com/whatwg/dom/issues/362, 1314303
@ -248,22 +240,6 @@
expected: FAIL
bug: https://github.com/whatwg/dom/issues/362, 1314303
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "CommandEvent"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "CommandEvents"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "DataContainerEvent"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "DataContainerEvents"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "KeyEvents"]
expected: FAIL
bug: 1251198
@ -280,43 +256,11 @@
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "NotifyPaintEvent"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "PageTransition"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "PopUpEvents"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "ScrollAreaEvent"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "SimpleGestureEvent"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "SVGEvent"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "TimeEvent"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "TimeEvents"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for non-legacy event interface "XULCommandEvent"]
expected: FAIL
bug: 1251198
[Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "XULCommandEvents"]
expected: FAIL
bug: 1251198

Просмотреть файл

@ -373,20 +373,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_COMMANDEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"commandevent\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_COMMANDEVENTS" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"commandevents\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_COMPOSITIONEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"compositionevent\") ever called",
@ -401,20 +387,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_DATACONTAINEREVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"datacontainerevent\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_DATACONTAINEREVENTS" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"datacontainerevents\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_DEVICEMOTIONEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"devicemotionevent\") ever called",
@ -436,13 +408,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_DRAGEVENTS" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"dragevents\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_ERROREVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"errorevent\") ever called",
@ -534,20 +499,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_NOTIFYPAINTEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"notifypaintevent\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_PAGETRANSITION" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"pagetransition\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_POPSTATEEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"popstateevent\") ever called",
@ -555,13 +506,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_POPUPEVENTS" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"popupevents\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_SCROLLAREAEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"scrollareaevent\") ever called",
@ -569,13 +513,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_SIMPLEGESTUREEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"simplegestureevent\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_STORAGEEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"storageevent\") ever called",
@ -583,13 +520,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_SVGEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"svgevent\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_SVGEVENTS" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"svgevents\") ever called",
@ -597,20 +527,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_SVGZOOMEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"svgzoomevent\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_SVGZOOMEVENTS" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"svgzoomevents\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_TEXTEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"textevent\") ever called",
@ -618,13 +534,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_TEXTEVENTS" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"textevents\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_TIMEEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"timeevent\") ever called",
@ -632,13 +541,6 @@
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_TIMEEVENTS" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"timeevents\") ever called",
"expires_in_version": "56",
"kind": "count",
"bug_numbers": [1295588, 1251198]
},
"CREATE_EVENT_TOUCHEVENT" : {
"alert_emails": ["ayg@aryeh.name"],
"description": "Was document.createEvent(\"touchevent\") ever called",

Просмотреть файл

@ -1824,16 +1824,11 @@
"COMPONENTS_SHIM_ACCESSED_BY_CONTENT",
"CONTENT_DOCUMENTS_DESTROYED",
"CREATE_EVENT_BEFOREUNLOADEVENT",
"CREATE_EVENT_COMMANDEVENT",
"CREATE_EVENT_COMMANDEVENTS",
"CREATE_EVENT_COMPOSITIONEVENT",
"CREATE_EVENT_CUSTOMEVENT",
"CREATE_EVENT_DATACONTAINEREVENT",
"CREATE_EVENT_DATACONTAINEREVENTS",
"CREATE_EVENT_DEVICEMOTIONEVENT",
"CREATE_EVENT_DEVICEORIENTATIONEVENT",
"CREATE_EVENT_DRAGEVENT",
"CREATE_EVENT_DRAGEVENTS",
"CREATE_EVENT_ERROREVENT",
"CREATE_EVENT_EVENT",
"CREATE_EVENT_EVENTS",
@ -1847,21 +1842,12 @@
"CREATE_EVENT_MOUSESCROLLEVENTS",
"CREATE_EVENT_MUTATIONEVENT",
"CREATE_EVENT_MUTATIONEVENTS",
"CREATE_EVENT_NOTIFYPAINTEVENT",
"CREATE_EVENT_PAGETRANSITION",
"CREATE_EVENT_POPSTATEEVENT",
"CREATE_EVENT_POPUPEVENTS",
"CREATE_EVENT_SCROLLAREAEVENT",
"CREATE_EVENT_SIMPLEGESTUREEVENT",
"CREATE_EVENT_STORAGEEVENT",
"CREATE_EVENT_SVGEVENT",
"CREATE_EVENT_SVGEVENTS",
"CREATE_EVENT_SVGZOOMEVENT",
"CREATE_EVENT_SVGZOOMEVENTS",
"CREATE_EVENT_TEXTEVENT",
"CREATE_EVENT_TEXTEVENTS",
"CREATE_EVENT_TIMEEVENT",
"CREATE_EVENT_TIMEEVENTS",
"CREATE_EVENT_TOUCHEVENT",
"CREATE_EVENT_UIEVENT",
"CREATE_EVENT_UIEVENTS",

Просмотреть файл

@ -57,7 +57,8 @@ nsAutoWindowStateHelper::DispatchEventToChrome(const char* aEventName)
}
ErrorResult rv;
RefPtr<Event> event = doc->CreateEvent(NS_LITERAL_STRING("Events"), rv);
RefPtr<Event> event = doc->CreateEvent(NS_LITERAL_STRING("Events"),
CallerType::System, rv);
if (rv.Failed()) {
rv.SuppressException();
return false;

Просмотреть файл

@ -29,7 +29,8 @@ void nsMenuUtilsX::DispatchCommandTo(nsIContent* aTargetContent)
if (doc) {
ErrorResult rv;
RefPtr<dom::Event> event =
doc->CreateEvent(NS_LITERAL_STRING("xulcommandevent"), rv);
doc->CreateEvent(NS_LITERAL_STRING("xulcommandevent"),
dom::CallerType::System, rv);
nsCOMPtr<nsIDOMXULCommandEvent> command = do_QueryObject(event);
// FIXME: Should probably figure out how to init this with the actual

Просмотреть файл

@ -26,7 +26,6 @@
#include "nsIDOMCSSValue.h"
#include "nsIDOMCSSValueList.h"
#include "nsIDOMCustomEvent.h"
#include "nsIDOMDataContainerEvent.h"
#ifdef MOZ_WEBRTC
#include "nsIDOMDataChannel.h"
#endif
@ -158,7 +157,6 @@
#ifdef MOZ_WEBRTC
#include "mozilla/dom/DataChannelBinding.h"
#endif
#include "mozilla/dom/DataContainerEventBinding.h"
#include "mozilla/dom/DataTransferBinding.h"
#include "mozilla/dom/DOMCursorBinding.h"
#include "mozilla/dom/DOMExceptionBinding.h"
@ -346,7 +344,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
#ifdef MOZ_WEBRTC
DEFINE_SHIM(DataChannel),
#endif
DEFINE_SHIM(DataContainerEvent),
DEFINE_SHIM(DataTransfer),
DEFINE_SHIM(DOMCursor),
DEFINE_SHIM(DOMException),

Просмотреть файл

@ -240,7 +240,8 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(uint32_t aLevel)
if (doc) {
ErrorResult rv;
RefPtr<dom::Event> event =
doc->CreateEvent(NS_LITERAL_STRING("Events"),rv);
doc->CreateEvent(NS_LITERAL_STRING("Events"), dom::CallerType::System,
rv);
if (event) {
event->InitEvent(NS_LITERAL_STRING("windowZLevel"), true, false);