Bug 834193: Implement USSDReceivedEvent, DataErrorEvent and CFStateChangeEvent using codegenerator. r=smaug
authorVicamo Yang <vyang@mozilla.com>
Thu, 07 Feb 2013 19:02:12 +0800
changeset 131018 26f2a61829ac359a47da2180fcfaaf48a8660ccd
parent 131017 3b05660cbdd2d5a166fdf7c0fe8cffe5433ff8bc
child 131019 4c85a8bfa2f49139a0f7ad85532434cd5095ecbe
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs834193
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 834193: Implement USSDReceivedEvent, DataErrorEvent and CFStateChangeEvent using codegenerator. r=smaug
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/network/interfaces/nsIDOMCFStateChangeEvent.idl
dom/network/interfaces/nsIDOMDataErrorEvent.idl
dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl
dom/network/src/CFStateChangeEvent.cpp
dom/network/src/CFStateChangeEvent.h
dom/network/src/DataErrorEvent.cpp
dom/network/src/DataErrorEvent.h
dom/network/src/Makefile.in
dom/network/src/MobileConnection.cpp
dom/network/src/USSDReceivedEvent.cpp
dom/network/src/USSDReceivedEvent.h
js/xpconnect/src/event_impl_gen.conf.in
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -420,32 +420,27 @@ using mozilla::dom::workers::ResolveWork
 #include "nsIDOMWakeLock.h"
 #include "nsIDOMSmsManager.h"
 #include "nsIDOMMozSmsMessage.h"
 #include "nsIDOMSmsRequest.h"
 #include "nsIDOMSmsFilter.h"
 #include "nsIDOMSmsCursor.h"
 #include "nsIDOMSmsSegmentInfo.h"
 #include "nsIDOMConnection.h"
-#ifdef MOZ_B2G_RIL
-#include "nsIDOMMobileConnection.h"
-#endif
-#include "USSDReceivedEvent.h"
-#include "DataErrorEvent.h"
 #include "mozilla/dom/network/Utils.h"
 
 #ifdef MOZ_B2G_RIL
 #include "Telephony.h"
 #include "TelephonyCall.h"
 #include "nsIDOMMozVoicemail.h"
 #include "nsIDOMIccManager.h"
 #include "StkCommandEvent.h"
 #include "nsIDOMMozCellBroadcast.h"
 #include "nsIDOMMozCellBroadcastEvent.h"
-#include "CFStateChangeEvent.h"
+#include "nsIDOMMobileConnection.h"
 #endif // MOZ_B2G_RIL
 
 #ifdef MOZ_B2G_FM
 #include "FMRadio.h"
 #endif
 
 #ifdef MOZ_B2G_BT
 #include "BluetoothManager.h"
