Bug 1000670 - part 3 - DOM: create and dispatch clirmodechange event. r=smaug
authorHsin-Yi Tsai <htsai@mozilla.com>
Thu, 24 Apr 2014 14:37:49 +0800
changeset 180989 c931c07c3232cf8fc1caee425a1a7d311388cf01
parent 180988 193cc0df5329aa0bfec4cf444e17e2bfdda17887
child 180990 02e01aa0c58a3cc4f984db3e772c791f860373dd
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerssmaug
bugs1000670
milestone31.0a1
Bug 1000670 - part 3 - DOM: create and dispatch clirmodechange event. r=smaug
content/base/src/nsGkAtomList.h
dom/events/test/test_all_synthetic_events.html
dom/mobileconnection/src/MobileConnection.cpp
dom/tests/mochitest/general/test_interfaces.html
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -671,16 +671,17 @@ GK_ATOM(oncached, "oncached")
 GK_ATOM(oncallschanged, "oncallschanged")
 GK_ATOM(oncardstatechange, "oncardstatechange")
 GK_ATOM(oncfstatechange, "oncfstatechange")
 GK_ATOM(onchange, "onchange")
 GK_ATOM(onchargingchange, "onchargingchange")
 GK_ATOM(onchargingtimechange, "onchargingtimechange")
 GK_ATOM(onchecking, "onchecking")
 GK_ATOM(onclick, "onclick")
+GK_ATOM(onclirmodechange, "onclirmodechange")
 GK_ATOM(onclose, "onclose")
 GK_ATOM(oncommand, "oncommand")
 GK_ATOM(oncommandupdate, "oncommandupdate")
 GK_ATOM(oncomplete, "oncomplete")
 GK_ATOM(oncompositionend, "oncompositionend")
 GK_ATOM(oncompositionstart, "oncompositionstart")
 GK_ATOM(oncompositionupdate, "oncompositionupdate")
 GK_ATOM(onconnect, "onconnect")
--- a/dom/events/test/test_all_synthetic_events.html
+++ b/dom/events/test/test_all_synthetic_events.html
@@ -224,16 +224,20 @@ const kEventConstructors = {
   MozApplicationEvent:                       { create: function (aName, aProps) {
                                                          return new MozApplicationEvent(aName, aProps);
                                                        },
                                              },
   MozCellBroadcastEvent:                     { create: function (aName, aProps) {
                                                           return new MozCellBroadcastEvent(aName, aProps);
                                                        },
                                              },
+  MozClirModeEvent:                          { create: function (aName, aProps) {
+                                                         return new MozClirModeEvent(aName, aProps);
+                                                       },
+                                             },
   MozContactChangeEvent:                     { create: function (aName, aProps) {
                                                          return new MozContactChangeEvent(aName, aProps);
                                                        },
                                              },
   MozEmergencyCbModeEvent:                   { create: function (aName, aProps) {
                                                           return new MozEmergencyCbModeEvent(aName, aProps);
                                                        },
                                              },
--- a/dom/mobileconnection/src/MobileConnection.cpp
+++ b/dom/mobileconnection/src/MobileConnection.cpp
@@ -2,16 +2,17 @@
  * 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/MobileConnection.h"
 
 #include "GeneratedEvents.h"
 #include "mozilla/dom/CFStateChangeEvent.h"
 #include "mozilla/dom/DataErrorEvent.h"
+#include "mozilla/dom/MozClirModeEvent.h"
 #include "mozilla/dom/MozEmergencyCbModeEvent.h"
 #include "mozilla/dom/MozOtaStatusEvent.h"
 #include "mozilla/dom/USSDReceivedEvent.h"
 #include "mozilla/Preferences.h"
 #include "nsIDOMClassInfo.h"
 #include "nsIDOMDOMRequest.h"
 #include "nsIPermissionManager.h"
 #include "nsIVariant.h"
@@ -74,16 +75,17 @@ NS_IMPL_EVENT_HANDLER(MobileConnection, 
 NS_IMPL_EVENT_HANDLER(MobileConnection, datachange)
 NS_IMPL_EVENT_HANDLER(MobileConnection, ussdreceived)
 NS_IMPL_EVENT_HANDLER(MobileConnection, dataerror)
 NS_IMPL_EVENT_HANDLER(MobileConnection, cfstatechange)
 NS_IMPL_EVENT_HANDLER(MobileConnection, emergencycbmodechange)
 NS_IMPL_EVENT_HANDLER(MobileConnection, otastatuschange)
 NS_IMPL_EVENT_HANDLER(MobileConnection, iccchange)
 NS_IMPL_EVENT_HANDLER(MobileConnection, radiostatechange)
+NS_IMPL_EVENT_HANDLER(MobileConnection, clirmodechange)
 
 MobileConnection::MobileConnection(uint32_t aClientId)
 : mClientId(aClientId)
 {
   mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   mWindow = nullptr;
 
   // Not being able to acquire the provider isn't fatal since we check
@@ -728,8 +730,26 @@ NS_IMETHODIMP
 MobileConnection::NotifyRadioStateChanged()
 {
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   return DispatchTrustedEvent(NS_LITERAL_STRING("radiostatechange"));
 }
+
+NS_IMETHODIMP
+MobileConnection::NotifyClirModeChanged(uint32_t aMode)
+{
+  if (!CheckPermission("mobileconnection")) {
+    return NS_OK;
+  }
+
+  MozClirModeEventInit init;
+  init.mBubbles = false;
+  init.mCancelable = false;
+  init.mMode = aMode;
+
+  nsRefPtr<MozClirModeEvent> event =
+    MozClirModeEvent::Constructor(this, NS_LITERAL_STRING("clirmodechange"), init);
+
+  return DispatchTrustedEvent(event);
+}
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -615,16 +615,18 @@ var interfaceNamesInGlobalScope =
     {name: "MozActivity", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozApplicationEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozCellBroadcast", b2g: true, pref: "dom.cellbroadcast.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozCellBroadcastEvent", b2g: true, pref: "dom.cellbroadcast.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
+    {name: "MozClirModeEvent", b2g: true, pref: "dom.mobileconnection.enabled"},
+// IMPORTANT: Do not change this list without review from a DOM peer!
     "mozContact",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozContactChangeEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozCSSKeyframeRule",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozCSSKeyframesRule",
 // IMPORTANT: Do not change this list without review from a DOM peer!