Bug 777271 - Re-implement nsIDOMCallEvent using event implementation codegen. r=bent,vicamo,hsinyi
authorKyle Machulis <kyle@nonpolynomial.com>
Mon, 28 Jan 2013 15:39:50 +0800
changeset 129922 514db0cfadcfc8db48408083fe81f53d60177018
parent 129921 472f37a8f4336c32ba47c32f11ae248b534736fa
child 129923 41b5ec7f02935920cc8b973b4ed8533475720bbd
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)
reviewersbent, vicamo, hsinyi
bugs777271
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 777271 - Re-implement nsIDOMCallEvent using event implementation codegen. r=bent,vicamo,hsinyi
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/telephony/CallEvent.cpp
dom/telephony/CallEvent.h
dom/telephony/Makefile.in
dom/telephony/Telephony.cpp
dom/telephony/Telephony.h
dom/telephony/TelephonyCall.cpp
dom/telephony/TelephonyCall.h
dom/telephony/nsIDOMCallEvent.idl
js/xpconnect/src/event_impl_gen.conf.in
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -459,17 +459,16 @@ using mozilla::dom::workers::ResolveWork
 #endif
 #include "USSDReceivedEvent.h"
 #include "DataErrorEvent.h"
 #include "mozilla/dom/network/Utils.h"
 
 #ifdef MOZ_B2G_RIL
 #include "Telephony.h"
 #include "TelephonyCall.h"
-#include "CallEvent.h"
 #include "nsIDOMVoicemail.h"
 #include "nsIDOMVoicemailEvent.h"
 #include "nsIDOMIccManager.h"
 #include "StkCommandEvent.h"
 #include "nsIDOMMozCellBroadcast.h"
 #include "nsIDOMMozCellBroadcastEvent.h"
 #include "CFStateChangeEvent.h"
 #endif // MOZ_B2G_RIL