@@ -1283,27 +1278,18 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
 #ifdef MOZ_B2G_RIL
   NS_DEFINE_CLASSINFO_DATA(MozMobileConnection, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozCellBroadcast, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
-
-  NS_DEFINE_CLASSINFO_DATA(CFStateChangeEvent, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
 #endif
 
-  NS_DEFINE_CLASSINFO_DATA(USSDReceivedEvent, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-
-  NS_DEFINE_CLASSINFO_DATA(DataErrorEvent, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-
   NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
 #if defined(MOZ_MEDIA)
   NS_DEFINE_CLASSINFO_DATA(HTMLVideoElement, nsElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(HTMLSourceElement, nsElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
@@ -3404,33 +3390,18 @@ nsDOMClassInfo::Init()
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCellBroadcast)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozCellBroadcastEvent, nsIDOMMozCellBroadcastEvent)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCellBroadcastEvent)
      DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
-
-  DOM_CLASSINFO_MAP_BEGIN(CFStateChangeEvent, nsIDOMCFStateChangeEvent)
-     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCFStateChangeEvent)
-     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
-  DOM_CLASSINFO_MAP_END
 #endif // MOZ_B2G_RIL
 
-  DOM_CLASSINFO_MAP_BEGIN(USSDReceivedEvent, nsIDOMUSSDReceivedEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMUSSDReceivedEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
-  DOM_CLASSINFO_MAP_END
- 
-  DOM_CLASSINFO_MAP_BEGIN(DataErrorEvent, nsIDOMDataErrorEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataErrorEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
   DOM_CLASSINFO_MAP_END
 
 #if defined (MOZ_MEDIA)
   DOM_CLASSINFO_MAP_BEGIN(HTMLVideoElement, nsIDOMHTMLVideoElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLVideoElement)
     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -318,23 +318,18 @@ DOMCI_CLASS(MozSmsRequest)
 DOMCI_CLASS(MozSmsFilter)
 DOMCI_CLASS(MozSmsCursor)
 DOMCI_CLASS(MozSmsSegmentInfo)
 
 DOMCI_CLASS(MozConnection)
 #ifdef MOZ_B2G_RIL
 DOMCI_CLASS(MozMobileConnection)
 DOMCI_CLASS(MozCellBroadcast)
-DOMCI_CLASS(CFStateChangeEvent)
 #endif
 
-DOMCI_CLASS(USSDReceivedEvent)
-
-DOMCI_CLASS(DataErrorEvent)
-
 // @font-face in CSS
 DOMCI_CLASS(CSSFontFaceRule)
 
 #if defined(MOZ_MEDIA)
 // WhatWG Video Element
 DOMCI_CLASS(HTMLVideoElement)
 DOMCI_CLASS(HTMLSourceElement)
 DOMCI_CLASS(MediaError)
--- a/dom/network/interfaces/nsIDOMCFStateChangeEvent.idl
+++ b/dom/network/interfaces/nsIDOMCFStateChangeEvent.idl
@@ -1,15 +1,15 @@
 /* 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 "nsIDOMEvent.idl"
 
-[scriptable, builtinclass, uuid(9342c4eb-b6b3-414c-892f-c3630ce35c40)]
+[scriptable, builtinclass, uuid(905348f1-3d06-443c-8762-567e7e4b6696)]
 interface nsIDOMCFStateChangeEvent : nsIDOMEvent
 {
   /**
    * Indicates about errors while setting up the Call forwarding rule.
    */
   readonly attribute bool success;
 
   /**
@@ -46,9 +46,29 @@ interface nsIDOMCFStateChangeEvent : nsI
    */
   readonly attribute unsigned short timeSeconds;
 
   /**
    * Service for which the call forward is set up. It should be one of the
    * nsIDOMMozMobileConnectionInfo.ICC_SERVICE_CLASS_* values.
    */
   readonly attribute unsigned short serviceClass;
+
+  [noscript] void initCFStateChangeEvent(in DOMString aType,
+                                         in boolean aCanBubble,
+                                         in boolean aCancelable,
+                                         in boolean aSuccess,
+                                         in unsigned short aAction,
+                                         in unsigned short aReason,
+                                         in DOMString aNumber,
+                                         in unsigned short aTimeSeconds,
+                                         in unsigned short aServiceClass);
 };
+
+dictionary CFStateChangeEventInit : EventInit
+{
+  boolean success;
+  unsigned short action;
+  unsigned short reason;
+  DOMString number;
+  unsigned short timeSeconds;
+  unsigned short serviceClass;
+};
--- a/dom/network/interfaces/nsIDOMDataErrorEvent.idl
+++ b/dom/network/interfaces/nsIDOMDataErrorEvent.idl
@@ -1,11 +1,21 @@
 /* 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 "nsIDOMEvent.idl"
 
-[scriptable, builtinclass, uuid(494cf68f-0ca8-4cf9-924b-84cf379c9631)]
+[scriptable, builtinclass, uuid(8b4ed443-a6b0-4445-aab0-9aa9fd5f6c1e)]
 interface nsIDOMDataErrorEvent : nsIDOMEvent
 {
   readonly attribute DOMString message;
+
+  [noscript] void initDataErrorEvent(in DOMString aType,
+                                     in boolean aCanBubble,
+                                     in boolean aCancelable,
+                                     in DOMString aMessage);
 };
+
+dictionary DataErrorEventInit : EventInit
+{
+  DOMString message;
+};
--- a/dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl
+++ b/dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl
@@ -1,12 +1,24 @@
 /* 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 "nsIDOMEvent.idl"
 
-[scriptable, builtinclass, uuid(56e18850-96f1-4898-a0de-47e0c994c4ab)]
+[scriptable, builtinclass, uuid(d26880c8-0468-4abb-94a6-9143defb5545)]
 interface nsIDOMUSSDReceivedEvent : nsIDOMEvent
 {
   readonly attribute DOMString message;
   [infallible] readonly attribute boolean sessionEnded;
+
+  [noscript] void initUSSDReceivedEvent(in DOMString aType,
+                                        in boolean aCanBubble,
+                                        in boolean aCancelable,
+                                        in DOMString aMessage,
+                                        in boolean aSessionEnded);
 };
+
+dictionary USSDReceivedEventInit : EventInit
+{
+  DOMString message;
+  boolean sessionEnded;
+};
deleted file mode 100644
--- a/dom/network/src/CFStateChangeEvent.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/* 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 "CFStateChangeEvent.h"
-#include "nsIDOMClassInfo.h"
-#include "nsDOMClassInfoID.h"
-#include "nsContentUtils.h"
-
-DOMCI_DATA(CFStateChangeEvent, mozilla::dom::network::CFStateChangeEvent)
-
-namespace mozilla {
-namespace dom {
-namespace network {
-
-already_AddRefed<CFStateChangeEvent>
-CFStateChangeEvent::Create(bool aSuccess,
-                           uint16_t aAction,
-                           uint16_t aReason,
-                           nsAString& aNumber,
-                           uint16_t aTimeSeconds,
-                           uint16_t aServiceClass)
-{
-  NS_ASSERTION(!aNumber.IsEmpty(), "Empty number!");
-
-  nsRefPtr<CFStateChangeEvent> event = new CFStateChangeEvent();
-
-  event->mSuccess = aSuccess;
-  event->mAction = aAction;
-  event->mReason = aReason;
-  event->mNumber = aNumber;
-  event->mTimeSeconds = aTimeSeconds;
-  event->mServiceClass = aServiceClass;
-
-  return event.forget();
-}
-
-NS_IMPL_ADDREF_INHERITED(CFStateChangeEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(CFStateChangeEvent, nsDOMEvent)
-
-NS_INTERFACE_MAP_BEGIN(CFStateChangeEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCFStateChangeEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CFStateChangeEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMETHODIMP
-CFStateChangeEvent::GetSuccess(bool* aSuccess)
-{
-  *aSuccess = mSuccess;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CFStateChangeEvent::GetAction(uint16_t* aAction)
-{
-  *aAction = mAction;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CFStateChangeEvent::GetReason(uint16_t* aReason)
-{
-  *aReason = mReason;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CFStateChangeEvent::GetNumber(nsAString& aNumber)
-{
-  aNumber.Assign(mNumber);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CFStateChangeEvent::GetTimeSeconds(uint16_t* aTimeSeconds)
-{
-  *aTimeSeconds = mTimeSeconds;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CFStateChangeEvent::GetServiceClass(uint16_t* aServiceClass)
-{
-  *aServiceClass = mServiceClass;
-  return NS_OK;
-}
-
-}
-}
-}
deleted file mode 100644
--- a/dom/network/src/CFStateChangeEvent.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* 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_network_cfstatechangeevent_h
-#define mozilla_dom_network_cfstatechangeevent_h
-
-#include "nsIDOMCFStateChangeEvent.h"
-#include "nsDOMEvent.h"
-
-namespace mozilla {
-namespace dom {
-namespace network {
-
-class CFStateChangeEvent : public nsDOMEvent,
-                           public nsIDOMCFStateChangeEvent
-{
-  bool mSuccess;
-  uint16_t mAction;
-  uint16_t mReason;
-  nsString mNumber;
-  uint16_t mTimeSeconds;
-  uint16_t mServiceClass;
-
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_FORWARD_TO_NSDOMEVENT
-  NS_DECL_NSIDOMCFSTATECHANGEEVENT
-
-  static already_AddRefed<CFStateChangeEvent>
-  Create(bool aSuccess,
-         uint16_t aAction,
-         uint16_t aReason,
-         nsAString& aNumber,
-         uint16_t aTimeSeconds,
-         uint16_t aServiceClass);
-
-  nsresult
-  Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
-  {
-    NS_ASSERTION(aTarget, "Null pointer!");
-    NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
-
-    nsresult rv = InitEvent(aEventType, false, false);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    SetTrusted(true);
-
-    nsDOMEvent* thisEvent = this;
-
-    bool dummy;
-    rv = aTarget->DispatchEvent(thisEvent, &dummy);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return NS_OK;
-  }
-
-private:
-  CFStateChangeEvent()
-  : nsDOMEvent(nullptr, nullptr)
-  { }
-
-  ~CFStateChangeEvent()
-  { }
-};
-
-}
-}
-}
-
-#endif // mozilla_dom_network_cfstatechangeevent_h
deleted file mode 100644
--- a/dom/network/src/DataErrorEvent.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/* 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 "DataErrorEvent.h"
-#include "nsIDOMClassInfo.h"
-
-DOMCI_DATA(DataErrorEvent, mozilla::dom::network::DataErrorEvent)
-
-namespace mozilla {
-namespace dom {
-namespace network {
-
-already_AddRefed<DataErrorEvent>
-DataErrorEvent::Create(nsAString& aMessage)
-{
-  NS_ASSERTION(!aMessage.IsEmpty(), "Empty message!");
-
-  nsRefPtr<DataErrorEvent> event = new DataErrorEvent();
-
-  event->mMessage = aMessage;
-
-  return event.forget();
-}
-
-NS_IMPL_ADDREF_INHERITED(DataErrorEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(DataErrorEvent, nsDOMEvent)
-
-NS_INTERFACE_MAP_BEGIN(DataErrorEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDataErrorEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DataErrorEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMETHODIMP
-DataErrorEvent::GetMessage(nsAString& aMessage)
-{
-  aMessage.Assign(mMessage);
-  return NS_OK;
-}
-
-}
-}
-}
deleted file mode 100644
--- a/dom/network/src/DataErrorEvent.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* 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_network_dataerrorevent_h
-#define mozilla_dom_network_dataerrorevent_h
-
-#include "nsIDOMDataErrorEvent.h"
-#include "nsDOMEvent.h"
-
-namespace mozilla {
-namespace dom {
-namespace network {
-
-class DataErrorEvent : public nsDOMEvent,
-                       public nsIDOMDataErrorEvent
-{
-  nsString mMessage;
-
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_FORWARD_TO_NSDOMEVENT
-  NS_DECL_NSIDOMDATAERROREVENT
-
-  static already_AddRefed<DataErrorEvent>
-  Create(nsAString& aMessage);
-
-  nsresult
-  Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
-  {
-    NS_ASSERTION(aTarget, "Null pointer!");
-    NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
-
-    nsresult rv = InitEvent(aEventType, false, false);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    SetTrusted(true);
-
-    nsDOMEvent* thisEvent = this;
-
-    bool dummy;
-    rv = aTarget->DispatchEvent(thisEvent, &dummy);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return NS_OK;
-  }
-
-private:
-  DataErrorEvent()
-  : nsDOMEvent(nullptr, nullptr)
-  { }
-
-  ~DataErrorEvent()
-  { }
-};
-
-}
-}
-}
-
-#endif // mozilla_dom_network_dataerrorevent_h
--- a/dom/network/src/Makefile.in
+++ b/dom/network/src/Makefile.in
@@ -44,26 +44,23 @@ EXPORTS_mozilla/dom/network = \
   Constants.h \
   TCPSocketChild.h \
   TCPSocketParent.h \
   $(NULL)
 
 CPPSRCS = \
   Connection.cpp \
   Utils.cpp \
-  USSDReceivedEvent.cpp \
-  DataErrorEvent.cpp \
   TCPSocketParent.cpp \
   TCPSocketChild.cpp \
   $(NULL)
 
 ifdef MOZ_B2G_RIL
 CPPSRCS += \
   MobileConnection.cpp \
-  CFStateChangeEvent.cpp \
   $(NULL)
 endif
 
 LOCAL_INCLUDES = \
   -I$(topsrcdir)/content/events/src \
   $(NULL)
 
 ifdef MOZ_B2G_RIL
--- a/dom/network/src/MobileConnection.cpp
+++ b/dom/network/src/MobileConnection.cpp
@@ -2,23 +2,23 @@
  * 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 "MobileConnection.h"
 #include "nsIDOMDOMRequest.h"
 #include "nsIDOMClassInfo.h"
 #include "nsDOMEvent.h"
 #include "nsIObserverService.h"
-#include "USSDReceivedEvent.h"
-#include "DataErrorEvent.h"
+#include "nsIDOMUSSDReceivedEvent.h"
+#include "nsIDOMDataErrorEvent.h"
+#include "nsIDOMCFStateChangeEvent.h"
 #include "mozilla/Services.h"
 #include "IccManager.h"
 #include "GeneratedEvents.h"
 #include "nsIDOMICCCardLockErrorEvent.h"
-#include "CFStateChangeEvent.h"
 
 #include "nsContentUtils.h"
 #include "nsJSUtils.h"
 #include "nsJSON.h"
 #include "jsapi.h"
 
 #include "mozilla/dom/USSDReceivedEventBinding.h"
 #include "mozilla/dom/CFStateChangeEventBinding.h"
@@ -165,35 +165,39 @@ MobileConnection::Observe(nsISupports* a
     return NS_OK;
   }
 
   if (!strcmp(aTopic, kUssdReceivedTopic)) {
     mozilla::dom::USSDReceivedEventDict dict;
     bool ok = dict.Init(nsDependentString(aData));
     NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
 
-    nsRefPtr<USSDReceivedEvent> event =
-      USSDReceivedEvent::Create(dict.mMessage, dict.mSessionEnded);
-    NS_ASSERTION(event, "This should never fail!");
+    nsCOMPtr<nsIDOMEvent> event;
+    NS_NewDOMUSSDReceivedEvent(getter_AddRefs(event), nullptr, nullptr);
+    nsCOMPtr<nsIDOMUSSDReceivedEvent> ce = do_QueryInterface(event);
+    nsresult rv = ce->InitUSSDReceivedEvent(USSDRECEIVED_EVENTNAME,
+                                            false, false,
+                                            dict.mMessage, dict.mSessionEnded);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-    nsresult rv = event->Dispatch(ToIDOMEventTarget(), USSDRECEIVED_EVENTNAME);
-    NS_ENSURE_SUCCESS(rv, rv);
-    return NS_OK;
+    return DispatchTrustedEvent(ce);
   }
 
   if (!strcmp(aTopic, kDataErrorTopic)) {
     nsString dataerror;
     dataerror.Assign(aData);
-    nsRefPtr<DataErrorEvent> event = DataErrorEvent::Create(dataerror);
-    NS_ASSERTION(event, "This should never fail!");
 
-    nsresult rv =
-      event->Dispatch(ToIDOMEventTarget(), DATAERROR_EVENTNAME);
+    nsCOMPtr<nsIDOMEvent> event;
+    NS_NewDOMDataErrorEvent(getter_AddRefs(event), nullptr, nullptr);
+    nsCOMPtr<nsIDOMDataErrorEvent> ce = do_QueryInterface(event);
+    nsresult rv = ce->InitDataErrorEvent(DATAERROR_EVENTNAME,
+                                         false, false, dataerror);
     NS_ENSURE_SUCCESS(rv, rv);
-    return NS_OK;
+
+    return DispatchTrustedEvent(ce);
   }
 
   if (!strcmp(aTopic, kIccCardLockErrorTopic)) {
     nsString errorMsg;
     errorMsg.Assign(aData);
 
     if (errorMsg.IsEmpty()) {
       NS_ERROR("Got a 'icc-cardlock-error' topic without a valid message!");
@@ -245,28 +249,28 @@ MobileConnection::Observe(nsISupports* a
     return NS_OK;
   }
 
   if (!strcmp(aTopic, kCfStateChangedTopic)) {
     mozilla::dom::CFStateChangeEventDict dict;
     bool ok = dict.Init(nsDependentString(aData));
     NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
 
-    nsRefPtr<CFStateChangeEvent> event =
-      CFStateChangeEvent::Create(dict.mSuccess,
-                                 dict.mAction,
-                                 dict.mReason,
-                                 dict.mNumber,
-                                 dict.mTimeSeconds,
-                                 dict.mServiceClass);
-    NS_ASSERTION(event, "This should never fail!");
+    nsCOMPtr<nsIDOMEvent> event;
+    NS_NewDOMCFStateChangeEvent(getter_AddRefs(event), nullptr, nullptr);
+    nsCOMPtr<nsIDOMCFStateChangeEvent> ce = do_QueryInterface(event);
+    nsresult rv = ce->InitCFStateChangeEvent(CFSTATECHANGE_EVENTNAME,
+                                             false, false,
+                                             dict.mSuccess, dict.mAction,
+                                             dict.mReason, dict.mNumber,
+                                             dict.mTimeSeconds,
+                                             dict.mServiceClass);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-    nsresult rv = event->Dispatch(ToIDOMEventTarget(), CFSTATECHANGE_EVENTNAME);
-    NS_ENSURE_SUCCESS(rv, rv);
-    return NS_OK;
+    return DispatchTrustedEvent(ce);
   }
 
   MOZ_NOT_REACHED("Unknown observer topic!");
   return NS_OK;
 }
 
 // nsIDOMMozMobileConnection
 
deleted file mode 100644
--- a/dom/network/src/USSDReceivedEvent.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/* 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 "USSDReceivedEvent.h"
-#include "nsIDOMClassInfo.h"
-#include "nsDOMClassInfoID.h"
-#include "nsContentUtils.h"
-
-DOMCI_DATA(USSDReceivedEvent, mozilla::dom::network::USSDReceivedEvent)
-
-namespace mozilla {
-namespace dom {
-namespace network {
-
-already_AddRefed<USSDReceivedEvent>
-USSDReceivedEvent::Create(nsAString& aMessage, bool aSessionEnded)
-{
-  NS_ASSERTION(!aMessage.IsEmpty(), "Empty message!");
-
-  nsRefPtr<USSDReceivedEvent> event = new USSDReceivedEvent();
-
-  event->mMessage = aMessage;
-  event->mSessionEnded = aSessionEnded;
-
-  return event.forget();
-}
-
-NS_IMPL_ADDREF_INHERITED(USSDReceivedEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(USSDReceivedEvent, nsDOMEvent)
-
-NS_INTERFACE_MAP_BEGIN(USSDReceivedEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMUSSDReceivedEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(USSDReceivedEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMETHODIMP
-USSDReceivedEvent::GetMessage(nsAString& aMessage)
-{
-  aMessage.Assign(mMessage);
-  return NS_OK;
-}
-
-/* [infallible] */ NS_IMETHODIMP
-USSDReceivedEvent::GetSessionEnded(bool* aSessionEnded)
-{
-  *aSessionEnded = mSessionEnded;
-  return NS_OK;
-}
-
-}
-}
-}
deleted file mode 100644
--- a/dom/network/src/USSDReceivedEvent.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* 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_network_ussdreceivedevent_h
-#define mozilla_dom_network_ussdreceivedevent_h
-
-#include "nsIDOMUSSDReceivedEvent.h"
-#include "nsDOMEvent.h"
-
-namespace mozilla {
-namespace dom {
-namespace network {
-
-class USSDReceivedEvent : public nsDOMEvent,
-                          public nsIDOMUSSDReceivedEvent
-{
-  nsString mMessage;
-  bool mSessionEnded;
-
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_FORWARD_TO_NSDOMEVENT
-  NS_DECL_NSIDOMUSSDRECEIVEDEVENT
-
-  static already_AddRefed<USSDReceivedEvent>
-  Create(nsAString& aMessage, bool aSessionEnded);
-
-  nsresult
-  Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
-  {
-    NS_ASSERTION(aTarget, "Null pointer!");
-    NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
-
-    nsresult rv = InitEvent(aEventType, false, false);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    SetTrusted(true);
-
-    nsDOMEvent* thisEvent = this;
-
-    bool dummy;
-    rv = aTarget->DispatchEvent(thisEvent, &dummy);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return NS_OK;
-  }
-
-private:
-  USSDReceivedEvent()
-  : nsDOMEvent(nullptr, nullptr)
-  { }
-
-  ~USSDReceivedEvent()
-  { }
-};
-
-}
-}
-}
-
-#endif // mozilla_dom_network_ussdreceivedevent_h
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -24,21 +24,24 @@ simple_events = [
     'DeviceLightEvent',
     'MozApplicationEvent',
 #ifdef MOZ_B2G_BT
     'BluetoothDeviceEvent',
     'BluetoothDeviceAddressEvent',
 #endif
 #ifdef MOZ_B2G_RIL
     'CallEvent',
+    'CFStateChangeEvent',
+    'DataErrorEvent',
     'ICCCardLockErrorEvent',
     'MozWifiStatusChangeEvent',
     'MozWifiConnectionInfoEvent',
     'MozCellBroadcastEvent',
     'MozVoicemailEvent',
+    'USSDReceivedEvent',
 #endif
     'MozSmsEvent',
     'DeviceStorageChangeEvent',
     'PopupBlockedEvent'
   ]
 
 """ include file names """
 special_includes = [