@@ -1495,18 +1494,16 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CLASSINFO_DATA(MediaQueryList, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
 #ifdef MOZ_B2G_RIL
   NS_DEFINE_CLASSINFO_DATA(Telephony, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(TelephonyCall, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
-  NS_DEFINE_CLASSINFO_DATA(CallEvent, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozVoicemail, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozVoicemailEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozIccManager, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozStkCommandEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -3906,21 +3903,16 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(TelephonyCall, nsIDOMTelephonyCall)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTelephonyCall)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(CallEvent, nsIDOMCallEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMCallEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(MozVoicemail, nsIDOMMozVoicemail)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozVoicemail)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozVoicemailEvent, nsIDOMMozVoicemailEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozVoicemailEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -426,17 +426,16 @@ DOMCI_CLASS(MozCSSKeyframesRule)
 
 DOMCI_CLASS(CSSPageRule)
 
 DOMCI_CLASS(MediaQueryList)
 
 #ifdef MOZ_B2G_RIL
 DOMCI_CLASS(Telephony)
 DOMCI_CLASS(TelephonyCall)
-DOMCI_CLASS(CallEvent)
 DOMCI_CLASS(MozVoicemail)
 DOMCI_CLASS(MozVoicemailEvent)
 DOMCI_CLASS(MozIccManager)
 DOMCI_CLASS(MozStkCommandEvent)
 #endif
 
 #ifdef MOZ_B2G_FM
 DOMCI_CLASS(FMRadio)
deleted file mode 100644
--- a/dom/telephony/CallEvent.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=40: */
-/* 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 "CallEvent.h"
-
-#include "nsDOMClassInfo.h"
-
-#include "Telephony.h"
-#include "TelephonyCall.h"
-
-USING_TELEPHONY_NAMESPACE
-
-// static
-already_AddRefed<CallEvent>
-CallEvent::Create(TelephonyCall* aCall)
-{
-  NS_ASSERTION(aCall, "Null pointer!");
-
-  nsRefPtr<CallEvent> event = new CallEvent();
-
-  event->mCall = aCall;
-
-  return event.forget();
-}
-
-NS_IMPL_CYCLE_COLLECTION_INHERITED_1(CallEvent,
-                                     nsDOMEvent,
-                                     mCall)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CallEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCallEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CallEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMPL_ADDREF_INHERITED(CallEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(CallEvent, nsDOMEvent)
-
-DOMCI_DATA(CallEvent, CallEvent)
-
-NS_IMETHODIMP
-CallEvent::GetCall(nsIDOMTelephonyCall** aCall)
-{
-  nsCOMPtr<nsIDOMTelephonyCall> call = mCall.get();
-  call.forget(aCall);
-  return NS_OK;
-}
deleted file mode 100644
--- a/dom/telephony/CallEvent.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=40: */
-/* 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_telephony_callevent_h__
-#define mozilla_dom_telephony_callevent_h__
-
-#include "TelephonyCommon.h"
-
-#include "nsIDOMCallEvent.h"
-#include "nsIDOMEventTarget.h"
-
-#include "nsDOMEvent.h"
-
-BEGIN_TELEPHONY_NAMESPACE
-
-class CallEvent : public nsDOMEvent,
-                  public nsIDOMCallEvent
-{
-  nsRefPtr<TelephonyCall> mCall;
-
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_FORWARD_TO_NSDOMEVENT
-  NS_DECL_NSIDOMCALLEVENT
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CallEvent, nsDOMEvent)
-
-  static already_AddRefed<CallEvent>
-  Create(TelephonyCall* aCall);
-
-  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:
-  CallEvent()
-  : nsDOMEvent(nullptr, nullptr)
-  { }
-
-  ~CallEvent()
-  { }
-};
-
-END_TELEPHONY_NAMESPACE
-
-#endif // mozilla_dom_telephony_callevent_h__
--- a/dom/telephony/Makefile.in
+++ b/dom/telephony/Makefile.in
@@ -16,17 +16,16 @@ LIBXUL_LIBRARY   = 1
 FORCE_STATIC_LIB = 1
 FAIL_ON_WARNINGS := 1
 
 include $(topsrcdir)/dom/dom-config.mk
 
 CPPSRCS = \
   Telephony.cpp \
   TelephonyCall.cpp \
-  CallEvent.cpp \
   Voicemail.cpp \
   VoicemailEvent.cpp \
   $(NULL)
 
 XPIDLSRCS = \
   nsIDOMNavigatorTelephony.idl \
   nsIDOMTelephony.idl \
   nsIDOMTelephonyCall.idl \
--- a/dom/telephony/Telephony.cpp
+++ b/dom/telephony/Telephony.cpp
@@ -2,30 +2,30 @@
 /* vim: set ts=2 et sw=2 tw=40: */
 /* 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 "Telephony.h"
 
 #include "nsIURI.h"
-#include "nsIURL.h"
+#include "nsIDOMCallEvent.h"
 #include "nsPIDOMWindow.h"
+#include "nsIPermissionManager.h"
 
+#include "GeneratedEvents.h"
 #include "jsapi.h"
-#include "nsIPermissionManager.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsNetUtil.h"
+#include "nsRadioInterfaceLayer.h"
 #include "nsServiceManagerUtils.h"
-#include "nsRadioInterfaceLayer.h"
 #include "nsTArrayHelpers.h"
 
-#include "CallEvent.h"
 #include "TelephonyCall.h"
 
 USING_TELEPHONY_NAMESPACE
 
 namespace {
 
 typedef nsAutoTArray<Telephony*, 2> TelephonyList;
 
@@ -116,33 +116,26 @@ Telephony::NoteDialedCallFromOtherInstan
 {
   // We don't need to hang on to this call object, it is held alive by mCalls.
   nsRefPtr<TelephonyCall> call = CreateNewDialingCall(aNumber);
 }
 
 nsresult
 Telephony::NotifyCallsChanged(TelephonyCall* aCall)
 {
-  nsRefPtr<CallEvent> event = CallEvent::Create(aCall);
-  NS_ASSERTION(event, "This should never fail!");
-
   if (aCall->CallState() == nsIRadioInterfaceLayer::CALL_STATE_DIALING ||
       aCall->CallState() == nsIRadioInterfaceLayer::CALL_STATE_ALERTING ||
       aCall->CallState() == nsIRadioInterfaceLayer::CALL_STATE_CONNECTED) {
     NS_ASSERTION(!mActiveCall, "Already have an active call!");
     mActiveCall = aCall;
   } else if (mActiveCall && mActiveCall->CallIndex() == aCall->CallIndex()) {
     mActiveCall = nullptr;
   }
 
-  nsresult rv =
-    event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("callschanged"));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return NS_OK;
+  return DispatchCallEvent(NS_LITERAL_STRING("callschanged"), aCall);
 }
 
 nsresult
 Telephony::DialInternal(bool isEmergency,
                         const nsAString& aNumber,
                         nsIDOMTelephonyCall** aResult)
 {
   NS_ENSURE_ARG(!aNumber.IsEmpty());
@@ -406,22 +399,17 @@ Telephony::CallStateChanged(uint32_t aCa
 
   nsRefPtr<TelephonyCall> call =
     TelephonyCall::Create(this, aNumber, aCallState, aCallIndex);
   NS_ASSERTION(call, "This should never fail!");
 
   NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!");
 
   if (aCallState == nsIRadioInterfaceLayer::CALL_STATE_INCOMING) {
-    // Dispatch incoming event.
-    nsRefPtr<CallEvent> event = CallEvent::Create(call);
-    NS_ASSERTION(event, "This should never fail!");
-
-    nsresult rv =
-      event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("incoming"));
+    nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("incoming"), call);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState,
@@ -480,16 +468,34 @@ Telephony::NotifyError(int32_t aCallInde
 
   // Set the call state to 'disconnected' and remove it from the calls list.
   callToNotify->NotifyError(aError);
 
   return NS_OK;
 }
 
 nsresult
+Telephony::DispatchCallEvent(const nsAString& aType,
+                             nsIDOMTelephonyCall* aCall)
+{
+  MOZ_ASSERT(aCall);
+
+  nsCOMPtr<nsIDOMEvent> event;
+  NS_NewDOMCallEvent(getter_AddRefs(event), nullptr, nullptr);
+  NS_ASSERTION(event, "This should never fail!");
+
+  nsCOMPtr<nsIDOMCallEvent> callEvent = do_QueryInterface(event);
+  MOZ_ASSERT(callEvent);
+  nsresult rv = callEvent->InitCallEvent(aType, false, false, aCall);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return DispatchTrustedEvent(callEvent);
+}
+
+nsresult
 NS_NewTelephony(nsPIDOMWindow* aWindow, nsIDOMTelephony** aTelephony)
 {
   NS_ASSERTION(aWindow, "Null pointer!");
 
   nsPIDOMWindow* innerWindow = aWindow->IsInnerWindow() ?
     aWindow :
     aWindow->GetCurrentInnerWindow();
 
--- a/dom/telephony/Telephony.h
+++ b/dom/telephony/Telephony.h
@@ -95,16 +95,20 @@ private:
   nsresult
   NotifyCallsChanged(TelephonyCall* aCall);
 
   nsresult
   DialInternal(bool isEmergency,
                const nsAString& aNumber,
                nsIDOMTelephonyCall** aResult);
 
+  nsresult
+  DispatchCallEvent(const nsAString& aType,
+                    nsIDOMTelephonyCall* aCall);
+
   class RILTelephonyCallback : public nsIRILTelephonyCallback
   {
     Telephony* mTelephony;
 
   public:
     NS_DECL_ISUPPORTS
     NS_FORWARD_NSIRILTELEPHONYCALLBACK(mTelephony->)
 
--- a/dom/telephony/TelephonyCall.cpp
+++ b/dom/telephony/TelephonyCall.cpp
@@ -1,21 +1,22 @@
 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
 /* vim: set ts=2 et sw=2 tw=40: */
 /* 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 "TelephonyCall.h"
 
-#include "nsDOMClassInfo.h"
+#include "nsIDOMCallEvent.h"
 
-#include "CallEvent.h"
+#include "DOMError.h"
+#include "GeneratedEvents.h"
+#include "nsDOMClassInfo.h"
 #include "Telephony.h"
-#include "DOMError.h"
 
 USING_TELEPHONY_NAMESPACE
 
 // static
 already_AddRefed<TelephonyCall>
 TelephonyCall::Create(Telephony* aTelephony, const nsAString& aNumber,
                       uint16_t aCallState, uint32_t aCallIndex)
 {
@@ -93,54 +94,63 @@ TelephonyCall::ChangeStateInternal(uint1
     mTelephony->RemoveCall(this);
     mLive = false;
   } else if (!mLive) {
     mTelephony->AddCall(this);
     mLive = true;
   }
 
   if (aFireEvents) {
-    nsRefPtr<CallEvent> event = CallEvent::Create(this);
-    NS_ASSERTION(event, "This should never fail!");
-
-    if (NS_FAILED(event->Dispatch(ToIDOMEventTarget(),
-                                  NS_LITERAL_STRING("statechange")))) {
-      NS_WARNING("Failed to dispatch statechange event!");
+    nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("statechange"), this);
+    if (NS_FAILED(rv)) {
+      NS_WARNING("Failed to dispatch specific event!");
     }
 
     // This can change if the statechange handler called back here... Need to
     // figure out something smarter.
     if (mCallState == aCallState) {
-      event = CallEvent::Create(this);
-      NS_ASSERTION(event, "This should never fail!");
-
-      if (NS_FAILED(event->Dispatch(ToIDOMEventTarget(), stateString))) {
+      rv = DispatchCallEvent(stateString, this);
+      if (NS_FAILED(rv)) {
         NS_WARNING("Failed to dispatch specific event!");
       }
     }
   }
 }
 
+nsresult
+TelephonyCall::DispatchCallEvent(const nsAString& aType,
+                                 nsIDOMTelephonyCall* aCall)
+{
+  MOZ_ASSERT(aCall);
+
+  nsCOMPtr<nsIDOMEvent> event;
+  NS_NewDOMCallEvent(getter_AddRefs(event), nullptr, nullptr);
+  NS_ASSERTION(event, "This should never fail!");
+
+  nsCOMPtr<nsIDOMCallEvent> callEvent = do_QueryInterface(event);
+  MOZ_ASSERT(callEvent);
+  nsresult rv = callEvent->InitCallEvent(aType, false, false, aCall);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return DispatchTrustedEvent(callEvent);
+}
+
 void
 TelephonyCall::NotifyError(const nsAString& aError)
 {
   // Set the error string
   NS_ASSERTION(!mError, "Already have an error?");
 
   mError = DOMError::CreateWithName(aError);
 
   // Do the state transitions
   ChangeStateInternal(nsIRadioInterfaceLayer::CALL_STATE_DISCONNECTED, true);
 
-  // Notify the error event
-  nsRefPtr<CallEvent> event = CallEvent::Create(this);
-  NS_ASSERTION(event, "This should never fail!");
-
-  if (NS_FAILED(event->Dispatch(ToIDOMEventTarget(),
-                                NS_LITERAL_STRING("error")))) {
+  nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("error"), this);
+  if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch error event!");
   }
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED_1(TelephonyCall,
                                      nsDOMEventTargetHelper,
                                      mTelephony)
 
@@ -210,35 +220,35 @@ TelephonyCall::HangUp()
 
 NS_IMETHODIMP
 TelephonyCall::Hold()
 {
   if (mCallState != nsIRadioInterfaceLayer::CALL_STATE_CONNECTED) {
     NS_WARNING("Hold non-connected call ignored!");
     return NS_OK;
   }
-  
+
   nsresult rv = mTelephony->RIL()->HoldCall(mCallIndex);
   NS_ENSURE_SUCCESS(rv,rv);
-  
+
   ChangeStateInternal(nsIRadioInterfaceLayer::CALL_STATE_HOLDING, true);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelephonyCall::Resume()
 {
   if (mCallState != nsIRadioInterfaceLayer::CALL_STATE_HELD) {
     NS_WARNING("Resume non-held call ignored!");
     return NS_OK;
   }
-  
+
   nsresult rv = mTelephony->RIL()->ResumeCall(mCallIndex);
   NS_ENSURE_SUCCESS(rv,rv);
-  
+
   ChangeStateInternal(nsIRadioInterfaceLayer::CALL_STATE_RESUMING, true);
   return NS_OK;
 }
 
 NS_IMPL_EVENT_HANDLER(TelephonyCall, statechange)
 NS_IMPL_EVENT_HANDLER(TelephonyCall, dialing)
 NS_IMPL_EVENT_HANDLER(TelephonyCall, alerting)
 NS_IMPL_EVENT_HANDLER(TelephonyCall, busy)
--- a/dom/telephony/TelephonyCall.h
+++ b/dom/telephony/TelephonyCall.h
@@ -95,13 +95,17 @@ private:
     mCallState(nsIRadioInterfaceLayer::CALL_STATE_UNKNOWN), mLive(false), mOutgoing(false)
   { }
 
   ~TelephonyCall()
   { }
 
   void
   ChangeStateInternal(uint16_t aCallState, bool aFireEvents);
+
+  nsresult
+  DispatchCallEvent(const nsAString& aType,
+                    nsIDOMTelephonyCall* aCall);
 };
 
 END_TELEPHONY_NAMESPACE
 
 #endif // mozilla_dom_telephony_telephonycall_h__
--- a/dom/telephony/nsIDOMCallEvent.idl
+++ b/dom/telephony/nsIDOMCallEvent.idl
@@ -3,13 +3,22 @@
 /* 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"
 
 interface nsIDOMTelephonyCall;
 
-[scriptable, builtinclass, uuid(21c233f9-721b-4985-bb2b-585f978ceee5)]
+[scriptable, builtinclass, uuid(476aacec-661e-44ec-80b4-4b7292b927b5)]
 interface nsIDOMCallEvent : nsIDOMEvent
 {
   readonly attribute nsIDOMTelephonyCall call;
+  [noscript] void initCallEvent(in DOMString aType,
+                                in boolean aCanBubble,
+                                in boolean aCancelable,
+                                in nsIDOMTelephonyCall aCall);
 };
+
+dictionary CallEventInit : EventInit
+{
+  nsIDOMTelephonyCall call;
+};
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -23,16 +23,17 @@ simple_events = [
     'DeviceOrientationEvent',
     'DeviceLightEvent',
     'MozApplicationEvent',
 #ifdef MOZ_B2G_BT
     'BluetoothDeviceEvent',
     'BluetoothDeviceAddressEvent',
 #endif
 #ifdef MOZ_B2G_RIL
+    'CallEvent',
     'ICCCardLockErrorEvent',
     'MozWifiStatusChangeEvent',
     'MozWifiConnectionInfoEvent',
     'MozCellBroadcastEvent',
 #endif
     'DeviceStorageChangeEvent',
     'PopupBlockedEvent'
   ]