Merge m-c to fx-team.
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 27 Feb 2014 17:35:05 -0500
changeset 171530 46ff4f074276035d8add88e6421c14d901623d6f
parent 171529 d4c7d7ed21969d64a1942bac871464bd32548a41 (current diff)
parent 171445 c3ce3b51c881501b62527439ddd70016c7ed133c (diff)
child 171531 b03e0515efaf32651e5bace907aa30033c271c58
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
milestone30.0a1
Merge m-c to fx-team.
content/base/src/nsDOMLists.cpp
content/base/src/nsDOMLists.h
dom/events/nsDOMDeviceMotionEvent.cpp
dom/events/nsDOMDeviceMotionEvent.h
dom/events/nsDOMDragEvent.cpp
dom/events/nsDOMDragEvent.h
dom/events/nsDOMFocusEvent.cpp
dom/events/nsDOMFocusEvent.h
dom/events/nsDOMKeyboardEvent.cpp
dom/events/nsDOMKeyboardEvent.h
dom/events/nsDOMMessageEvent.cpp
dom/events/nsDOMMessageEvent.h
dom/events/nsDOMMouseEvent.cpp
dom/events/nsDOMMouseEvent.h
dom/events/nsDOMMouseScrollEvent.cpp
dom/events/nsDOMMouseScrollEvent.h
dom/events/nsDOMMutationEvent.cpp
dom/events/nsDOMMutationEvent.h
dom/events/nsDOMSimpleGestureEvent.cpp
dom/events/nsDOMSimpleGestureEvent.h
dom/interfaces/core/nsIDOMDOMStringList.idl
js/src/jit-test/tests/ion/testFloat32-trigo.js
toolkit/themes/osx/global/icons/question-mark.png
--- a/accessible/public/nsIAccessible.idl
+++ b/accessible/public/nsIAccessible.idl
@@ -3,17 +3,16 @@
  * 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 "nsIArray.idl"
 
 interface nsIPersistentProperties;
 interface nsIDOMCSSPrimitiveValue;
-interface nsIDOMDOMStringList;
 interface nsIDOMNode;
 interface nsIAccessibleDocument;
 interface nsIAccessibleRelation;
 
 /**
  * A cross-platform interface that supports platform-specific 
  * accessibility APIs like MSAA and ATK. Contains the sum of what's needed
  * to support IAccessible as well as ATK's generic accessibility objects.
--- a/accessible/public/nsIAccessibleRetrieval.idl
+++ b/accessible/public/nsIAccessibleRetrieval.idl
@@ -5,17 +5,16 @@
 
 #include "nsISupports.idl"
 
 interface nsIDOMNode;
 interface nsIAccessible;
 interface nsIWeakReference;
 interface nsIPresShell;
 interface nsIDOMWindow;
-interface nsIDOMDOMStringList;
 interface nsIAccessiblePivot;
 
 /**
  * An interface for in-process accessibility clients wishing to get an
  * nsIAccessible for a given DOM node.  More documentation at:
  *   http://www.mozilla.org/projects/ui/accessibility
  */
 [scriptable, uuid(17f86615-1a3d-4021-b227-3a2ef5cbffd8)]
@@ -43,18 +42,18 @@ interface nsIAccessibleRetrieval : nsISu
   AString getStringRole(in unsigned long aRole);
 
    /**
     * Returns list which contains accessible states as a strings.
     *
     * @param aStates - accessible states.
     * @param aExtraStates - accessible extra states.
     */
-  nsIDOMDOMStringList getStringStates(in unsigned long aStates,
-                                      in unsigned long aExtraStates);
+  nsISupports getStringStates(in unsigned long aStates,
+                              in unsigned long aExtraStates);
 
   /**
    * Get the type of accessible event as a string.
    *
    * @param aEventType - the accessible event type constant
    * @return - accessible event type presented as human readable string
    */
   AString getStringEventType(in unsigned long aEventType);
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -59,16 +59,17 @@
 #include "nsObjectFrame.h"
 #include "nsSVGPathGeometryFrame.h"
 #include "nsTreeBodyFrame.h"
 #include "nsTreeColumns.h"
 #include "nsTreeUtils.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsXBLBinding.h"
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "nsDeckFrame.h"
 
 #ifdef MOZ_XUL
 #include "XULAlertAccessible.h"
 #include "XULColorPickerAccessible.h"
 #include "XULComboboxAccessible.h"
@@ -82,16 +83,17 @@
 #endif
 
 #if defined(XP_WIN) || defined(MOZ_ACCESSIBILITY_ATK)
 #include "nsNPAPIPluginInstance.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::a11y;
+using namespace mozilla::dom;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Statics
 ////////////////////////////////////////////////////////////////////////////////
 
 /**
  * Return true if the element must be accessible.
  */
@@ -570,20 +572,19 @@ nsAccessibilityService::GetStringRole(ui
       return NS_OK;
   }
 
 #undef ROLE
 }
 
 NS_IMETHODIMP
 nsAccessibilityService::GetStringStates(uint32_t aState, uint32_t aExtraState,
-                                        nsIDOMDOMStringList **aStringStates)
+                                        nsISupports **aStringStates)
 {
-  nsAccessibleDOMStringList* stringStates = new nsAccessibleDOMStringList();
-  NS_ENSURE_TRUE(stringStates, NS_ERROR_OUT_OF_MEMORY);
+  nsRefPtr<DOMStringList> stringStates = new DOMStringList();
 
   uint64_t state = nsAccUtils::To64State(aState, aExtraState);
 
   // states
   if (state & states::UNAVAILABLE)
     stringStates->Add(NS_LITERAL_STRING("unavailable"));
   if (state & states::SELECTED)
     stringStates->Add(NS_LITERAL_STRING("selected"));
@@ -676,22 +677,20 @@ nsAccessibilityService::GetStringStates(
   if (state & states::ENABLED)
     stringStates->Add(NS_LITERAL_STRING("enabled"));
   if (state & states::SENSITIVE)
     stringStates->Add(NS_LITERAL_STRING("sensitive"));
   if (state & states::EXPANDABLE)
     stringStates->Add(NS_LITERAL_STRING("expandable"));
 
   //unknown states
-  uint32_t stringStatesLength = 0;
-  stringStates->GetLength(&stringStatesLength);
-  if (!stringStatesLength)
+  if (!stringStates->Length())
     stringStates->Add(NS_LITERAL_STRING("unknown"));
 
-  NS_ADDREF(*aStringStates = stringStates);
+  stringStates.forget(aStringStates);
   return NS_OK;
 }
 
 // nsIAccessibleRetrieval::getStringEventType()
 NS_IMETHODIMP
 nsAccessibilityService::GetStringEventType(uint32_t aEventType,
                                            nsAString& aString)
 {
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -644,43 +644,8 @@ nsCoreUtils::IsWhitespaceString(const ns
   aString.BeginReading(iterBegin);
   aString.EndReading(iterEnd);
 
   while (iterBegin != iterEnd && IsWhitespace(*iterBegin))
     ++iterBegin;
 
   return iterBegin == iterEnd;
 }
-
-
-////////////////////////////////////////////////////////////////////////////////
-// nsAccessibleDOMStringList
-////////////////////////////////////////////////////////////////////////////////
-
-NS_IMPL_ISUPPORTS1(nsAccessibleDOMStringList, nsIDOMDOMStringList)
-
-NS_IMETHODIMP
-nsAccessibleDOMStringList::Item(uint32_t aIndex, nsAString& aResult)
-{
-  if (aIndex >= mNames.Length())
-    SetDOMStringToNull(aResult);
-  else
-    aResult = mNames.ElementAt(aIndex);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAccessibleDOMStringList::GetLength(uint32_t* aLength)
-{
-  *aLength = mNames.Length();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAccessibleDOMStringList::Contains(const nsAString& aString, bool* aResult)
-{
-  *aResult = mNames.Contains(aString);
-
-  return NS_OK;
-}
-
--- a/accessible/src/base/nsCoreUtils.h
+++ b/accessible/src/base/nsCoreUtils.h
@@ -5,17 +5,16 @@
 
 #ifndef nsCoreUtils_h_
 #define nsCoreUtils_h_
 
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 
-#include "nsIDOMDOMStringList.h"
 #include "nsPoint.h"
 #include "nsTArray.h"
 
 class nsRange;
 class nsIBoxObject;
 class nsIFrame;
 class nsIDocShell;
 class nsITreeColumn;
@@ -309,31 +308,10 @@ public:
    */
   static bool IsWhitespace(char16_t aChar)
   {
     return aChar == ' ' || aChar == '\n' ||
       aChar == '\r' || aChar == '\t' || aChar == 0xa0;
   }
 };
 
-
-/**
- * nsIDOMDOMStringList implementation.
- */
-class nsAccessibleDOMStringList : public nsIDOMDOMStringList
-{
-public:
-  nsAccessibleDOMStringList() {}
-  virtual ~nsAccessibleDOMStringList() {}
-
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMDOMSTRINGLIST
-
-  bool Add(const nsAString& aName) {
-    return mNames.AppendElement(aName) != nullptr;
-  }
-
-private:
-  nsTArray<nsString> mNames;
-};
-
 #endif
 
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -1675,17 +1675,17 @@ double
 Accessible::MinValue() const
 {
   return AttrNumericValue(nsGkAtoms::aria_valuemin);
 }
 
 double
 Accessible::Step() const
 {
-  return UnspecifiedNaN(); // no mimimum increment (step) in ARIA.
+  return UnspecifiedNaN<double>(); // no mimimum increment (step) in ARIA.
 }
 
 double
 Accessible::CurValue() const
 {
   return AttrNumericValue(nsGkAtoms::aria_valuenow);
 }
 
@@ -3079,25 +3079,25 @@ Accessible::GetSiblingAtOffset(int32_t a
 
   return child;
 }
 
 double
 Accessible::AttrNumericValue(nsIAtom* aAttr) const
 {
   if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue)
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
 
   nsAutoString attrValue;
   if (!mContent->GetAttr(kNameSpaceID_None, aAttr, attrValue))
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
 
   nsresult error = NS_OK;
   double value = attrValue.ToDouble(&error);
-  return NS_FAILED(error) ? UnspecifiedNaN() : value;
+  return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
 }
 
 uint32_t
 Accessible::GetActionRule()
 {
   if (!HasOwnContent() || (InteractiveState() & states::UNAVAILABLE))
     return eNoAction;
 
--- a/accessible/src/generic/FormControlAccessible.cpp
+++ b/accessible/src/generic/FormControlAccessible.cpp
@@ -139,21 +139,21 @@ double
 ProgressMeterAccessible<Max>::CurValue() const
 {
   double value = LeafAccessible::CurValue();
   if (!IsNaN(value))
     return value;
 
   nsAutoString attrValue;
   if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue))
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
 
   nsresult error = NS_OK;
   value = attrValue.ToDouble(&error);
-  return NS_FAILED(error) ? UnspecifiedNaN() : value;
+  return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
 }
 
 template<int Max>
 bool
 ProgressMeterAccessible<Max>::SetCurValue(double aValue)
 {
   return false; // progress meters are readonly.
 }
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -192,18 +192,19 @@ this.AccessFu = {
       else
         this._disable();
     } catch (x) {
       dump('Error ' + x.message + ' ' + x.fileName + ':' + x.lineNumber);
     }
   },
 
   receiveMessage: function receiveMessage(aMessage) {
-    if (Logger.logLevel >= Logger.DEBUG)
-      Logger.debug('Recieved', aMessage.name, JSON.stringify(aMessage.json));
+    Logger.debug(() => {
+      return ['Recieved', aMessage.name, JSON.stringify(aMessage.json)];
+    });
 
     switch (aMessage.name) {
       case 'AccessFu:Ready':
         let mm = Utils.getMessageManager(aMessage.target);
         if (this._enabled) {
           mm.sendAsyncMessage('AccessFu:Start',
                               {method: 'start', buildApp: Utils.MozBuildApp});
         }
--- a/accessible/src/jsat/EventManager.jsm
+++ b/accessible/src/jsat/EventManager.jsm
@@ -84,16 +84,20 @@ this.EventManager.prototype = {
     } catch (x) {
       // contentScope is dead.
     } finally {
       this._started = false;
     }
   },
 
   handleEvent: function handleEvent(aEvent) {
+    Logger.debug(() => {
+      return ['DOMEvent', aEvent.type];
+    });
+
     try {
       switch (aEvent.type) {
       case 'wheel':
       {
         let attempts = 0;
         let vc = Utils.getVirtualCursor(this.contentScope.content.document);
         let intervalId = this.contentScope.content.setInterval(() => {
           if (!Utils.isAliveAndVisible(vc.position, true)) {
@@ -124,19 +128,20 @@ this.EventManager.prototype = {
       }
       }
     } catch (x) {
       Logger.logException(x, 'Error handling DOM event');
     }
   },
 
   handleAccEvent: function handleAccEvent(aEvent) {
-    if (Logger.logLevel >= Logger.DEBUG)
-      Logger.debug('A11yEvent', Logger.eventToString(aEvent),
-                   Logger.accessibleToString(aEvent.accessible));
+    Logger.debug(() => {
+      return ['A11yEvent', Logger.eventToString(aEvent),
+              Logger.accessibleToString(aEvent.accessible)];
+    });
 
     // Don't bother with non-content events in firefox.
     if (Utils.MozBuildApp == 'browser' &&
         aEvent.eventType != Events.VIRTUALCURSOR_CHANGED &&
         // XXX Bug 442005 results in DocAccessible::getDocType returning
         // NS_ERROR_FAILURE. Checking for aEvent.accessibleDocument.docType ==
         // 'window' does not currently work.
         (aEvent.accessibleDocument.DOMDocument.doctype &&
--- a/accessible/src/jsat/Utils.jsm
+++ b/accessible/src/jsat/Utils.jsm
@@ -346,17 +346,18 @@ this.Logger = {
   logLevel: 1, // INFO;
 
   test: false,
 
   log: function log(aLogLevel) {
     if (aLogLevel < this.logLevel)
       return;
 
-    let message = Array.prototype.slice.call(arguments, 1).join(' ');
+    let args = Array.prototype.slice.call(arguments, 1);
+    let message = (typeof(args[0]) === 'function' ? args[0]() : args).join(' ');
     message = '[' + Utils.ScriptName + '] ' + this._LEVEL_NAMES[aLogLevel] +
       ' ' + message + '\n';
     dump(message);
     // Note: used for testing purposes. If |this.test| is true, also log to
     // the console service.
     if (this.test) {
       try {
         Services.console.logStringMessage(message);
--- a/accessible/src/jsat/content-script.js
+++ b/accessible/src/jsat/content-script.js
@@ -111,19 +111,19 @@ function moveToPoint(aMessage) {
     vc.moveToPoint(rule, details.x * dpr, details.y * dpr, true);
     forwardToChild(aMessage, moveToPoint, vc.position);
   } catch (x) {
     Logger.logException(x, 'Failed move to point');
   }
 }
 
 function showCurrent(aMessage) {
-  if (Logger.logLevel >= Logger.DEBUG) {
-    Logger.debug(aMessage.name, JSON.stringify(aMessage.json, null, ' '));
-  }
+  Logger.debug(() => {
+    return [aMessage.name, JSON.stringify(aMessage.json, null, ' ')];
+  });
 
   let vc = Utils.getVirtualCursor(content.document);
 
   if (!forwardToChild(vc, showCurrent, aMessage)) {
     if (!vc.position && aMessage.json.move) {
       vc.moveFirst(TraversalRules.Simple);
     } else {
       sendAsyncMessage('AccessFu:Present', Presentation.pivotChanged(
@@ -142,20 +142,20 @@ function forwardToParent(aMessage) {
 
 function forwardToChild(aMessage, aListener, aVCPosition) {
   let acc = aVCPosition || Utils.getVirtualCursor(content.document).position;
 
   if (!Utils.isAliveAndVisible(acc) || acc.role != Roles.INTERNAL_FRAME) {
     return false;
   }
 
-  if (Logger.logLevel >= Logger.DEBUG) {
-    Logger.debug('forwardToChild', Logger.accessibleToString(acc),
-                 aMessage.name, JSON.stringify(aMessage.json, null, '  '));
-  }
+  Logger.debug(() => {
+    return ['forwardToChild', Logger.accessibleToString(acc),
+            aMessage.name, JSON.stringify(aMessage.json, null, '  ')];
+  });
 
   let mm = Utils.getMessageManager(acc.DOMNode);
 
   if (aListener) {
     mm.addMessageListener(aMessage.name, aListener);
   }
 
   // XXX: This is a silly way to make a deep copy
--- a/accessible/src/xul/XULSliderAccessible.cpp
+++ b/accessible/src/xul/XULSliderAccessible.cpp
@@ -73,17 +73,17 @@ XULSliderAccessible::ActionCount()
 
 NS_IMETHODIMP
 XULSliderAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
   NS_ENSURE_ARG(aIndex == 0);
 
-  aName.AssignLiteral("activate"); 
+  aName.AssignLiteral("activate");
   return NS_OK;
 }
 
 NS_IMETHODIMP
 XULSliderAccessible::DoAction(uint8_t aIndex)
 {
   NS_ENSURE_ARG(aIndex == 0);
 
@@ -182,21 +182,21 @@ XULSliderAccessible::SetSliderAttr(nsIAt
 }
 
 double
 XULSliderAccessible::GetSliderAttr(nsIAtom* aName) const
 {
   nsAutoString attrValue;
   nsresult rv = GetSliderAttr(aName, attrValue);
   if (NS_FAILED(rv))
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
 
   nsresult error = NS_OK;
   double value = attrValue.ToDouble(&error);
-  return NS_FAILED(error) ? UnspecifiedNaN() : value;
+  return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
 }
 
 bool
 XULSliderAccessible::SetSliderAttr(nsIAtom* aName, double aValue)
 {
   nsAutoString value;
   value.AppendFloat(aValue);
 
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -857,25 +857,22 @@ pref("media.webspeech.synth.enabled", tr
 
 // Downloads API
 pref("dom.mozDownloads.enabled", true);
 pref("dom.downloads.max_retention_days", 7);
 
 // Inactivity time in milliseconds after which we shut down the OS.File worker.
 pref("osfile.reset_worker_delay", 5000);
 
-// The URL of the Firefox Accounts auth server backend
-pref("identity.fxaccounts.auth.uri", "https://api-accounts.dev.lcip.org/v1");
-
 // APZC preferences.
 //
 // Gaia relies heavily on scroll events for now, so lets fire them
 // more often than the default value (100).
 pref("apz.asyncscroll.throttle", 40);
-pref("apz.pan_repaint_interval", 40);
+pref("apz.pan_repaint_interval", 16);
 
 // Maximum fling velocity in px/ms.  Slower devices may need to reduce this
 // to avoid checkerboarding.  Note, float value must be set as a string.
 pref("apz.max_velocity_pixels_per_ms", "6.0");
 
 // This preference allows FirefoxOS apps (and content, I think) to force
 // the use of software (instead of hardware accelerated) 2D canvases by
 // creating a context like this:
--- a/b2g/config/emulator-ics/sources.xml
+++ b/b2g/config/emulator-ics/sources.xml
@@ -14,23 +14,23 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="refs/tags/android-4.0.4_r2.1" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="59605a7c026ff06cc1613af3938579b1dddc6cfe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d11f524d00cacf5ba0dfbf25e4aa2158b1c3a036"/>
-  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="022eadd5917615ff00c47eaaafa792b45e9c8a28"/>
+  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="456499c44d1ef39b602ea02e9ed460b6aab85b44"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="52ca41d9fa6ef88e65d9da52e375716c68d48646"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="990ddd9f96fd4bac333d1178e56985d09bb26173"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
   <project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="425f8b5fadf5889834c5acd27d23c9e0b2129c28"/>
   <project name="device/common" path="device/common" revision="42b808b7e93d0619286ae8e59110b176b7732389"/>
   <project name="device/sample" path="device/sample" revision="237bd668d0f114d801a8d6455ef5e02cc3577587"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
   <project name="platform/external/bluetooth/bluez" path="external/bluetooth/bluez" revision="52a1a862a8bac319652b8f82d9541ba40bfa45ce"/>
--- a/b2g/config/emulator-jb/sources.xml
+++ b/b2g/config/emulator-jb/sources.xml
@@ -12,20 +12,20 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="97a5b461686757dbb8ecab2aac5903e41d2e1afe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="52ca41d9fa6ef88e65d9da52e375716c68d48646"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="990ddd9f96fd4bac333d1178e56985d09bb26173"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="905bfa3548eb75cf1792d0d8412b92113bbd4318"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="c3d7efc45414f1b44cd9c479bb2758c91c4707c0"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="5c45f43419d5582949284eee9cef0c43d866e03b"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="3748b4168e7bd8d46457d4b6786003bc6a5223ce"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="9025e50b9d29b3cabbbb21e1dd94d0d13121a17e"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="b89fda71fcd0fa0cf969310e75be3ea33e048b44"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="2e7d5348f35575870b3c7e567a9a9f6d66f8d6c5"/>
--- a/b2g/config/emulator/sources.xml
+++ b/b2g/config/emulator/sources.xml
@@ -14,23 +14,23 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="refs/tags/android-4.0.4_r2.1" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="59605a7c026ff06cc1613af3938579b1dddc6cfe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d11f524d00cacf5ba0dfbf25e4aa2158b1c3a036"/>
-  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="022eadd5917615ff00c47eaaafa792b45e9c8a28"/>
+  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="456499c44d1ef39b602ea02e9ed460b6aab85b44"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="52ca41d9fa6ef88e65d9da52e375716c68d48646"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="990ddd9f96fd4bac333d1178e56985d09bb26173"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
   <project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="425f8b5fadf5889834c5acd27d23c9e0b2129c28"/>
   <project name="device/common" path="device/common" revision="42b808b7e93d0619286ae8e59110b176b7732389"/>
   <project name="device/sample" path="device/sample" revision="237bd668d0f114d801a8d6455ef5e02cc3577587"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
   <project name="platform/external/bluetooth/bluez" path="external/bluetooth/bluez" revision="52a1a862a8bac319652b8f82d9541ba40bfa45ce"/>
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,9 +1,9 @@
 {
     "git": {
         "remote": "", 
         "branch": "", 
         "revision": ""
     }, 
-    "revision": "cba6294f97cb705143dc4581410518901aa4aa59", 
+    "revision": "761b205f4e8b27f766af4eb35b0457b618d97c52", 
     "repo_path": "/integration/gaia-central"
 }
--- a/b2g/config/hamachi/sources.xml
+++ b/b2g/config/hamachi/sources.xml
@@ -12,22 +12,22 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="b2g/ics_strawberry" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="59605a7c026ff06cc1613af3938579b1dddc6cfe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="52ca41d9fa6ef88e65d9da52e375716c68d48646"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="990ddd9f96fd4bac333d1178e56985d09bb26173"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="746bc48f34f5060f90801925dcdd964030c1ab6d"/>
   <project name="platform/development" path="development" revision="2460485184bc8535440bb63876d4e63ec1b4770c"/>
   <project name="device/common" path="device/common" revision="0dcc1e03659db33b77392529466f9eb685cdd3c7"/>
   <project name="device/sample" path="device/sample" revision="68b1cb978a20806176123b959cb05d4fa8adaea4"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
--- a/b2g/config/helix/sources.xml
+++ b/b2g/config/helix/sources.xml
@@ -10,17 +10,17 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <default remote="caf" revision="b2g/ics_strawberry" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="59605a7c026ff06cc1613af3938579b1dddc6cfe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
   <project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>
--- a/b2g/config/inari/sources.xml
+++ b/b2g/config/inari/sources.xml
@@ -14,22 +14,22 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="ics_chocolate_rb4.2" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="59605a7c026ff06cc1613af3938579b1dddc6cfe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="52ca41d9fa6ef88e65d9da52e375716c68d48646"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="990ddd9f96fd4bac333d1178e56985d09bb26173"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="cd5dfce80bc3f0139a56b58aca633202ccaee7f8"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="e0a9ac010df3afaa47ba107192c05ac8b5516435"/>
   <project name="platform/development" path="development" revision="a384622f5fcb1d2bebb9102591ff7ae91fe8ed2d"/>
   <project name="device/common" path="device/common" revision="7c65ea240157763b8ded6154a17d3c033167afb7"/>
   <project name="device/sample" path="device/sample" revision="c328f3d4409db801628861baa8d279fb8855892f"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
--- a/b2g/config/leo/sources.xml
+++ b/b2g/config/leo/sources.xml
@@ -12,22 +12,22 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="b2g/ics_strawberry" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="59605a7c026ff06cc1613af3938579b1dddc6cfe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="52ca41d9fa6ef88e65d9da52e375716c68d48646"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="990ddd9f96fd4bac333d1178e56985d09bb26173"/>
   <project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="575fdbf046e966a5915b1f1e800e5d6ad0ea14c0"/>
   <project name="platform/development" path="development" revision="b1025ec93beeb480caaf3049d171283c3846461d"/>
   <project name="device/common" path="device/common" revision="0dcc1e03659db33b77392529466f9eb685cdd3c7"/>
   <project name="device/sample" path="device/sample" revision="68b1cb978a20806176123b959cb05d4fa8adaea4"/>
--- a/b2g/config/mako/sources.xml
+++ b/b2g/config/mako/sources.xml
@@ -12,20 +12,20 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="97a5b461686757dbb8ecab2aac5903e41d2e1afe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="52ca41d9fa6ef88e65d9da52e375716c68d48646"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="990ddd9f96fd4bac333d1178e56985d09bb26173"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="905bfa3548eb75cf1792d0d8412b92113bbd4318"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="c3d7efc45414f1b44cd9c479bb2758c91c4707c0"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="5c45f43419d5582949284eee9cef0c43d866e03b"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="3748b4168e7bd8d46457d4b6786003bc6a5223ce"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="9025e50b9d29b3cabbbb21e1dd94d0d13121a17e"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="b89fda71fcd0fa0cf969310e75be3ea33e048b44"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="2e7d5348f35575870b3c7e567a9a9f6d66f8d6c5"/>
--- a/b2g/config/wasabi/sources.xml
+++ b/b2g/config/wasabi/sources.xml
@@ -12,22 +12,22 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="ics_chocolate_rb4.2" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="59605a7c026ff06cc1613af3938579b1dddc6cfe">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="3a9fdec737cdfd41206a332970fea833ec4ca13a"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="adaeeb2970c9327e977711c4e18741cfea4baaa6"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="52ca41d9fa6ef88e65d9da52e375716c68d48646"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="990ddd9f96fd4bac333d1178e56985d09bb26173"/>
   <project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="cd5dfce80bc3f0139a56b58aca633202ccaee7f8"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="e0a9ac010df3afaa47ba107192c05ac8b5516435"/>
   <project name="platform/development" path="development" revision="a384622f5fcb1d2bebb9102591ff7ae91fe8ed2d"/>
   <project name="device/common" path="device/common" revision="7c65ea240157763b8ded6154a17d3c033167afb7"/>
   <project name="device/sample" path="device/sample" revision="c328f3d4409db801628861baa8d279fb8855892f"/>
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -799,17 +799,17 @@ pref("browser.safebrowsing.gethashURL", 
 pref("browser.safebrowsing.reportURL", "https://safebrowsing.google.com/safebrowsing/report?");
 pref("browser.safebrowsing.reportGenericURL", "http://%LOCALE%.phish-generic.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportErrorURL", "http://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportPhishURL", "http://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportMalwareURL", "http://%LOCALE%.malware-report.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportMalwareErrorURL", "http://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%");
 
 pref("browser.safebrowsing.malware.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
-pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download&key=%GOOGLE_API_KEY%");
+pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
 
 #ifdef MOZILLA_OFFICIAL
 // Normally the "client ID" sent in updates is appinfo.name, but for
 // official Firefox releases from Mozilla we use a special identifier.
 pref("browser.safebrowsing.id", "navclient-auto-ffox");
 #endif
 
 // Name of the about: page contributed by safebrowsing to handle display of error
@@ -1380,19 +1380,16 @@ pref("identity.fxaccounts.remote.force_a
 // The remote content URL shown for signin in. Must use HTTPS.
 pref("identity.fxaccounts.remote.signin.uri", "https://accounts.firefox.com/signin?service=sync&context=fx_desktop_v1");
 
 // The URL we take the user to when they opt to "manage" their Firefox Account.
 // Note that this will always need to be in the same TLD as the
 // "identity.fxaccounts.remote.uri" pref.
 pref("identity.fxaccounts.settings.uri", "https://accounts.firefox.com/settings");
 
-// The URL of the Firefox Accounts auth server backend
-pref("identity.fxaccounts.auth.uri", "https://api.accounts.firefox.com/v1");
-
 // On GTK, we now default to showing the menubar only when alt is pressed:
 #ifdef MOZ_WIDGET_GTK
 pref("ui.key.menuAccessKeyFocuses", true);
 #endif
 
 
 // Delete HTTP cache v2 data of users that didn't opt-in manually
 pref("browser.cache.auto_delete_cache_version", 1);
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -1356,17 +1356,17 @@ let PlacesControllerDragHelper = {
    */
   getSession: function PCDH__getSession() {
     return this.dragService.getCurrentSession();
   },
 
   /**
    * Extract the first accepted flavor from a list of flavors.
    * @param aFlavors
-   *        The flavors list of type nsIDOMDOMStringList.
+   *        The flavors list of type DOMStringList.
    */
   getFirstValidFlavor: function PCDH_getFirstValidFlavor(aFlavors) {
     for (let i = 0; i < aFlavors.length; i++) {
       if (this.GENERIC_VIEW_DROP_TYPES.indexOf(aFlavors[i]) != -1)
         return aFlavors[i];
     }
 
     // If no supported flavor is found, check if data includes text/plain 
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -630,17 +630,17 @@ public:
   }
   void ReleaseCapture()
   {
     if (nsIPresShell::GetCapturingContent() == this) {
       nsIPresShell::SetCapturingContent(nullptr, 0);
     }
   }
   void MozRequestFullScreen();
-  inline void MozRequestPointerLock();
+  void MozRequestPointerLock();
   Attr* GetAttributeNode(const nsAString& aName);
   already_AddRefed<Attr> SetAttributeNode(Attr& aNewAttr,
                                           ErrorResult& aError);
   already_AddRefed<Attr> RemoveAttributeNode(Attr& aOldAttr,
                                              ErrorResult& aError);
   Attr* GetAttributeNodeNS(const nsAString& aNamespaceURI,
                            const nsAString& aLocalName);
   already_AddRefed<Attr> SetAttributeNodeNS(Attr& aNewAttr,
--- a/content/base/public/ElementInlines.h
+++ b/content/base/public/ElementInlines.h
@@ -9,22 +9,16 @@
 
 #include "mozilla/dom/Element.h"
 #include "nsIDocument.h"
 
 namespace mozilla {
 namespace dom {
 
 inline void
-Element::MozRequestPointerLock()
-{
-  OwnerDoc()->RequestPointerLock(this);
-}
-
-inline void
 Element::RegisterFreezableElement()
 {
   OwnerDoc()->RegisterFreezableElement(this);
 }
 
 inline void
 Element::UnregisterFreezableElement()
 {
--- a/content/base/public/nsIAttribute.h
+++ b/content/base/public/nsIAttribute.h
@@ -38,16 +38,17 @@ public:
    */
   virtual nsresult SetOwnerDocument(nsIDocument* aDocument) = 0;
 
 protected:
 #ifdef MOZILLA_INTERNAL_API
   nsIAttribute(nsDOMAttributeMap *aAttrMap, already_AddRefed<nsINodeInfo> aNodeInfo,
                bool aNsAware);
 #endif //MOZILLA_INTERNAL_API
+  virtual ~nsIAttribute();
 
   nsRefPtr<nsDOMAttributeMap> mAttrMap;
   bool mNsAware;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIAttribute, NS_IATTRIBUTE_IID)
 
 #endif /* nsIAttribute_h___ */
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -95,16 +95,17 @@ class ImageLoader;
 namespace dom {
 class Attr;
 class CDATASection;
 class Comment;
 struct CustomElementDefinition;
 class DocumentFragment;
 class DocumentType;
 class DOMImplementation;
+class DOMStringList;
 class Element;
 struct ElementRegistrationOptions;
 class EventTarget;
 class FrameRequestCallback;
 class HTMLBodyElement;
 struct LifecycleCallbackArgs;
 class Link;
 class GlobalObject;
@@ -119,18 +120,18 @@ template<typename> class OwningNonNull;
 template<typename> class Sequence;
 
 template<typename, typename> class CallbackObjectHolder;
 typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
 } // namespace dom
 } // namespace mozilla
 
 #define NS_IDOCUMENT_IID \
-{ 0x595492bc, 0xa26d, 0x46a9, \
-  { 0xa9, 0x35, 0x0c, 0x40, 0xdd, 0xc2, 0x77, 0x51 } }
+{ 0x94629cb0, 0xfe8a, 0x4627, \
+  { 0x8e, 0x59, 0xab, 0x1a, 0xaf, 0xdc, 0x99, 0x56 } }
 
 // Flag for AddStyleSheet().
 #define NS_STYLESHEET_FROM_CATALOG                (1 << 0)
 
 // Enum for requesting a particular type of document when creating a doc
 enum DocumentFlavor {
   DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
   DocumentFlavorHTML, // HTMLDocument with HTMLness bit set to true
@@ -2154,17 +2155,17 @@ public:
     WarnOnceAbout(ePrefixedVisibilityAPI);
     return VisibilityState();
   }
   virtual nsIDOMStyleSheetList* StyleSheets() = 0;
   void GetSelectedStyleSheetSet(nsAString& aSheetSet);
   virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) = 0;
   virtual void GetLastStyleSheetSet(nsString& aSheetSet) = 0;
   void GetPreferredStyleSheetSet(nsAString& aSheetSet);
-  virtual nsIDOMDOMStringList* StyleSheetSets() = 0;
+  virtual mozilla::dom::DOMStringList* StyleSheetSets() = 0;
   virtual void EnableStyleSheetsForSet(const nsAString& aSheetSet) = 0;
   Element* ElementFromPoint(float aX, float aY);
 
   /**
    * Retrieve the location of the caret position (DOM node and character
    * offset within that node), given a point.
    *
    * @param aX Horizontal point at which to determine the caret position, in
--- a/content/base/public/nsIMessageManager.idl
+++ b/content/base/public/nsIMessageManager.idl
@@ -1,16 +1,15 @@
 /* -*- 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/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMDOMStringList;
 interface nsIDOMWindow;
 interface nsIDocShell;
 interface nsIContent;
 interface nsIPrincipal;
 
 /**
  * Message managers provide a way for chrome-privileged JS code to
  * communicate with each other, even across process boundaries.
--- a/content/base/src/Attr.cpp
+++ b/content/base/src/Attr.cpp
@@ -5,17 +5,17 @@
 
 /*
  * Implementation of DOM Core's nsIDOMAttr node.
  */
 
 #include "mozilla/dom/Attr.h"
 #include "mozilla/dom/AttrBinding.h"
 #include "mozilla/dom/Element.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsINameSpaceManager.h"
 #include "nsError.h"
 #include "nsUnicharUtils.h"
 #include "nsDOMString.h"
 #include "nsIContentInlines.h"
 #include "nsIDocument.h"
 #include "nsIDOMUserDataHandler.h"
@@ -31,16 +31,20 @@
 
 nsIAttribute::nsIAttribute(nsDOMAttributeMap* aAttrMap,
                            already_AddRefed<nsINodeInfo> aNodeInfo,
                            bool aNsAware)
 : nsINode(aNodeInfo), mAttrMap(aAttrMap), mNsAware(aNsAware)
 {
 }
 
+nsIAttribute::~nsIAttribute()
+{
+}
+
 namespace mozilla {
 namespace dom {
 
 //----------------------------------------------------------------------
 bool Attr::sInitialized;
 
 Attr::Attr(nsDOMAttributeMap *aAttrMap,
            already_AddRefed<nsINodeInfo> aNodeInfo,
--- a/content/base/src/Attr.h
+++ b/content/base/src/Attr.h
@@ -15,16 +15,17 @@
 #include "nsIDOMAttr.h"
 #include "nsIDOMText.h"
 #include "nsIDOMNodeList.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsINodeInfo.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsStubMutationObserver.h"
+#include "nsIDocument.h"
 
 namespace mozilla {
 namespace dom {
 
 // Attribute helper class used to wrap up an attribute with a dom
 // object that implements nsIDOMAttr and nsIDOMNode
 class Attr MOZ_FINAL : public nsIAttribute,
                        public nsIDOMAttr
rename from content/base/src/nsDOMLists.cpp
rename to content/base/src/DOMStringList.cpp
--- a/content/base/src/nsDOMLists.cpp
+++ b/content/base/src/DOMStringList.cpp
@@ -1,59 +1,33 @@
 /* -*- 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/. */
 
-/*
- * Implementation of nsIDOMDOMStringList, used by various DOM stuff.
- */
+#include "mozilla/dom/DOMStringList.h"
+#include "mozilla/dom/DOMStringListBinding.h"
+#include "nsContentUtils.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(DOMStringList)
 
-#include "nsDOMLists.h"
-#include "nsError.h"
-#include "nsDOMClassInfoID.h"
-#include "nsINode.h"
+NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMStringList)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMStringList)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMStringList)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
 
-nsDOMStringList::nsDOMStringList()
-{
-}
-
-nsDOMStringList::~nsDOMStringList()
+DOMStringList::~DOMStringList()
 {
 }
 
-DOMCI_DATA(DOMStringList, nsDOMStringList)
-
-NS_IMPL_ADDREF(nsDOMStringList)
-NS_IMPL_RELEASE(nsDOMStringList)
-NS_INTERFACE_TABLE_HEAD(nsDOMStringList)
-  NS_INTERFACE_TABLE1(nsDOMStringList, nsIDOMDOMStringList)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMStringList)
-NS_INTERFACE_MAP_END
-
-NS_IMETHODIMP
-nsDOMStringList::Item(uint32_t aIndex, nsAString& aResult)
+JSObject*
+DOMStringList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
-  if (aIndex >= mNames.Length()) {
-    SetDOMStringToNull(aResult);
-  } else {
-    aResult = mNames[aIndex];
-  }
-
-  return NS_OK;
+  return DOMStringListBinding::Wrap(aCx, aScope, this);
 }
 
-NS_IMETHODIMP
-nsDOMStringList::GetLength(uint32_t *aLength)
-{
-  *aLength = mNames.Length();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMStringList::Contains(const nsAString& aString, bool *aResult)
-{
-  *aResult = mNames.Contains(aString);
-
-  return NS_OK;
-}
+} // namespace dom
+} // namespace mozilla
rename from content/base/src/nsDOMLists.h
rename to content/base/src/DOMStringList.h
--- a/content/base/src/nsDOMLists.h
+++ b/content/base/src/DOMStringList.h
@@ -1,45 +1,106 @@
 /* -*- 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/. */
 
-/*
- * Implementation of nsIDOMDOMStringList, used by various DOM stuff.
- */
+#ifndef mozilla_dom_DOMStringList_h
+#define mozilla_dom_DOMStringList_h
 
-#ifndef nsDOMLists_h___
-#define nsDOMLists_h___
-
-#include "nsIDOMDOMStringList.h"
+#include "nsISupports.h"
 #include "nsTArray.h"
+#include "nsWrapperCache.h"
 #include "nsString.h"
 
-class nsDOMStringList : public nsIDOMDOMStringList
+namespace mozilla {
+namespace dom {
+
+class DOMStringList : public nsISupports,
+                      public nsWrapperCache
 {
 public:
-  nsDOMStringList();
-  virtual ~nsDOMStringList();
+  DOMStringList()
+  {
+    SetIsDOMBinding();
+  }
+  virtual ~DOMStringList();
+
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMStringList)
+
+  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
+  nsISupports* GetParentObject()
+  {
+    return nullptr;
+  }
 
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMDOMSTRINGLIST
+  void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aResult)
+  {
+    EnsureFresh();
+    if (aIndex < mNames.Length()) {
+      aFound = true;
+      aResult = mNames[aIndex];
+    } else {
+      aFound = false;
+    }
+  }
+
+  void Item(uint32_t aIndex, nsAString& aResult)
+  {
+    EnsureFresh();
+    if (aIndex < mNames.Length()) {
+      aResult = mNames[aIndex];
+    } else {
+      aResult.SetIsVoid(true);
+    }
+  }
+
+  uint32_t Length()
+  {
+    EnsureFresh();
+    return mNames.Length();
+  }
+
+  bool Contains(const nsAString& aString)
+  {
+    EnsureFresh();
+    return mNames.Contains(aString);
+  }
 
   bool Add(const nsAString& aName)
   {
+    // XXXbz mNames should really be a fallible array; otherwise this
+    // return value is meaningless.
     return mNames.AppendElement(aName) != nullptr;
   }
 
   void Clear()
   {
     mNames.Clear();
   }
 
+  nsTArray<nsString>& StringArray()
+  {
+    return mNames;
+  }
+
   void CopyList(nsTArray<nsString>& aNames)
   {
     aNames = mNames;
   }
 
-private:
+protected:
+  // A method that subclasses can override to modify mNames as needed
+  // before we index into it or return its length or whatnot.
+  virtual void EnsureFresh()
+  {
+  }
+
+  // XXXbz we really want this to be a fallible array, but we end up passing it
+  // to consumers who declare themselves as taking and nsTArray.  :(
   nsTArray<nsString> mNames;
 };
 
-#endif /* nsDOMLists_h___ */
+} // namespace dom
+} // namespace mozilla
+
+#endif /* mozilla_dom_DOMStringList_h */
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -45,18 +45,18 @@
 #include "nsContentList.h"
 #include "nsDOMTokenList.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsError.h"
 #include "nsDOMString.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIDOMMutationEvent.h"
 #include "mozilla/ContentEvents.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/TextEvents.h"
 #include "nsNodeUtils.h"
 #include "mozilla/dom/DirectionalityUtils.h"
 #include "nsDocument.h"
 #include "nsAttrValueOrString.h"
 #include "nsAttrValueInlines.h"
 #ifdef MOZ_XUL
 #include "nsXULElement.h"
@@ -2590,16 +2590,22 @@ Element::MozRequestFullScreen()
     return;
   }
 
   OwnerDoc()->AsyncRequestFullScreen(this);
 
   return;
 }
 
+void
+Element::MozRequestPointerLock()
+{
+  OwnerDoc()->RequestPointerLock(this);
+}
+
 NS_IMETHODIMP
 Element::GetInnerHTML(nsAString& aInnerHTML)
 {
   GetMarkup(false, aInnerHTML);
   return NS_OK;
 }
 
 void
--- a/content/base/src/EventSource.cpp
+++ b/content/base/src/EventSource.cpp
@@ -3,21 +3,21 @@
  * 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/EventSource.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/EventSourceBinding.h"
+#include "mozilla/dom/MessageEvent.h"
 
 #include "js/OldDebugAPI.h"
 #include "nsNetUtil.h"
 #include "nsMimeTypes.h"
-#include "nsDOMMessageEvent.h"
 #include "nsIPromptFactory.h"
 #include "nsIWindowWatcher.h"
 #include "nsPresContext.h"
 #include "nsContentPolicyUtils.h"
 #include "nsIStringBundle.h"
 #include "nsIConsoleService.h"
 #include "nsIObserverService.h"
 #include "nsIScriptObjectPrincipal.h"
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -47,18 +47,18 @@
 #include "nsINameSpaceManager.h"
 #include "nsContentList.h"
 #include "nsDOMTokenList.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsError.h"
 #include "nsDOMString.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIDOMMutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "nsNodeUtils.h"
 #include "nsDocument.h"
 #include "nsAttrValueOrString.h"
 #ifdef MOZ_XUL
 #include "nsXULElement.h"
 #endif /* MOZ_XUL */
 #include "nsFrameManager.h"
 #include "nsFrameSelection.h"
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -31,17 +31,16 @@
 #include "nsIConsoleService.h"
 #include "nsIDOMCloseEvent.h"
 #include "nsICryptoHash.h"
 #include "nsJSUtils.h"
 #include "nsIScriptError.h"
 #include "nsNetUtil.h"
 #include "nsILoadGroup.h"
 #include "mozilla/Preferences.h"
-#include "nsDOMLists.h"
 #include "xpcpublic.h"
 #include "nsContentPolicyUtils.h"
 #include "nsDOMFile.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsIObserverService.h"
 #include "nsIWebSocketChannel.h"
 #include "GeneratedEvents.h"
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -57,16 +57,17 @@ if CONFIG['INTEL_ARCHITECTURE']:
 EXPORTS.mozilla.dom += [
     'Attr.h',
     'Comment.h',
     'DocumentFragment.h',
     'DocumentType.h',
     'DOMImplementation.h',
     'DOMParser.h',
     'DOMRect.h',
+    'DOMStringList.h',
     'EventSource.h',
     'Link.h',
     'NodeIterator.h',
     'ShadowRoot.h',
     'Text.h',
     'TreeWalker.h',
 ]
 
@@ -75,16 +76,17 @@ UNIFIED_SOURCES += [
     'ChildIterator.cpp',
     'Comment.cpp',
     'DirectionalityUtils.cpp',
     'DocumentFragment.cpp',
     'DocumentType.cpp',
     'DOMImplementation.cpp',
     'DOMParser.cpp',
     'DOMRect.cpp',
+    'DOMStringList.cpp',
     'Element.cpp',
     'EventSource.cpp',
     'FileIOObject.cpp',
     'FragmentOrElement.cpp',
     'Link.cpp',
     'NodeIterator.cpp',
     'nsAtomListUtils.cpp',
     'nsAttrAndChildArray.cpp',
@@ -102,17 +104,16 @@ UNIFIED_SOURCES += [
     'nsCSPService.cpp',
     'nsDataDocumentContentPolicy.cpp',
     'nsDocumentEncoder.cpp',
     'nsDOMAttributeMap.cpp',
     'nsDOMBlobBuilder.cpp',
     'nsDOMCaretPosition.cpp',
     'nsDOMFile.cpp',
     'nsDOMFileReader.cpp',
-    'nsDOMLists.cpp',
     'nsDOMMutationObserver.cpp',
     'nsDOMSerializer.cpp',
     'nsDOMSettableTokenList.cpp',
     'nsDOMTokenList.cpp',
     'nsFormData.cpp',
     'nsFrameLoader.cpp',
     'nsFrameMessageManager.cpp',
     'nsGenConImageContent.cpp',
--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -670,32 +670,32 @@ nsContentSink::ProcessLink(const nsSubst
   // The link relation may apply to a different resource, specified
   // in the anchor parameter. For the link relations supported so far,
   // we simply abort if the link applies to a resource different to the
   // one we've loaded
   if (!LinkContextIsOurDocument(aAnchor)) {
     return NS_OK;
   }
   
-  bool hasPrefetch = linkTypes & PREFETCH;
+  bool hasPrefetch = linkTypes & nsStyleLinkElement::ePREFETCH;
   // prefetch href if relation is "next" or "prefetch"
-  if (hasPrefetch || (linkTypes & NEXT)) {
+  if (hasPrefetch || (linkTypes & nsStyleLinkElement::eNEXT)) {
     PrefetchHref(aHref, mDocument, hasPrefetch);
   }
 
-  if (!aHref.IsEmpty() && (linkTypes & DNS_PREFETCH)) {
+  if (!aHref.IsEmpty() && (linkTypes & nsStyleLinkElement::eDNS_PREFETCH)) {
     PrefetchDNS(aHref);
   }
 
   // is it a stylesheet link?
-  if (!(linkTypes & STYLESHEET)) {
+  if (!(linkTypes & nsStyleLinkElement::eSTYLESHEET)) {
     return NS_OK;
   }
 
-  bool isAlternate = linkTypes & ALTERNATE;
+  bool isAlternate = linkTypes & nsStyleLinkElement::eALTERNATE;
   return ProcessStyleLink(nullptr, aHref, isAlternate, aTitle, aType,
                           aMedia);
 }
 
 nsresult
 nsContentSink::ProcessStyleLink(nsIContent* aElement,
                                 const nsSubstring& aHref,
                                 bool aAlternate,
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -35,19 +35,19 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "mozilla/dom/HTMLTemplateElement.h"
 #include "mozilla/dom/HTMLContentElement.h"
 #include "mozilla/dom/TextDecoder.h"
 #include "mozilla/dom/ShadowRoot.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Selection.h"
 #include "mozilla/TextEvents.h"
 #include "nsAString.h"
 #include "nsAttrName.h"
 #include "nsAttrValue.h"
 #include "nsAttrValueInlines.h"
 #include "nsBindingManager.h"
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -41,17 +41,16 @@
 #include "nsCxPusher.h"
 
 #include "mozilla/BasicEvents.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsIDOMNodeFilter.h"
 
 #include "nsIDOMStyleSheet.h"
 #include "mozilla/dom/Attr.h"
-#include "nsIDOMDOMStringList.h"
 #include "nsIDOMDOMImplementation.h"
 #include "nsIDOMDocumentXBL.h"
 #include "mozilla/dom/Element.h"
 #include "nsGenericHTMLElement.h"
 #include "mozilla/dom/CDATASection.h"
 #include "mozilla/dom/ProcessingInstruction.h"
 #include "nsDOMString.h"
 #include "nsNodeUtils.h"
@@ -116,17 +115,17 @@
 #include "nsCharsetAlias.h"
 #include "nsCharsetSource.h"
 #include "nsIParser.h"
 #include "nsIContentSink.h"
 
 #include "nsDateTimeFormatCID.h"
 #include "nsIDateTimeFormat.h"
 #include "nsEventDispatcher.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsDOMCID.h"
 
 #include "jsapi.h"
 #include "nsIXPConnect.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
 #include "nsICategoryManager.h"
@@ -216,16 +215,17 @@
 #include "nsIHttpChannelInternal.h"
 #include "nsISecurityConsoleMessage.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "mozilla/dom/XPathEvaluator.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIStructuredCloneContainer.h"
 #include "nsIMutableArray.h"
 #include "nsContentPermissionHelper.h"
+#include "mozilla/dom/DOMStringList.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 typedef nsTArray<Link*> LinkArray;
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gDocumentLeakPRLog;
@@ -1302,115 +1302,61 @@ nsExternalResourceMap::ExternalResource:
   }
 }
 
 // ==================================================================
 // =
 // ==================================================================
 
 // If we ever have an nsIDocumentObserver notification for stylesheet title
-// changes, we could make this inherit from nsDOMStringList instead of
-// reimplementing nsIDOMDOMStringList.
-class nsDOMStyleSheetSetList MOZ_FINAL : public nsIDOMDOMStringList
+// changes we should update the list from that instead of overriding
+// EnsureFresh.
+class nsDOMStyleSheetSetList MOZ_FINAL : public DOMStringList
 {
 public:
-  NS_DECL_ISUPPORTS
-
-  NS_DECL_NSIDOMDOMSTRINGLIST
-
   nsDOMStyleSheetSetList(nsIDocument* aDocument);
 
   void Disconnect()
   {
     mDocument = nullptr;
   }
 
+  virtual void EnsureFresh() MOZ_OVERRIDE;
+
 protected:
-  // Rebuild our list of style sets
-  nsresult GetSets(nsTArray<nsString>& aStyleSets);
-
   nsIDocument* mDocument;  // Our document; weak ref.  It'll let us know if it
                            // dies.
 };
 
-NS_IMPL_ADDREF(nsDOMStyleSheetSetList)
-NS_IMPL_RELEASE(nsDOMStyleSheetSetList)
-NS_INTERFACE_TABLE_HEAD(nsDOMStyleSheetSetList)
-  NS_INTERFACE_TABLE1(nsDOMStyleSheetSetList, nsIDOMDOMStringList)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMStringList)
-NS_INTERFACE_MAP_END
-
 nsDOMStyleSheetSetList::nsDOMStyleSheetSetList(nsIDocument* aDocument)
   : mDocument(aDocument)
 {
   NS_ASSERTION(mDocument, "Must have document!");
 }
 
-NS_IMETHODIMP
-nsDOMStyleSheetSetList::Item(uint32_t aIndex, nsAString& aResult)
-{
-  nsTArray<nsString> styleSets;
-  nsresult rv = GetSets(styleSets);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (aIndex >= styleSets.Length()) {
-    SetDOMStringToNull(aResult);
-  } else {
-    aResult = styleSets[aIndex];
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMStyleSheetSetList::GetLength(uint32_t *aLength)
-{
-  nsTArray<nsString> styleSets;
-  nsresult rv = GetSets(styleSets);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aLength = styleSets.Length();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMStyleSheetSetList::Contains(const nsAString& aString, bool *aResult)
-{
-  nsTArray<nsString> styleSets;
-  nsresult rv = GetSets(styleSets);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aResult = styleSets.Contains(aString);
-
-  return NS_OK;
-}
-
-nsresult
-nsDOMStyleSheetSetList::GetSets(nsTArray<nsString>& aStyleSets)
-{
+void
+nsDOMStyleSheetSetList::EnsureFresh()
+{
+  mNames.Clear();
+
   if (!mDocument) {
-    return NS_OK; // Spec says "no exceptions", and we have no style sets if we
-                  // have no document, for sure
+    return; // Spec says "no exceptions", and we have no style sets if we have
+            // no document, for sure
   }
 
   int32_t count = mDocument->GetNumberOfStyleSheets();
   nsAutoString title;
   for (int32_t index = 0; index < count; index++) {
     nsIStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
     NS_ASSERTION(sheet, "Null sheet in sheet list!");
     sheet->GetTitle(title);
-    if (!title.IsEmpty() && !aStyleSets.Contains(title) &&
-        !aStyleSets.AppendElement(title)) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-  }
-
-  return NS_OK;
+    if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
+      return;
+    }
+  }
 }
 
 // ==================================================================
 nsIDocument::SelectorCache::SelectorCache()
   : nsExpirationTracker<SelectorCacheKey, 4>(1000) { }
 
 // CacheList takes ownership of aSelectorList.
 void nsIDocument::SelectorCache::CacheList(const nsAString& aSelector,
@@ -6168,23 +6114,23 @@ nsDocument::GetPreferredStyleSheetSet(ns
 
 void
 nsIDocument::GetPreferredStyleSheetSet(nsAString& aSheetSet)
 {
   GetHeaderData(nsGkAtoms::headerDefaultStyle, aSheetSet);
 }
 
 NS_IMETHODIMP
-nsDocument::GetStyleSheetSets(nsIDOMDOMStringList** aList)
+nsDocument::GetStyleSheetSets(nsISupports** aList)
 {
   NS_ADDREF(*aList = StyleSheetSets());
   return NS_OK;
 }
 
-nsIDOMDOMStringList*
+DOMStringList*
 nsDocument::StyleSheetSets()
 {
   if (!mStyleSheetSetList) {
     mStyleSheetSetList = new nsDOMStyleSheetSetList(this);
   }
   return mStyleSheetSetList;
 }
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -1190,17 +1190,17 @@ public:
     GetImplementation(mozilla::ErrorResult& rv) MOZ_OVERRIDE;
   virtual JSObject*
     RegisterElement(JSContext* aCx, const nsAString& aName,
                     const mozilla::dom::ElementRegistrationOptions& aOptions,
                     mozilla::ErrorResult& rv) MOZ_OVERRIDE;
   virtual nsIDOMStyleSheetList* StyleSheets() MOZ_OVERRIDE;
   virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) MOZ_OVERRIDE;
   virtual void GetLastStyleSheetSet(nsString& aSheetSet) MOZ_OVERRIDE;
-  virtual nsIDOMDOMStringList* StyleSheetSets() MOZ_OVERRIDE;
+  virtual mozilla::dom::DOMStringList* StyleSheetSets() MOZ_OVERRIDE;
   virtual void EnableStyleSheetsForSet(const nsAString& aSheetSet) MOZ_OVERRIDE;
   using nsIDocument::CreateElement;
   using nsIDocument::CreateElementNS;
   virtual already_AddRefed<Element> CreateElement(const nsAString& aTagName,
                                                   const nsAString& aTypeExtension,
                                                   mozilla::ErrorResult& rv) MOZ_OVERRIDE;
   virtual already_AddRefed<Element> CreateElementNS(const nsAString& aNamespaceURI,
                                                     const nsAString& aQualifiedName,
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -28,17 +28,17 @@
 #include "nsIJSRuntimeService.h"
 #include "nsIDOMClassInfo.h"
 #include "nsIDOMFile.h"
 #include "xpcpublic.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/StructuredCloneUtils.h"
 #include "JavaScriptChild.h"
 #include "JavaScriptParent.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsPrintfCString.h"
 #include <algorithm>
 
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 #ifdef XP_WIN
 #include <windows.h>
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -13,17 +13,17 @@
 #include "nsGenericDOMDataNode.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ShadowRoot.h"
 #include "nsIDocument.h"
 #include "nsEventListenerManager.h"
 #include "nsIDOMDocument.h"
 #include "nsReadableUtils.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsINameSpaceManager.h"
 #include "nsIURI.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMText.h"
 #include "nsCOMPtr.h"
 #include "nsDOMString.h"
 #include "nsIDOMUserDataHandler.h"
 #include "nsChangeHint.h"
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -9,19 +9,19 @@
  */
 
 #include "nsINode.h"
 
 #include "AccessCheck.h"
 #include "jsapi.h"
 #include "mozAutoDocUpdate.h"
 #include "mozilla/CORSMode.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/Telemetry.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsAttrValueOrString.h"
 #include "nsBindingManager.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentList.h"
 #include "nsContentUtils.h"
--- a/content/base/src/nsStyleLinkElement.cpp
+++ b/content/base/src/nsStyleLinkElement.cpp
@@ -115,28 +115,28 @@ nsStyleLinkElement::OverrideBaseURI(nsIU
 }
 
 /* virtual */ void
 nsStyleLinkElement::SetLineNumber(uint32_t aLineNumber)
 {
   mLineNumber = aLineNumber;
 }
 
-uint32_t ToLinkMask(const nsAString& aLink)
+static uint32_t ToLinkMask(const nsAString& aLink)
 { 
   if (aLink.EqualsLiteral("prefetch"))
-     return PREFETCH;
+    return nsStyleLinkElement::ePREFETCH;
   else if (aLink.EqualsLiteral("dns-prefetch"))
-     return DNS_PREFETCH;
+    return nsStyleLinkElement::eDNS_PREFETCH;
   else if (aLink.EqualsLiteral("stylesheet"))
-    return STYLESHEET;
+    return nsStyleLinkElement::eSTYLESHEET;
   else if (aLink.EqualsLiteral("next"))
-    return NEXT;
+    return nsStyleLinkElement::eNEXT;
   else if (aLink.EqualsLiteral("alternate"))
-    return ALTERNATE;
+    return nsStyleLinkElement::eALTERNATE;
   else 
     return 0;
 }
 
 uint32_t nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes)
 {
   uint32_t linkMask = 0;
   nsAString::const_iterator start, done;
--- a/content/base/src/nsStyleLinkElement.h
+++ b/content/base/src/nsStyleLinkElement.h
@@ -15,22 +15,16 @@
 
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsCSSStyleSheet.h"
 #include "nsTArray.h"
 #include "mozilla/CORSMode.h"
 
-#define PREFETCH      0x00000001
-#define DNS_PREFETCH  0x00000002
-#define STYLESHEET    0x00000004
-#define NEXT          0x00000008
-#define ALTERNATE     0x00000010
-
 class nsIDocument;
 class nsIURI;
 
 namespace mozilla {
 namespace dom {
 class ShadowRoot;
 } // namespace dom
 } // namespace mozilla
@@ -53,16 +47,25 @@ public:
                               bool* aWillNotify,
                               bool* aIsAlternate) MOZ_OVERRIDE;
   NS_IMETHOD SetEnableUpdates(bool aEnableUpdates) MOZ_OVERRIDE;
   NS_IMETHOD GetCharset(nsAString& aCharset) MOZ_OVERRIDE;
 
   virtual void OverrideBaseURI(nsIURI* aNewBaseURI) MOZ_OVERRIDE;
   virtual void SetLineNumber(uint32_t aLineNumber) MOZ_OVERRIDE;
 
+  enum RelValue {
+    ePREFETCH =     0x00000001,
+    eDNS_PREFETCH = 0x00000002,
+    eSTYLESHEET =   0x00000004,
+    eNEXT =         0x00000008,
+    eALTERNATE =    0x00000010,
+  };
+
+  // The return value is a bitwise or of 0 or more RelValues
   static uint32_t ParseLinkTypes(const nsAString& aTypes);
 
   void UpdateStyleSheetInternal()
   {
     UpdateStyleSheetInternal(nullptr, nullptr);
   }
 protected:
   /**
--- a/content/base/src/nsStyledElement.cpp
+++ b/content/base/src/nsStyledElement.cpp
@@ -4,17 +4,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 "nsStyledElement.h"
 #include "nsGkAtoms.h"
 #include "nsAttrValue.h"
 #include "nsAttrValueInlines.h"
 #include "mozilla/dom/ElementInlines.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsDOMCSSAttrDeclaration.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIDocument.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsCSSParser.h"
 #include "mozilla/css/Loader.h"
 #include "nsIDOMMutationEvent.h"
--- a/content/base/test/mochitest.ini
+++ b/content/base/test/mochitest.ini
@@ -448,16 +448,17 @@ skip-if = toolkit == 'android' #bug 6870
 [test_bug622117.html]
 [test_bug622246.html]
 [test_bug625722.html]
 [test_bug626262.html]
 [test_bug628938.html]
 [test_bug631615.html]
 [test_bug638112.html]
 [test_bug647518.html]
+[test_bug650001.html]
 [test_bug656283.html]
 [test_bug664916.html]
 [test_bug666604.html]
 [test_bug675121.html]
 [test_bug675166.html]
 [test_bug682463.html]
 [test_bug682554.html]
 [test_bug682592.html]
new file mode 100644
--- /dev/null
+++ b/content/base/test/test_bug650001.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=650001
+-->
+<head>
+  <title>Test for Bug 650001</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650001">Mozilla Bug 650001</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 650001 **/
+
+var svg = '<svg><style xml:lang="en" xlink:href="foo" xmlns="bar" xmlns:link="qux">&lt;&gt;</style><script>&lt;&gt;<\/script></svg>';
+var div = document.getElementById("content");
+div.innerHTML = svg;
+is(div.innerHTML, svg, "Unexpected serialization.");
+
+</script>
+</pre>
+</body>
+</html>
--- a/content/html/content/src/HTMLInputElement.cpp
+++ b/content/html/content/src/HTMLInputElement.cpp
@@ -56,17 +56,17 @@
 #include "nsLinebreakConverter.h" //to strip out carriage returns
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsEventDispatcher.h"
 #include "nsLayoutUtils.h"
 
 #include "nsIDOMMutationEvent.h"
 #include "mozilla/ContentEvents.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "nsEventListenerManager.h"
 
 #include "nsRuleData.h"
 #include <algorithm>
 
 // input type=radio
--- a/content/html/content/src/HTMLInputElement.h
+++ b/content/html/content/src/HTMLInputElement.h
@@ -606,17 +606,17 @@ public:
 
   Nullable<Date> GetValueAsDate(ErrorResult& aRv);
 
   void SetValueAsDate(Nullable<Date>, ErrorResult& aRv);
 
   double ValueAsNumber() const
   {
     return DoesValueAsNumberApply() ? GetValueAsDecimal().toDouble()
-                                    : UnspecifiedNaN();
+                                    : UnspecifiedNaN<double>();
   }
 
   void SetValueAsNumber(double aValue, ErrorResult& aRv);
 
   uint32_t Width();
 
   void SetWidth(uint32_t aValue, ErrorResult& aRv)
   {
--- a/content/html/content/src/HTMLLinkElement.cpp
+++ b/content/html/content/src/HTMLLinkElement.cpp
@@ -1,8 +1,9 @@
+
 /* -*- 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 "mozilla/dom/HTMLLinkElement.h"
 
 #include "mozilla/Attributes.h"
@@ -250,17 +251,17 @@ HTMLLinkElement::SetAttr(int32_t aNameSp
       (aName == nsGkAtoms::href ||
        aName == nsGkAtoms::rel ||
        aName == nsGkAtoms::title ||
        aName == nsGkAtoms::media ||
        aName == nsGkAtoms::type)) {
     bool dropSheet = false;
     if (aName == nsGkAtoms::rel && GetSheet()) {
       uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(aValue);
-      dropSheet = !(linkTypes & STYLESHEET);          
+      dropSheet = !(linkTypes & nsStyleLinkElement::eSTYLESHEET);
     }
     
     UpdateStyleSheetInternal(nullptr, nullptr,
                              dropSheet ||
                              (aName == nsGkAtoms::title ||
                               aName == nsGkAtoms::media ||
                               aName == nsGkAtoms::type));
   }
@@ -355,27 +356,27 @@ HTMLLinkElement::GetStyleSheetInfo(nsASt
   aMedia.Truncate();
   *aIsScoped = false;
   *aIsAlternate = false;
 
   nsAutoString rel;
   GetAttr(kNameSpaceID_None, nsGkAtoms::rel, rel);
   uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel);
   // Is it a stylesheet link?
-  if (!(linkTypes & STYLESHEET)) {
+  if (!(linkTypes & nsStyleLinkElement::eSTYLESHEET)) {
     return;
   }
 
   nsAutoString title;
   GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
   title.CompressWhitespace();
   aTitle.Assign(title);
 
   // If alternate, does it have title?
-  if (linkTypes & ALTERNATE) {
+  if (linkTypes & nsStyleLinkElement::eALTERNATE) {
     if (aTitle.IsEmpty()) { // alternates must have title
       return;
     } else {
       *aIsAlternate = true;
     }
   }
 
   GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
--- a/content/html/content/src/HTMLPropertiesCollection.cpp
+++ b/content/html/content/src/HTMLPropertiesCollection.cpp
@@ -218,17 +218,16 @@ HTMLPropertiesCollection::EnsureFresh()
   mProperties.Sort(comparator);
 
   // Create the names DOMStringList
   uint32_t count = mProperties.Length();
   for (uint32_t i = 0; i < count; ++i) {
     const nsAttrValue* attr = mProperties.ElementAt(i)->GetParsedAttr(nsGkAtoms::itemprop); 
     for (uint32_t i = 0; i < attr->GetAtomCount(); i++) {
       nsDependentAtomString propName(attr->AtomAt(i));
-      // ContainsInternal must not call EnsureFresh
       bool contains = mNames->ContainsInternal(propName);
       if (!contains) {
         mNames->Add(propName);
       }
     }
   }
 }
 
@@ -487,55 +486,36 @@ PropertyNodeList::EnsureFresh()
     const nsAttrValue* attr = element->GetParsedAttr(nsGkAtoms::itemprop);
     if (attr->Contains(mName)) {
       AppendElement(element);
     }
   }
 }
 
 PropertyStringList::PropertyStringList(HTMLPropertiesCollection* aCollection)
-  : nsDOMStringList()
+  : DOMStringList()
   , mCollection(aCollection)
 { }
 
-NS_IMPL_CYCLE_COLLECTION_1(PropertyStringList, mCollection)
+NS_IMPL_CYCLE_COLLECTION_INHERITED_1(PropertyStringList, DOMStringList,
+                                     mCollection)
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(PropertyStringList)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(PropertyStringList)
+NS_IMPL_ADDREF_INHERITED(PropertyStringList, DOMStringList)
+NS_IMPL_RELEASE_INHERITED(PropertyStringList, DOMStringList)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PropertyStringList)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDOMStringList)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMStringList)
-NS_INTERFACE_MAP_END
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PropertyStringList)
+NS_INTERFACE_MAP_END_INHERITING(DOMStringList)
 
-NS_IMETHODIMP
-PropertyStringList::Item(uint32_t aIndex, nsAString& aResult)
+void
+PropertyStringList::EnsureFresh()
 {
   mCollection->EnsureFresh();
-  return nsDOMStringList::Item(aIndex, aResult);
-}
-
-NS_IMETHODIMP
-PropertyStringList::GetLength(uint32_t* aLength)
-{
-  mCollection->EnsureFresh();
-  return nsDOMStringList::GetLength(aLength);
-}
-
-NS_IMETHODIMP
-PropertyStringList::Contains(const nsAString& aString, bool* aResult)
-{
-  mCollection->EnsureFresh();
-  return nsDOMStringList::Contains(aString, aResult);
 }
 
 bool
 PropertyStringList::ContainsInternal(const nsAString& aString)
 {
   // This method should not call EnsureFresh, otherwise we may become stuck in an infinite loop.
-  bool result;
-  nsDOMStringList::Contains(aString, &result);
-  return result;
+  return mNames.Contains(aString);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLPropertiesCollection.h
+++ b/content/html/content/src/HTMLPropertiesCollection.h
@@ -3,17 +3,17 @@
 /* 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 HTMLPropertiesCollection_h_
 #define HTMLPropertiesCollection_h_
 
 #include "mozilla/Attributes.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsIMutationObserver.h"
 #include "nsStubMutationObserver.h"
 #include "nsBaseHashtable.h"
 #include "nsINodeList.h"
 #include "nsIHTMLCollection.h"
@@ -26,27 +26,28 @@ class nsINode;
 
 namespace mozilla {
 namespace dom {
 
 class HTMLPropertiesCollection;
 class PropertyNodeList;
 class Element;
 
-class PropertyStringList : public nsDOMStringList
+class PropertyStringList : public DOMStringList
 {
 public:
   PropertyStringList(HTMLPropertiesCollection* aCollection);
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS(PropertyStringList)
-  NS_DECL_NSIDOMDOMSTRINGLIST
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PropertyStringList, DOMStringList)
 
   bool ContainsInternal(const nsAString& aString);
 
 protected:
+  virtual void EnsureFresh() MOZ_OVERRIDE;
+
   nsRefPtr<HTMLPropertiesCollection> mCollection;
 };
 
 class HTMLPropertiesCollection : public nsIHTMLCollection,
                                  public nsStubMutationObserver,
                                  public nsWrapperCache
 {
   friend class PropertyNodeList;
@@ -81,17 +82,17 @@ public:
     return nullptr;
   }
   PropertyNodeList* NamedItem(const nsAString& aName);
   PropertyNodeList* NamedGetter(const nsAString& aName, bool& aFound)
   {
     aFound = IsSupportedNamedProperty(aName);
     return aFound ? NamedItem(aName) : nullptr;
   }
-  nsDOMStringList* Names()
+  DOMStringList* Names()
   {
     EnsureFresh();
     return mNames;
   }
   virtual void GetSupportedNames(nsTArray<nsString>& aNames) MOZ_OVERRIDE;
 
   NS_DECL_NSIDOMHTMLCOLLECTION
 
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -65,17 +65,17 @@
 #include "nsITextControlFrame.h"
 #include "nsIForm.h"
 #include "nsIFormControl.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "mozilla/dom/HTMLFormElement.h"
 #include "nsFocusManager.h"
 #include "nsAttrValueOrString.h"
 
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsDOMStringMap.h"
 
 #include "nsIEditor.h"
 #include "nsIEditorIMESupport.h"
 #include "nsEventDispatcher.h"
 #include "nsLayoutUtils.h"
 #include "mozAutoDocUpdate.h"
 #include "nsHtml5Module.h"
--- a/content/media/mediasource/MediaSource.cpp
+++ b/content/media/mediasource/MediaSource.cpp
@@ -75,17 +75,17 @@ MediaSource::ReadyState()
 {
   return mReadyState;
 }
 
 double
 MediaSource::Duration()
 {
   if (mReadyState == MediaSourceReadyState::Closed) {
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
   }
   return mDuration;
 }
 
 void
 MediaSource::SetDuration(double aDuration, ErrorResult& aRv)
 {
   if (aDuration < 0 || IsNaN(aDuration)) {
@@ -192,25 +192,25 @@ MediaSource::Attach(MediaSourceDecoder* 
 
 void
 MediaSource::Detach()
 {
   LOG(PR_LOG_DEBUG, ("%p Detaching decoder %p owner %p", this, mDecoder.get(), mDecoder->GetOwner()));
   MOZ_ASSERT(mDecoder);
   mDecoder->DetachMediaSource();
   mDecoder = nullptr;
-  mDuration = UnspecifiedNaN();
+  mDuration = UnspecifiedNaN<double>();
   mActiveSourceBuffers->Clear();
   mSourceBuffers->Clear();
   SetReadyState(MediaSourceReadyState::Closed);
 }
 
 MediaSource::MediaSource(nsPIDOMWindow* aWindow)
   : nsDOMEventTargetHelper(aWindow)
-  , mDuration(UnspecifiedNaN())
+  , mDuration(UnspecifiedNaN<double>())
   , mDecoder(nullptr)
   , mReadyState(MediaSourceReadyState::Closed)
 {
   mSourceBuffers = new SourceBufferList(this);
   mActiveSourceBuffers = new SourceBufferList(this);
 
 #ifdef PR_LOGGING
   if (!gMediaSourceLog) {
--- a/content/media/mediasource/SourceBuffer.cpp
+++ b/content/media/mediasource/SourceBuffer.cpp
@@ -195,17 +195,17 @@ SourceBuffer::Abort(ErrorResult& aRv)
     return;
   }
   if (mUpdating) {
     // TODO: Abort segment parser loop, buffer append, and stream append loop algorithms.
     AbortUpdating();
   }
   // TODO: Run reset parser algorithm.
   mAppendWindowStart = 0;
-  mAppendWindowEnd = PositiveInfinity();
+  mAppendWindowEnd = PositiveInfinity<double>();
 }
 
 void
 SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
 {
   if (!IsAttached() || mUpdating ||
       mMediaSource->ReadyState() != MediaSourceReadyState::Open) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
@@ -234,17 +234,17 @@ SourceBuffer::Ended()
 {
   mDecoder->GetResource()->Ended();
 }
 
 SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
   : nsDOMEventTargetHelper(aMediaSource->GetParentObject())
   , mMediaSource(aMediaSource)
   , mAppendWindowStart(0)
-  , mAppendWindowEnd(PositiveInfinity())
+  , mAppendWindowEnd(PositiveInfinity<double>())
   , mTimestampOffset(0)
   , mAppendMode(SourceBufferAppendMode::Segments)
   , mUpdating(false)
 {
   MOZ_ASSERT(aMediaSource);
   MediaSourceDecoder* parentDecoder = aMediaSource->GetDecoder();
   mDecoder = parentDecoder->CreateSubDecoder(aType);
   MOZ_ASSERT(mDecoder);
--- a/content/media/webaudio/AnalyserNode.cpp
+++ b/content/media/webaudio/AnalyserNode.cpp
@@ -176,16 +176,27 @@ AnalyserNode::GetByteFrequencyData(const
     // scale down the value to the range of [0, UCHAR_MAX]
     const double scaled = std::max(0.0, std::min(double(UCHAR_MAX),
                                                  UCHAR_MAX * (decibels - mMinDecibels) * rangeScaleFactor));
     buffer[i] = static_cast<unsigned char>(scaled);
   }
 }
 
 void
+AnalyserNode::GetFloatTimeDomainData(const Float32Array& aArray)
+{
+  float* buffer = aArray.Data();
+  uint32_t length = std::min(aArray.Length(), mBuffer.Length());
+
+  for (uint32_t i = 0; i < length; ++i) {
+    buffer[i] = mBuffer[(i + mWriteIndex) % mBuffer.Length()];;
+  }
+}
+
+void
 AnalyserNode::GetByteTimeDomainData(const Uint8Array& aArray)
 {
   unsigned char* buffer = aArray.Data();
   uint32_t length = std::min(aArray.Length(), mBuffer.Length());
 
   for (uint32_t i = 0; i < length; ++i) {
     const float value = mBuffer[(i + mWriteIndex) % mBuffer.Length()];
     // scale the value to the range of [0, UCHAR_MAX]
--- a/content/media/webaudio/AnalyserNode.h
+++ b/content/media/webaudio/AnalyserNode.h
@@ -22,16 +22,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void GetFloatFrequencyData(const Float32Array& aArray);
   void GetByteFrequencyData(const Uint8Array& aArray);
+  void GetFloatTimeDomainData(const Float32Array& aArray);
   void GetByteTimeDomainData(const Uint8Array& aArray);
   uint32_t FftSize() const
   {
     return mAnalysisBlock.FFTSize();
   }
   void SetFftSize(uint32_t aValue, ErrorResult& aRv);
   uint32_t FrequencyBinCount() const
   {
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -9,17 +9,17 @@
 #include "nsSVGElement.h"
 
 #include "mozilla/dom/SVGSVGElement.h"
 #include "mozilla/dom/SVGTests.h"
 #include "nsContentUtils.h"
 #include "nsICSSDeclaration.h"
 #include "nsIDocument.h"
 #include "nsIDOMMutationEvent.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsError.h"
 #include "nsIPresShell.h"
 #include "nsGkAtoms.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsRuleWalker.h"
 #include "mozilla/css/Declaration.h"
 #include "nsCSSProps.h"
 #include "nsCSSParser.h"
--- a/content/xml/document/src/nsXMLContentSink.cpp
+++ b/content/xml/document/src/nsXMLContentSink.cpp
@@ -601,25 +601,25 @@ nsXMLContentSink::CloseElement(nsIConten
     }
     // Look for <link rel="dns-prefetch" href="hostname">
     // and look for <link rel="next" href="hostname"> like in HTML sink
     if (nodeInfo->Equals(nsGkAtoms::link, kNameSpaceID_XHTML)) {
       nsAutoString relVal;
       aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
       if (!relVal.IsEmpty()) {
         uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(relVal);
-        bool hasPrefetch = linkTypes & PREFETCH;
-        if (hasPrefetch || (linkTypes & NEXT)) {
+        bool hasPrefetch = linkTypes & nsStyleLinkElement::ePREFETCH;
+        if (hasPrefetch || (linkTypes & nsStyleLinkElement::eNEXT)) {
           nsAutoString hrefVal;
           aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
           if (!hrefVal.IsEmpty()) {
             PrefetchHref(hrefVal, aContent, hasPrefetch);
           }
         }
-        if (linkTypes & DNS_PREFETCH) {
+        if (linkTypes & nsStyleLinkElement::eDNS_PREFETCH) {
           nsAutoString hrefVal;
           aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
           if (!hrefVal.IsEmpty()) {
             PrefetchDNS(hrefVal);
           }
         }
       }
     }
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -68,18 +68,18 @@
 #include "XULDocument.h"
 #include "nsXULPopupListener.h"
 #include "nsRuleWalker.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsCSSParser.h"
 #include "nsIListBoxObject.h"
 #include "nsContentUtils.h"
 #include "nsContentList.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsJSPrincipals.h"
 #include "nsDOMAttributeMap.h"
 #include "nsGkAtoms.h"
 #include "nsXULContentUtils.h"
 #include "nsNodeUtils.h"
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -69,17 +69,16 @@
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMJSWindow.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsIDOMConstructor.h"
 
 // DOM core includes
 #include "nsError.h"
-#include "nsIDOMDOMStringList.h"
 #include "nsIDOMUserDataHandler.h"
 #include "nsIDOMXPathNamespace.h"
 #include "nsIDOMXULButtonElement.h"
 #include "nsIDOMXULCheckboxElement.h"
 #include "nsIDOMXULPopupElement.h"
 
 // Event related includes
 #include "nsIDOMEventTarget.h"
@@ -351,19 +350,16 @@ static nsDOMClassInfoData sClassInfoData
 #ifdef MOZ_XUL
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULTemplateBuilder, nsDOMGenericSH,
                                       DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULTreeBuilder, nsDOMGenericSH,
                                       DEFAULT_SCRIPTABLE_FLAGS)
 #endif
 
-  NS_DEFINE_CLASSINFO_DATA(DOMStringList, nsStringListSH,
-                           ARRAY_SCRIPTABLE_FLAGS)
-
 #ifdef MOZ_XUL
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(TreeColumn, nsDOMGenericSH,
                                       DEFAULT_SCRIPTABLE_FLAGS)
 #endif
 
   NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
@@ -1009,20 +1005,16 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN(XULTreeBuilder, nsIXULTreeBuilder)
     DOM_CLASSINFO_MAP_ENTRY(nsIXULTreeBuilder)
     DOM_CLASSINFO_MAP_ENTRY(nsIXULTemplateBuilder)
     DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
   DOM_CLASSINFO_MAP_END
 #endif
 
-  DOM_CLASSINFO_MAP_BEGIN(DOMStringList, nsIDOMDOMStringList)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMStringList)
-  DOM_CLASSINFO_MAP_END
-
 #ifdef MOZ_XUL
   DOM_CLASSINFO_MAP_BEGIN(TreeColumn, nsITreeColumn)
     DOM_CLASSINFO_MAP_ENTRY(nsITreeColumn)
   DOM_CLASSINFO_MAP_END
 #endif
 
   DOM_CLASSINFO_MAP_BEGIN(CSSMozDocumentRule, nsIDOMCSSMozDocumentRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
@@ -3695,71 +3687,16 @@ nsArraySH::GetProperty(nsIXPConnectWrapp
       rv = NS_SUCCESS_I_DID_SOMETHING;
     }
   }
 
   return rv;
 }
 
 
-// StringList scriptable helper
-
-nsresult
-nsStringListSH::GetStringAt(nsISupports *aNative, int32_t aIndex,
-                            nsAString& aResult)
-{
-  nsCOMPtr<nsIDOMDOMStringList> list(do_QueryInterface(aNative));
-  NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
-
-  nsresult rv = list->Item(aIndex, aResult);
-#ifdef DEBUG
-  if (DOMStringIsNull(aResult)) {
-    uint32_t length = 0;
-    list->GetLength(&length);
-    NS_ASSERTION(uint32_t(aIndex) >= length, "Item should only return null for out-of-bounds access");
-  }
-#endif
-  return rv;
-}
-
-
-// StringArray helper
-
-NS_IMETHODIMP
-nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
-                             JSObject *aObj, jsid aId, jsval *vp,
-                             bool *_retval)
-{
-  JS::Rooted<JSObject*> obj(cx, aObj);
-  JS::Rooted<jsid> id(cx, aId);
-  bool is_number = false;
-  int32_t n = GetArrayIndexFromId(cx, id, &is_number);
-
-  if (!is_number) {
-    return NS_OK;
-  }
-
-  nsAutoString val;
-
-  nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (DOMStringIsNull(val)) {
-    *vp = JSVAL_VOID;
-    return NS_SUCCESS_I_DID_SOMETHING;
-  }
-
-  JS::Rooted<JS::Value> rval(cx);
-  NS_ENSURE_TRUE(xpc::NonVoidStringToJsval(cx, val, &rval),
-                 NS_ERROR_OUT_OF_MEMORY);
-  *vp = rval;
-  return NS_SUCCESS_I_DID_SOMETHING;
-}
-
-
 // StyleSheetList helper
 
 nsISupports*
 nsStyleSheetListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
                               nsWrapperCache **aCache, nsresult *rv)
 {
   nsIDOMStyleSheetList* list = static_cast<nsIDOMStyleSheetList*>(aNative);
   nsCOMPtr<nsIDOMStyleSheet> sheet;
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -369,64 +369,16 @@ public:
                          JSObject *obj, jsid id, JS::Value *vp, bool *_retval) MOZ_OVERRIDE;
 
 private:
   // Not implemented, nothing should create an instance of this class.
   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData);
 };
 
 
-// String array helper
-
-class nsStringArraySH : public nsGenericArraySH
-{
-protected:
-  nsStringArraySH(nsDOMClassInfoData* aData) : nsGenericArraySH(aData)
-  {
-  }
-
-  virtual ~nsStringArraySH()
-  {
-  }
-
-  virtual nsresult GetStringAt(nsISupports *aNative, int32_t aIndex,
-                               nsAString& aResult) = 0;
-
-public:
-  NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
-                         JSObject *obj, jsid id, JS::Value *vp, bool *_retval) MOZ_OVERRIDE;
-};
-
-
-// StringList scriptable helper
-
-class nsStringListSH : public nsStringArraySH
-{
-protected:
-  nsStringListSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
-  {
-  }
-
-  virtual ~nsStringListSH()
-  {
-  }
-
-  virtual nsresult GetStringAt(nsISupports *aNative, int32_t aIndex,
-                               nsAString& aResult) MOZ_OVERRIDE;
-
-public:
-  // Inherit GetProperty, Enumerate from nsStringArraySH
-  
-  static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
-  {
-    return new nsStringListSH(aData);
-  }
-};
-
-
 // StyleSheetList helper
 
 class nsStyleSheetListSH : public nsArraySH
 {
 protected:
   nsStyleSheetListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
   {
   }
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -33,19 +33,16 @@ DOMCI_CLASS(TreeContentView)
 // DOM Chrome Window class, almost identical to Window
 DOMCI_CLASS(ChromeWindow)
 
 #ifdef MOZ_XUL
 DOMCI_CLASS(XULTemplateBuilder)
 DOMCI_CLASS(XULTreeBuilder)
 #endif
 
-// DOMStringList object
-DOMCI_CLASS(DOMStringList)
-
 #ifdef MOZ_XUL
 DOMCI_CLASS(TreeColumn)
 #endif
 
 DOMCI_CLASS(CSSMozDocumentRule)
 DOMCI_CLASS(CSSSupportsRule)
 
 // other SVG classes
--- a/dom/base/nsDOMClassInfoID.h
+++ b/dom/base/nsDOMClassInfoID.h
@@ -57,31 +57,33 @@ DOMCI_CASTABLE_NODECL_INTERFACE(mozilla:
 DOMCI_CASTABLE_INTERFACE(nsDOMEvent, nsIDOMEvent, 3, _extra)                  \
 DOMCI_CASTABLE_INTERFACE(nsIDocument, nsIDocument, 4, _extra)                 \
 DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 5, _extra)                  \
 DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsIContent, 6, _extra)         \
 DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 7, _extra)              \
 DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 8, _extra)         \
 DOMCI_CASTABLE_INTERFACE(nsSVGElement, nsIContent, 9, _extra)                 \
 /* NOTE: When removing the casts below, remove the nsDOMEventBase class */    \
-DOMCI_CASTABLE_INTERFACE(nsDOMMouseEvent, nsDOMEventBase, 10, _extra)         \
+DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::MouseEvent,                     \
+                                nsDOMEventBase, 10, _extra)                   \
 DOMCI_CASTABLE_INTERFACE(nsDOMUIEvent, nsDOMEventBase, 11, _extra)            \
 DOMCI_CASTABLE_INTERFACE(nsGlobalWindow, nsIDOMEventTarget, 12, _extra)
 
 // Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
 // have been declared.
 #define DOMCI_CASTABLE_NODECL_INTERFACE(_interface, _u1, _u2, _u3) /* Nothing */
 #define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2, _u3) class _interface;
 DOMCI_CASTABLE_INTERFACES(unused)
 #undef DOMCI_CASTABLE_INTERFACE
 #undef DOMCI_CASTABLE_NODECL_INTERFACE
 namespace mozilla {
 namespace dom {
 class Element;
 class EventTarget;
+class MouseEvent;
 } // namespace dom
 } // namespace mozilla
 
 #define DOMCI_CASTABLE_NODECL_INTERFACE DOMCI_CASTABLE_INTERFACE
 
 #ifdef MOZILLA_INTERNAL_API
 
 #define DOMCI_CLASS(_dom_class)                                               \
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -308,27 +308,21 @@ DOMInterfaces = {
     'workers': True,
 },
 
 'DelayNode': {
     'resultNotAddRefed': [ 'delayTime' ],
 },
 
 'DeviceAcceleration': {
-    'nativeType': 'nsDOMDeviceAcceleration',
-    'headerFile': 'nsDOMDeviceMotionEvent.h',
-},
-
-'DeviceMotionEvent': {
-    'nativeType': 'nsDOMDeviceMotionEvent',
+    'headerFile': 'mozilla/dom/DeviceMotionEvent.h',
 },
 
 'DeviceRotationRate': {
-    'nativeType': 'nsDOMDeviceRotationRate',
-    'headerFile': 'nsDOMDeviceMotionEvent.h',
+    'headerFile': 'mozilla/dom/DeviceMotionEvent.h',
 },
 
 'DeviceStorage': {
     'nativeType': 'nsDOMDeviceStorage',
     'headerFile': 'DeviceStorage.h',
 },
 
 'Document': [
@@ -366,20 +360,16 @@ DOMInterfaces = {
 'DOMStringMap': {
     'nativeType': 'nsDOMStringMap'
 },
 
 'DOMTokenList': {
     'nativeType': 'nsDOMTokenList',
 },
 
-'DragEvent': {
-    'nativeType': 'nsDOMDragEvent',
-},
-
 'DummyInterface': {
     'skipGen': True,
     'register': False,
 },
 
 'DummyInterfaceWorkers': {
     'skipGen': True,
     'register': False,
@@ -449,20 +439,16 @@ DOMInterfaces = {
     'nativeType': 'nsFormData'
 },
 {
     'workers': True,
     'skipGen': True,
     'nativeType': 'JSObject'
 }],
 
-'FocusEvent': {
-    'nativeType': 'nsDOMFocusEvent',
-},
-
 'GainNode': {
     'resultNotAddRefed': [ 'gain' ],
 },
 
 'Geolocation': {
     'headerFile': 'nsGeolocation.h'
 },
 
@@ -690,20 +676,16 @@ DOMInterfaces = {
 {
     'nativeType': 'nsIInputStream',
     'notflattened': True
 },
 {
     'workers': True,
 }],
 
-'KeyboardEvent': {
-    'nativeType': 'nsDOMKeyboardEvent',
-},
-
 'KeyEvent': {
     'concrete': False
 },
 
 'LocalMediaStream': {
     'headerFile': 'DOMMediaStream.h',
     'nativeType': 'mozilla::DOMLocalMediaStream'
 },
@@ -755,20 +737,16 @@ DOMInterfaces = {
     'concrete': False
 },
 
 'MediaRecorder': {
     'headerFile': 'MediaRecorder.h',
     'resultNotAddRefed': [ 'stream' ]
 },
 
-'MessageEvent': {
-    'nativeType': 'nsDOMMessageEvent',
-},
-
 'MessagePort': {
     'nativeType': 'mozilla::dom::MessagePortBase',
     'headerFile': 'mozilla/dom/MessagePort.h',
     'binaryNames': {
         'postMessage': 'postMessageMoz',
     },
 },
 
@@ -778,24 +756,16 @@ DOMInterfaces = {
     'resultNotAddRefed': [ 'enabledPlugin' ]
 },
 
 'MimeTypeArray': {
     'nativeType': 'nsMimeTypeArray',
     'resultNotAddRefed': [ 'item', 'namedItem' ]
 },
 
-'MouseEvent': {
-    'nativeType': 'nsDOMMouseEvent',
-},
-
-'MouseScrollEvent': {
-    'nativeType': 'nsDOMMouseScrollEvent',
-},
-
 'MozCanvasPrintState': {
     'headerFile': 'mozilla/dom/HTMLCanvasElement.h',
     'nativeType': 'mozilla::dom::HTMLCanvasPrintState',
 },
 
 'MozChannel': [
 {
     'nativeType': 'nsIChannel',
@@ -842,20 +812,16 @@ DOMInterfaces = {
 'MozTimeManager': {
     'nativeType': 'mozilla::dom::time::TimeManager',
 },
 
 'MozVoicemail': {
     'nativeType': 'mozilla::dom::Voicemail',
 },
 
-'MutationEvent': {
-    'nativeType': 'nsDOMMutationEvent',
-},
-
 'MutationObserver': {
     'nativeType': 'nsDOMMutationObserver',
 },
 
 'MutationRecord': {
     'nativeType': 'nsDOMMutationRecord',
     'headerFile': 'nsDOMMutationObserver.h',
     'resultNotAddRefed': [ 'target', 'addedNodes', 'removedNodes',
@@ -1015,20 +981,16 @@ DOMInterfaces = {
     'implicitJSContext': [ 'constructor' ],
 },
 
 'SharedWorkerGlobalScope': {
     'headerFile': 'mozilla/dom/WorkerScope.h',
     'workers': True,
 },
 
-'SimpleGestureEvent': {
-    'nativeType': 'nsDOMSimpleGestureEvent',
-},
-
 'SourceBufferList': {
     'resultNotAddRefed': [ '__indexedGetter' ],
 },
 
 'StyleSheet': {
     'nativeType': 'nsCSSStyleSheet',
 },
 
@@ -1905,17 +1867,16 @@ def addExternalIface(iface, nativeType=N
 
 addExternalIface('ApplicationCache', nativeType='nsIDOMOfflineResourceList')
 addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
                  headerFile='nsIDOMActivityOptions.h')
 addExternalIface('Counter')
 addExternalIface('CSSRule')
 addExternalIface('mozIDOMApplication', nativeType='mozIDOMApplication', headerFile='nsIDOMApplicationRegistry.h')
 addExternalIface('CSSRuleList')
-addExternalIface('DOMStringList')
 addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
 addExternalIface('LockedFile')
 addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
 addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2625,22 +2625,23 @@ numericSuffixes = {
     IDLType.Tags.float: 'F',
     IDLType.Tags.unrestricted_double: '',
     IDLType.Tags.double: ''
 }
 
 def numericValue(t, v):
     if (t == IDLType.Tags.unrestricted_double or
         t == IDLType.Tags.unrestricted_float):
+        typeName = builtinNames[t]
         if v == float("inf"):
-            return "mozilla::PositiveInfinity()"
+            return "mozilla::PositiveInfinity<%s>()" % typeName
         if v == float("-inf"):
-            return "mozilla::NegativeInfinity()"
+            return "mozilla::NegativeInfinity<%s>()" % typeName
         if math.isnan(v):
-            return "mozilla::UnspecifiedNaN()"
+            return "mozilla::UnspecifiedNaN<%s>()" % typeName
     return "%s%s" % (v, numericSuffixes[t])
 
 class CastableObjectUnwrapper():
     """
     A class for unwrapping an object named by the "source" argument
     based on the passed-in descriptor and storing it in a variable
     called by the name in the "target" argument.
 
@@ -5446,36 +5447,42 @@ class CGMethodCall(CGThing):
                     CGWrapper(CGIndenter(CGGeneric(code)), pre="\n", post="\n"))
             return
 
         # Need to find the right overload
         maxArgCount = method.maxArgCount
         allowedArgCounts = method.allowedArgCounts
 
         argCountCases = []
-        for argCount in allowedArgCounts:
+        for (argCountIdx, argCount) in enumerate(allowedArgCounts):
             possibleSignatures = method.signaturesForArgCount(argCount)
+
+            # Try to optimize away cases when the next argCount in the list
+            # will have the same code as us; if it does, we can fall through to
+            # that case.
+            if argCountIdx+1 < len(allowedArgCounts):
+                nextPossibleSignatures = \
+                    method.signaturesForArgCount(allowedArgCounts[argCountIdx+1])
+            else:
+                nextPossibleSignatures = None
+            if possibleSignatures == nextPossibleSignatures:
+                # Same set of signatures means we better have the same
+                # distinguishing index.  So we can in fact just fall through to
+                # the next case here.
+                assert (len(possibleSignatures) == 1 or
+                        (method.distinguishingIndexForArgCount(argCount) ==
+                         method.distinguishingIndexForArgCount(allowedArgCounts[argCountIdx+1])))
+                argCountCases.append(CGCase(str(argCount), None, True))
+                continue
+
             if len(possibleSignatures) == 1:
                 # easy case!
                 signature = possibleSignatures[0]
-
-                # (possibly) important optimization: if signature[1] has >
-                # argCount arguments and signature[1][argCount] is optional and
-                # there is only one signature for argCount+1, then the
-                # signature for argCount+1 is just ourselves and we can fall
-                # through.
-                if (len(signature[1]) > argCount and
-                    signature[1][argCount].optional and
-                    (argCount+1) in allowedArgCounts and
-                    len(method.signaturesForArgCount(argCount+1)) == 1):
-                    argCountCases.append(
-                        CGCase(str(argCount), None, True))
-                else:
-                    argCountCases.append(
-                        CGCase(str(argCount), getPerSignatureCall(signature)))
+                argCountCases.append(
+                    CGCase(str(argCount), getPerSignatureCall(signature)))
                 continue
 
             distinguishingIndex = method.distinguishingIndexForArgCount(argCount)
 
             def distinguishingArgument(signature):
                 args = signature[1]
                 if distinguishingIndex < len(args):
                     return args[distinguishingIndex]
--- a/dom/bindings/Date.cpp
+++ b/dom/bindings/Date.cpp
@@ -12,17 +12,17 @@
 #include "js/Value.h" // for Value
 #include "jswrapper.h" // for CheckedUnwrap
 #include "mozilla/FloatingPoint.h" // for IsNaN, UnspecifiedNaN
 
 namespace mozilla {
 namespace dom {
 
 Date::Date()
-  : mMsecSinceEpoch(UnspecifiedNaN())
+  : mMsecSinceEpoch(UnspecifiedNaN<double>())
 {
 }
 
 bool
 Date::IsUndefined() const
 {
   return IsNaN(mMsecSinceEpoch);
 }
--- a/dom/bluetooth/BluetoothRilListener.cpp
+++ b/dom/bluetooth/BluetoothRilListener.cpp
@@ -173,17 +173,19 @@ NS_IMPL_ISUPPORTS1(TelephonyListener, ns
 NS_IMETHODIMP
 TelephonyListener::CallStateChanged(uint32_t aServiceId,
                                     uint32_t aCallIndex,
                                     uint16_t aCallState,
                                     const nsAString& aNumber,
                                     bool aIsActive,
                                     bool aIsOutgoing,
                                     bool aIsEmergency,
-                                    bool aIsConference)
+                                    bool aIsConference,
+                                    bool aIsSwitchable,
+                                    bool aIsMergeable)
 {
   BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
   NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
 
   hfp->HandleCallStateChanged(aCallIndex, aCallState, EmptyString(), aNumber,
                               aIsOutgoing, aIsConference, true);
   return NS_OK;
 }
@@ -191,17 +193,19 @@ TelephonyListener::CallStateChanged(uint
 NS_IMETHODIMP
 TelephonyListener::EnumerateCallState(uint32_t aServiceId,
                                       uint32_t aCallIndex,
                                       uint16_t aCallState,
                                       const nsAString_internal& aNumber,
                                       bool aIsActive,
                                       bool aIsOutgoing,
                                       bool aIsEmergency,
-                                      bool aIsConference)
+                                      bool aIsConference,
+                                      bool aIsSwitchable,
+                                      bool aIsMergeable)
 {
   BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
   NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
 
   hfp->HandleCallStateChanged(aCallIndex, aCallState, EmptyString(), aNumber,
                               aIsOutgoing, aIsConference, false);
   return NS_OK;
 }
--- a/dom/browser-element/BrowserElementParent.cpp
+++ b/dom/browser-element/BrowserElementParent.cpp
@@ -234,22 +234,21 @@ BrowserElementParent::OpenWindowInProces
   // out-of-process, so we couldn't touch it if we tried.)
   //
   // GetScriptableTop gets us the <iframe mozbrowser>'s window; we'll use its
   // frame element, rather than aOpenerWindow's frame element, as our "opener
   // frame element" below.
   nsCOMPtr<nsIDOMWindow> topWindow;
   aOpenerWindow->GetScriptableTop(getter_AddRefs(topWindow));
 
-  nsCOMPtr<nsIDOMElement> openerFrameDOMElement;
-  topWindow->GetFrameElement(getter_AddRefs(openerFrameDOMElement));
-  NS_ENSURE_TRUE(openerFrameDOMElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
+  nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(topWindow);
 
-  nsCOMPtr<Element> openerFrameElement =
-    do_QueryInterface(openerFrameDOMElement);
+  nsCOMPtr<Element> openerFrameElement = win->GetFrameElementInternal();
+  NS_ENSURE_TRUE(openerFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
+
 
   nsRefPtr<HTMLIFrameElement> popupFrameElement =
     CreateIframe(openerFrameElement, aName, /* aRemote = */ false);
   NS_ENSURE_TRUE(popupFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
 
   nsAutoCString spec;
   if (aURI) {
     aURI->GetSpec(spec);
--- a/dom/camera/DOMCameraCapabilities.h
+++ b/dom/camera/DOMCameraCapabilities.h
@@ -9,16 +9,17 @@
 
 #include "nsString.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/CameraManagerBinding.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
+#include "nsPIDOMWindow.h"
 
 struct JSContext;
 class nsPIDOMWindow;
 
 namespace mozilla {
 
 class ICameraControl;
 class RecorderProfileManager;
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -8,17 +8,17 @@
 #include "mozilla/BasicEvents.h"
 
 #include "DataTransfer.h"
 
 #include "nsIDOMDocument.h"
 #include "nsIVariant.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsError.h"
 #include "nsIDragService.h"
 #include "nsIClipboard.h"
 #include "nsContentUtils.h"
 #include "nsIContent.h"
 #include "nsCRT.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptContext.h"
@@ -319,37 +319,42 @@ DataTransfer::GetFiles(ErrorResult& aRv)
 NS_IMETHODIMP
 DataTransfer::GetFiles(nsIDOMFileList** aFileList)
 {
   ErrorResult rv;
   *aFileList = GetFiles(rv);
   return rv.ErrorCode();
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 DataTransfer::Types()
 {
-  nsRefPtr<nsDOMStringList> types = new nsDOMStringList();
+  nsRefPtr<DOMStringList> types = new DOMStringList();
   if (mItems.Length()) {
+    bool addFile = false;
     const nsTArray<TransferItem>& item = mItems[0];
-    for (uint32_t i = 0; i < item.Length(); i++)
-      types->Add(item[i].mFormat);
+    for (uint32_t i = 0; i < item.Length(); i++) {
+      const nsString& format = item[i].mFormat;
+      types->Add(format);
+      if (!addFile) {
+        addFile = format.EqualsASCII(kFileMime) ||
+                  format.EqualsASCII("application/x-moz-file-promise");
+      }
+    }
 
-    bool filePresent, filePromisePresent;
-    types->Contains(NS_LITERAL_STRING(kFileMime), &filePresent);
-    types->Contains(NS_LITERAL_STRING("application/x-moz-file-promise"), &filePromisePresent);
-    if (filePresent || filePromisePresent)
+    if (addFile) {
       types->Add(NS_LITERAL_STRING("Files"));
+    }
   }
 
   return types.forget();
 }
 
 NS_IMETHODIMP
-DataTransfer::GetTypes(nsIDOMDOMStringList** aTypes)
+DataTransfer::GetTypes(nsISupports** aTypes)
 {
   *aTypes = Types().get();
 
   return NS_OK;
 }
 
 void
 DataTransfer::GetData(const nsAString& aFormat, nsAString& aData,
@@ -516,39 +521,39 @@ DataTransfer::GetMozSourceNode(nsIDOMNod
   if (!sourceNode) {
     *aSourceNode = nullptr;
     return NS_OK;
   }
 
   return CallQueryInterface(sourceNode, aSourceNode);
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 DataTransfer::MozTypesAt(uint32_t aIndex, ErrorResult& aRv)
 {
   // Only the first item is valid for clipboard events
   if (aIndex > 0 &&
       (mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return nullptr;
   }
 
-  nsRefPtr<nsDOMStringList> types = new nsDOMStringList();
+  nsRefPtr<DOMStringList> types = new DOMStringList();
   if (aIndex < mItems.Length()) {
     // note that you can retrieve the types regardless of their principal
     nsTArray<TransferItem>& item = mItems[aIndex];
     for (uint32_t i = 0; i < item.Length(); i++)
       types->Add(item[i].mFormat);
   }
 
   return types.forget();
 }
 
 NS_IMETHODIMP
-DataTransfer::MozTypesAt(uint32_t aIndex, nsIDOMDOMStringList** aTypes)
+DataTransfer::MozTypesAt(uint32_t aIndex, nsISupports** aTypes)
 {
   ErrorResult rv;
   *aTypes = MozTypesAt(aIndex, rv).get();
   return rv.ErrorCode();
 }
 
 NS_IMETHODIMP
 DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
--- a/dom/events/DataTransfer.h
+++ b/dom/events/DataTransfer.h
@@ -23,16 +23,17 @@ class nsEventStateManager;
 class nsINode;
 class nsITransferable;
 class nsISupportsArray;
 class nsILoadContext;
 
 namespace mozilla {
 namespace dom {
 
+class DOMStringList;
 class Element;
 template<typename T> class Optional;
 
 /**
  * TransferItem is used to hold data for a particular format. Each piece of
  * data has a principal set from the caller which added it. This allows a
  * caller that wishes to retrieve the data to only be able to access the data
  * it is allowed to, yet still allow a chrome caller to retrieve any of the
@@ -129,17 +130,17 @@ public:
     if (mEffectAllowed == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED) {
       aEffectAllowed.AssignLiteral("uninitialized");
     } else {
       aEffectAllowed.AssignASCII(sEffects[mEffectAllowed]);
     }
   }
   void SetDragImage(Element& aElement, int32_t aX, int32_t aY,
                     ErrorResult& aRv);
-  already_AddRefed<nsIDOMDOMStringList> Types();
+  already_AddRefed<DOMStringList> Types();
   void GetData(const nsAString& aFormat, nsAString& aData, ErrorResult& aRv);
   void SetData(const nsAString& aFormat, const nsAString& aData,
                ErrorResult& aRv);
   void ClearData(const mozilla::dom::Optional<nsAString>& aFormat,
                  mozilla::ErrorResult& aRv);
   nsDOMFileList* GetFiles(mozilla::ErrorResult& aRv);
   void AddElement(Element& aElement, mozilla::ErrorResult& aRv);
   uint32_t MozItemCount()
@@ -149,18 +150,18 @@ public:
   void GetMozCursor(nsString& aCursor)
   {
     if (mCursorState) {
       aCursor.AssignLiteral("default");
     } else {
       aCursor.AssignLiteral("auto");
     }
   }
-  already_AddRefed<nsIDOMDOMStringList> MozTypesAt(uint32_t aIndex,
-                                                   mozilla::ErrorResult& aRv);
+  already_AddRefed<DOMStringList> MozTypesAt(uint32_t aIndex,
+                                             mozilla::ErrorResult& aRv);
   void MozClearDataAt(const nsAString& aFormat, uint32_t aIndex,
                       mozilla::ErrorResult& aRv);
   void MozSetDataAt(JSContext* aCx, const nsAString& aFormat,
                     JS::Handle<JS::Value> aData, uint32_t aIndex,
                     mozilla::ErrorResult& aRv);
   JS::Value MozGetDataAt(JSContext* aCx, const nsAString& aFormat,
                          uint32_t aIndex, mozilla::ErrorResult& aRv);
   bool MozUserCancelled()
rename from dom/events/nsDOMDeviceMotionEvent.cpp
rename to dom/events/DeviceMotionEvent.cpp
--- a/dom/events/nsDOMDeviceMotionEvent.cpp
+++ b/dom/events/DeviceMotionEvent.cpp
@@ -1,141 +1,160 @@
 /* -*- 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 "nsDOMDeviceMotionEvent.h"
+#include "mozilla/dom/DeviceMotionEvent.h"
 #include "nsContentUtils.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED_3(nsDOMDeviceMotionEvent, nsDOMEvent,
+/******************************************************************************
+ * DeviceMotionEvent
+ *****************************************************************************/
+
+NS_IMPL_CYCLE_COLLECTION_INHERITED_3(DeviceMotionEvent, nsDOMEvent,
                                      mAcceleration,
                                      mAccelerationIncludingGravity,
                                      mRotationRate)
 
-NS_IMPL_ADDREF_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
+NS_IMPL_ADDREF_INHERITED(DeviceMotionEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(DeviceMotionEvent, nsDOMEvent)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMDeviceMotionEvent)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DeviceMotionEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
 void
-nsDOMDeviceMotionEvent::InitDeviceMotionEvent(const nsAString& aType,
-                                              bool aCanBubble,
-                                              bool aCancelable,
-                                              const DeviceAccelerationInit& aAcceleration,
-                                              const DeviceAccelerationInit& aAccelerationIncludingGravity,
-                                              const DeviceRotationRateInit& aRotationRate,
-                                              Nullable<double> aInterval,
-                                              ErrorResult& aRv)
+DeviceMotionEvent::InitDeviceMotionEvent(
+                     const nsAString& aType,
+                     bool aCanBubble,
+                     bool aCancelable,
+                     const DeviceAccelerationInit& aAcceleration,
+                     const DeviceAccelerationInit& aAccelIncludingGravity,
+                     const DeviceRotationRateInit& aRotationRate,
+                     Nullable<double> aInterval,
+                     ErrorResult& aRv)
 {
   aRv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
   if (aRv.Failed()) {
     return;
   }
 
-  mAcceleration = new nsDOMDeviceAcceleration(this, aAcceleration.mX,
-                                              aAcceleration.mY,
-                                              aAcceleration.mZ);
+  mAcceleration = new DeviceAcceleration(this, aAcceleration.mX,
+                                         aAcceleration.mY,
+                                         aAcceleration.mZ);
 
   mAccelerationIncludingGravity =
-    new nsDOMDeviceAcceleration(this, aAccelerationIncludingGravity.mX,
-                                aAccelerationIncludingGravity.mY,
-                                aAccelerationIncludingGravity.mZ);
+    new DeviceAcceleration(this, aAccelIncludingGravity.mX,
+                           aAccelIncludingGravity.mY,
+                           aAccelIncludingGravity.mZ);
 
-  mRotationRate = new nsDOMDeviceRotationRate(this, aRotationRate.mAlpha,
-                                              aRotationRate.mBeta,
-                                              aRotationRate.mGamma);
+  mRotationRate = new DeviceRotationRate(this, aRotationRate.mAlpha,
+                                         aRotationRate.mBeta,
+                                         aRotationRate.mGamma);
   mInterval = aInterval;
 }
 
-already_AddRefed<nsDOMDeviceMotionEvent>
-nsDOMDeviceMotionEvent::Constructor(const GlobalObject& aGlobal,
-                                    const nsAString& aType,
-                                    const DeviceMotionEventInit& aEventInitDict,
-                                    ErrorResult& aRv)
+already_AddRefed<DeviceMotionEvent>
+DeviceMotionEvent::Constructor(const GlobalObject& aGlobal,
+                               const nsAString& aType,
+                               const DeviceMotionEventInit& aEventInitDict,
+                               ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t =
-    do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMDeviceMotionEvent> e =
-    new nsDOMDeviceMotionEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<DeviceMotionEvent> e = new DeviceMotionEvent(t, nullptr, nullptr);
   aRv = e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
   if (aRv.Failed()) {
     return nullptr;
   }
   bool trusted = e->Init(t);
 
-  e->mAcceleration = new nsDOMDeviceAcceleration(e,
+  e->mAcceleration = new DeviceAcceleration(e,
     aEventInitDict.mAcceleration.mX,
     aEventInitDict.mAcceleration.mY,
     aEventInitDict.mAcceleration.mZ);
 
-  e->mAccelerationIncludingGravity = new nsDOMDeviceAcceleration(e,
+  e->mAccelerationIncludingGravity = new DeviceAcceleration(e,
     aEventInitDict.mAccelerationIncludingGravity.mX,
     aEventInitDict.mAccelerationIncludingGravity.mY,
     aEventInitDict.mAccelerationIncludingGravity.mZ);
 
-  e->mRotationRate = new nsDOMDeviceRotationRate(e,
+  e->mRotationRate = new DeviceRotationRate(e,
     aEventInitDict.mRotationRate.mAlpha,
     aEventInitDict.mRotationRate.mBeta,
     aEventInitDict.mRotationRate.mGamma);
 
   e->mInterval = aEventInitDict.mInterval;
   e->SetTrusted(trusted);
 
   return e.forget();
 }
 
+/******************************************************************************
+ * DeviceAcceleration
+ *****************************************************************************/
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DeviceAcceleration, mOwner)
+
+NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DeviceAcceleration, AddRef)
+NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DeviceAcceleration, Release)
+
+DeviceAcceleration::DeviceAcceleration(DeviceMotionEvent* aOwner,
+                                       Nullable<double> aX,
+                                       Nullable<double> aY,
+                                       Nullable<double> aZ)
+  : mOwner(aOwner)
+  , mX(aX)
+  , mY(aY)
+  , mZ(aZ)
+{
+  SetIsDOMBinding();
+}
+
+DeviceAcceleration::~DeviceAcceleration()
+{
+}
+
+/******************************************************************************
+ * DeviceRotationRate
+ *****************************************************************************/
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DeviceRotationRate, mOwner)
+
+NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DeviceRotationRate, AddRef)
+NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DeviceRotationRate, Release)
+
+DeviceRotationRate::DeviceRotationRate(DeviceMotionEvent* aOwner,
+                                       Nullable<double> aAlpha,
+                                       Nullable<double> aBeta,
+                                       Nullable<double> aGamma)
+  : mOwner(aOwner)
+  , mAlpha(aAlpha)
+  , mBeta(aBeta)
+  , mGamma(aGamma)
+{
+  SetIsDOMBinding();
+}
+
+DeviceRotationRate::~DeviceRotationRate()
+{
+}
+
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
 
 nsresult
 NS_NewDOMDeviceMotionEvent(nsIDOMEvent** aInstancePtrResult,
-                           mozilla::dom::EventTarget* aOwner,
+                           EventTarget* aOwner,
                            nsPresContext* aPresContext,
                            WidgetEvent* aEvent) 
 {
   NS_ENSURE_ARG_POINTER(aInstancePtrResult);
 
-  nsDOMDeviceMotionEvent* it =
-    new nsDOMDeviceMotionEvent(aOwner, aPresContext, aEvent);
+  DeviceMotionEvent* it = new DeviceMotionEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
-
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMDeviceAcceleration, mOwner)
-
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsDOMDeviceAcceleration, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsDOMDeviceAcceleration, Release)
-
-nsDOMDeviceAcceleration::nsDOMDeviceAcceleration(nsDOMDeviceMotionEvent* aOwner,
-                                                 Nullable<double> aX,
-                                                 Nullable<double> aY,
-                                                 Nullable<double> aZ)
-: mOwner(aOwner), mX(aX), mY(aY), mZ(aZ)
-{
-  SetIsDOMBinding();
-}
-
-nsDOMDeviceAcceleration::~nsDOMDeviceAcceleration()
-{
-}
-
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMDeviceRotationRate, mOwner)
-
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsDOMDeviceRotationRate, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsDOMDeviceRotationRate, Release)
-
-nsDOMDeviceRotationRate::nsDOMDeviceRotationRate(nsDOMDeviceMotionEvent* aOwner,
-                                                 Nullable<double> aAlpha,
-                                                 Nullable<double> aBeta,
-                                                 Nullable<double> aGamma)
-: mOwner(aOwner), mAlpha(aAlpha), mBeta(aBeta), mGamma(aGamma)
-{
-  SetIsDOMBinding();
-}
-
-nsDOMDeviceRotationRate::~nsDOMDeviceRotationRate()
-{
-}
rename from dom/events/nsDOMDeviceMotionEvent.h
rename to dom/events/DeviceMotionEvent.h
--- a/dom/events/nsDOMDeviceMotionEvent.h
+++ b/dom/events/DeviceMotionEvent.h
@@ -1,156 +1,161 @@
 /* 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 nsDOMDeviceMotionEvent_h__
-#define nsDOMDeviceMotionEvent_h__
+#ifndef mozilla_dom_DeviceMotionEvent_h_
+#define mozilla_dom_DeviceMotionEvent_h_
 
 #include "nsDOMEvent.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/DeviceMotionEventBinding.h"
 
-class nsDOMDeviceRotationRate MOZ_FINAL : public nsWrapperCache
+namespace mozilla {
+namespace dom {
+
+class DeviceRotationRate MOZ_FINAL : public nsWrapperCache
 {
 public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMDeviceRotationRate)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMDeviceRotationRate)
+  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate)
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate)
 
-  nsDOMDeviceRotationRate(nsDOMDeviceMotionEvent* aOwner,
-                          Nullable<double> aAlpha, Nullable<double> aBeta,
-                          Nullable<double> aGamma);
-  nsDOMDeviceRotationRate(double aAlpha, double aBeta, double aGamma)
+  DeviceRotationRate(DeviceMotionEvent* aOwner,
+                     Nullable<double> aAlpha, Nullable<double> aBeta,
+                     Nullable<double> aGamma);
+  DeviceRotationRate(double aAlpha, double aBeta, double aGamma)
   {
-    nsDOMDeviceRotationRate(nullptr, Nullable<double>(aAlpha),
-                            Nullable<double>(aBeta), Nullable<double>(aGamma));
+    DeviceRotationRate(nullptr, Nullable<double>(aAlpha),
+                       Nullable<double>(aBeta), Nullable<double>(aGamma));
   }
 
-  nsDOMDeviceMotionEvent* GetParentObject() const
+  DeviceMotionEvent* GetParentObject() const
   {
     return mOwner;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::DeviceRotationRateBinding::Wrap(aCx, aScope, this);
+    return DeviceRotationRateBinding::Wrap(aCx, aScope, this);
   }
 
   Nullable<double> GetAlpha() const { return mAlpha; }
   Nullable<double> GetBeta() const { return mBeta; }
   Nullable<double> GetGamma() const { return mGamma; }
 
 private:
-  ~nsDOMDeviceRotationRate();
+  ~DeviceRotationRate();
 
 protected:
-  nsRefPtr<nsDOMDeviceMotionEvent> mOwner;
+  nsRefPtr<DeviceMotionEvent> mOwner;
   Nullable<double> mAlpha, mBeta, mGamma;
 };
 
-class nsDOMDeviceAcceleration MOZ_FINAL : public nsWrapperCache
+class DeviceAcceleration MOZ_FINAL : public nsWrapperCache
 {
 public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMDeviceAcceleration)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMDeviceAcceleration)
+  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration)
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration)
 
-  nsDOMDeviceAcceleration(nsDOMDeviceMotionEvent* aOwner,
-                          Nullable<double> aX, Nullable<double> aY,
-                          Nullable<double> aZ);
-  nsDOMDeviceAcceleration(double aX, double aY, double aZ)
+  DeviceAcceleration(DeviceMotionEvent* aOwner,
+                     Nullable<double> aX, Nullable<double> aY,
+                     Nullable<double> aZ);
+  DeviceAcceleration(double aX, double aY, double aZ)
   {
-    nsDOMDeviceAcceleration(nullptr, Nullable<double>(aX),
-                            Nullable<double>(aY), Nullable<double>(aZ));
+    DeviceAcceleration(nullptr, Nullable<double>(aX),
+                       Nullable<double>(aY), Nullable<double>(aZ));
   }
 
-  nsDOMDeviceMotionEvent* GetParentObject() const
+  DeviceMotionEvent* GetParentObject() const
   {
     return mOwner;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::DeviceAccelerationBinding::Wrap(aCx, aScope, this);
+    return DeviceAccelerationBinding::Wrap(aCx, aScope, this);
   }
 
   Nullable<double> GetX() const { return mX; }
   Nullable<double> GetY() const { return mY; }
   Nullable<double> GetZ() const { return mZ; }
 
 private:
-  ~nsDOMDeviceAcceleration();
+  ~DeviceAcceleration();
 
 protected:
-  nsRefPtr<nsDOMDeviceMotionEvent> mOwner;
+  nsRefPtr<DeviceMotionEvent> mOwner;
   Nullable<double> mX, mY, mZ;
 };
 
-class nsDOMDeviceMotionEvent MOZ_FINAL : public nsDOMEvent
+class DeviceMotionEvent MOZ_FINAL : public nsDOMEvent
 {
-  typedef mozilla::dom::DeviceAccelerationInit DeviceAccelerationInit;
-  typedef mozilla::dom::DeviceRotationRateInit DeviceRotationRateInit;
 public:
 
-  nsDOMDeviceMotionEvent(mozilla::dom::EventTarget* aOwner,
-                         nsPresContext* aPresContext,
-                         mozilla::WidgetEvent* aEvent)
-  : nsDOMEvent(aOwner, aPresContext, aEvent)
+  DeviceMotionEvent(EventTarget* aOwner,
+                    nsPresContext* aPresContext,
+                    WidgetEvent* aEvent)
+    : nsDOMEvent(aOwner, aPresContext, aEvent)
   {
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Forward to nsDOMEvent
   NS_FORWARD_TO_NSDOMEVENT
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, nsDOMEvent)
 
   virtual JSObject* WrapObject(JSContext* aCx,
-			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::DeviceMotionEventBinding::Wrap(aCx, aScope, this);
+    return DeviceMotionEventBinding::Wrap(aCx, aScope, this);
   }
 
-  nsDOMDeviceAcceleration* GetAcceleration() const
+  DeviceAcceleration* GetAcceleration() const
   {
     return mAcceleration;
   }
 
-  nsDOMDeviceAcceleration* GetAccelerationIncludingGravity() const
+  DeviceAcceleration* GetAccelerationIncludingGravity() const
   {
     return mAccelerationIncludingGravity;
   }
 
-  nsDOMDeviceRotationRate* GetRotationRate() const
+  DeviceRotationRate* GetRotationRate() const
   {
     return mRotationRate;
   }
 
   Nullable<double> GetInterval() const
   {
     return mInterval;
   }
 
-  void InitDeviceMotionEvent(const nsAString& aType,
-                             bool aCanBubble,
-                             bool aCancelable,
-                             const DeviceAccelerationInit& aAcceleration,
-                             const DeviceAccelerationInit& aAccelerationIncludingGravity,
-                             const DeviceRotationRateInit& aRotationRate,
-                             Nullable<double> aInterval,
-                             mozilla::ErrorResult& aRv);
+  void InitDeviceMotionEvent(
+         const nsAString& aType,
+         bool aCanBubble,
+         bool aCancelable,
+         const DeviceAccelerationInit& aAcceleration,
+         const DeviceAccelerationInit& aAccelerationIncludingGravity,
+         const DeviceRotationRateInit& aRotationRate,
+         Nullable<double> aInterval,
+         ErrorResult& aRv);
 
-  static already_AddRefed<nsDOMDeviceMotionEvent>
-  Constructor(const mozilla::dom::GlobalObject& aGlobal,
+  static already_AddRefed<DeviceMotionEvent>
+  Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
-              const mozilla::dom::DeviceMotionEventInit& aEventInitDict,
-              mozilla::ErrorResult& aRv);
+              const DeviceMotionEventInit& aEventInitDict,
+              ErrorResult& aRv);
 
 protected:
-  nsRefPtr<nsDOMDeviceAcceleration> mAcceleration;
-  nsRefPtr<nsDOMDeviceAcceleration> mAccelerationIncludingGravity;
-  nsRefPtr<nsDOMDeviceRotationRate> mRotationRate;
+  nsRefPtr<DeviceAcceleration> mAcceleration;
+  nsRefPtr<DeviceAcceleration> mAccelerationIncludingGravity;
+  nsRefPtr<DeviceRotationRate> mRotationRate;
   Nullable<double> mInterval;
 };
 
-#endif
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_DeviceMotionEvent_h_
rename from dom/events/nsDOMDragEvent.cpp
rename to dom/events/DragEvent.cpp
--- a/dom/events/nsDOMDragEvent.cpp
+++ b/dom/events/DragEvent.cpp
@@ -1,106 +1,122 @@
 /* -*- 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 "nsDOMDragEvent.h"
+#include "mozilla/dom/DragEvent.h"
+#include "mozilla/MouseEvents.h"
 #include "nsContentUtils.h"
 #include "prtime.h"
-#include "mozilla/MouseEvents.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-nsDOMDragEvent::nsDOMDragEvent(EventTarget* aOwner,
-                               nsPresContext* aPresContext,
-                               WidgetDragEvent* aEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext, aEvent ? aEvent :
-                    new WidgetDragEvent(false, 0, nullptr))
+DragEvent::DragEvent(EventTarget* aOwner,
+                     nsPresContext* aPresContext,
+                     WidgetDragEvent* aEvent)
+  : MouseEvent(aOwner, aPresContext,
+               aEvent ? aEvent : new WidgetDragEvent(false, 0, nullptr))
 {
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     mEvent->AsMouseEvent()->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMDragEvent, nsDOMMouseEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMDragEvent, nsDOMMouseEvent)
+NS_IMPL_ADDREF_INHERITED(DragEvent, MouseEvent)
+NS_IMPL_RELEASE_INHERITED(DragEvent, MouseEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMDragEvent)
+NS_INTERFACE_MAP_BEGIN(DragEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMDragEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
+NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
 
 void
-nsDOMDragEvent::InitDragEvent(const nsAString& aType, bool aCanBubble,
-                              bool aCancelable, nsIDOMWindow* aView,
-                              int32_t aDetail, int32_t aScreenX,
-                              int32_t aScreenY, int32_t aClientX,
-                              int32_t aClientY, bool aCtrlKey, bool aAltKey,
-                              bool aShiftKey, bool aMetaKey, uint16_t aButton,
-                              EventTarget* aRelatedTarget,
-                              DataTransfer* aDataTransfer, ErrorResult& aError)
+DragEvent::InitDragEvent(const nsAString& aType,
+                         bool aCanBubble,
+                         bool aCancelable,
+                         nsIDOMWindow* aView,
+                         int32_t aDetail,
+                         int32_t aScreenX,
+                         int32_t aScreenY,
+                         int32_t aClientX,
+                         int32_t aClientY,
+                         bool aCtrlKey,
+                         bool aAltKey,
+                         bool aShiftKey,
+                         bool aMetaKey,
+                         uint16_t aButton,
+                         EventTarget* aRelatedTarget,
+                         DataTransfer* aDataTransfer,
+                         ErrorResult& aError)
 {
   aError =
-    nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
-                                    aView, aDetail, aScreenX, aScreenY,
-                                    aClientX, aClientY, aCtrlKey, aAltKey,
-                                    aShiftKey, aMetaKey, aButton,
-                                    aRelatedTarget);
+    MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
+                               aView, aDetail, aScreenX, aScreenY,
+                               aClientX, aClientY, aCtrlKey, aAltKey,
+                               aShiftKey, aMetaKey, aButton, aRelatedTarget);
   if (aError.Failed()) {
     return;
   }
 
   if (mEventIsInternal && mEvent) {
     mEvent->AsDragEvent()->dataTransfer = aDataTransfer;
   }
 }
 
 NS_IMETHODIMP
-nsDOMDragEvent::InitDragEvent(const nsAString & aType,
-                              bool aCanBubble, bool aCancelable,
-                              nsIDOMWindow* aView, int32_t aDetail,
-                              int32_t aScreenX, int32_t aScreenY,
-                              int32_t aClientX, int32_t aClientY, 
-                              bool aCtrlKey, bool aAltKey, bool aShiftKey,
-                              bool aMetaKey, uint16_t aButton,
-                              nsIDOMEventTarget *aRelatedTarget,
-                              nsIDOMDataTransfer* aDataTransfer)
+DragEvent::InitDragEvent(const nsAString& aType,
+                         bool aCanBubble,
+                         bool aCancelable,
+                         nsIDOMWindow* aView,
+                         int32_t aDetail,
+                         int32_t aScreenX,
+                         int32_t aScreenY,
+                         int32_t aClientX,
+                         int32_t aClientY,
+                         bool aCtrlKey,
+                         bool aAltKey,
+                         bool aShiftKey,
+                         bool aMetaKey,
+                         uint16_t aButton,
+                         nsIDOMEventTarget* aRelatedTarget,
+                         nsIDOMDataTransfer* aDataTransfer)
 {
   nsCOMPtr<DataTransfer> dataTransfer = do_QueryInterface(aDataTransfer);
   NS_ENSURE_ARG(dataTransfer);
 
-  nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
-                  aView, aDetail, aScreenX, aScreenY, aClientX, aClientY,
-                  aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
-                  aRelatedTarget);
+  nsresult rv =
+    MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
+                               aScreenX, aScreenY, aClientX, aClientY,
+                               aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
+                               aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mEventIsInternal && mEvent) {
     mEvent->AsDragEvent()->dataTransfer = dataTransfer;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDragEvent::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
+DragEvent::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
 {
   NS_IF_ADDREF(*aDataTransfer = GetDataTransfer());
   return NS_OK;
 }
 
 DataTransfer*
-nsDOMDragEvent::GetDataTransfer()
+DragEvent::GetDataTransfer()
 {
   // the dataTransfer field of the event caches the DataTransfer associated
   // with the drag. It is initialized when an attempt is made to retrieve it
   // rather that when the event is created to avoid duplicating the data when
   // no listener ever uses it.
   if (!mEvent || mEvent->eventStructType != NS_DRAG_EVENT) {
     NS_WARNING("Tried to get dataTransfer from non-drag event!");
     return nullptr;
@@ -111,16 +127,23 @@ nsDOMDragEvent::GetDataTransfer()
   if (!mEventIsInternal) {
     nsresult rv = nsContentUtils::SetDataTransferInEvent(dragEvent);
     NS_ENSURE_SUCCESS(rv, nullptr);
   }
 
   return dragEvent->dataTransfer;
 }
 
-nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
-                            EventTarget* aOwner,
-                            nsPresContext* aPresContext,
-                            WidgetDragEvent* aEvent) 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
+                   EventTarget* aOwner,
+                   nsPresContext* aPresContext,
+                   WidgetDragEvent* aEvent) 
 {
-  nsDOMDragEvent* event = new nsDOMDragEvent(aOwner, aPresContext, aEvent);
+  DragEvent* event = new DragEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(event, aInstancePtrResult);
 }
rename from dom/events/nsDOMDragEvent.h
rename to dom/events/DragEvent.h
--- a/dom/events/nsDOMDragEvent.h
+++ b/dom/events/DragEvent.h
@@ -1,59 +1,56 @@
 /* -*- 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/. */
 
-#ifndef nsDOMDragEvent_h__
-#define nsDOMDragEvent_h__
+#ifndef mozilla_dom_DragEvent_h_
+#define mozilla_dom_DragEvent_h_
 
 #include "nsIDOMDragEvent.h"
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/DragEventBinding.h"
 #include "mozilla/EventForwards.h"
 
 namespace mozilla {
 namespace dom {
+
 class DataTransfer;
-}
-}
 
-class nsDOMDragEvent : public nsDOMMouseEvent,
-                       public nsIDOMDragEvent
+class DragEvent : public MouseEvent,
+                  public nsIDOMDragEvent
 {
 public:
-  nsDOMDragEvent(mozilla::dom::EventTarget* aOwner,
-                 nsPresContext* aPresContext,
-                 mozilla::WidgetDragEvent* aEvent);
+  DragEvent(EventTarget* aOwner,
+            nsPresContext* aPresContext,
+            WidgetDragEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMDRAGEVENT
-  
-  NS_FORWARD_TO_NSDOMMOUSEEVENT
+
+  NS_FORWARD_TO_MOUSEEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::DragEventBinding::Wrap(aCx, aScope, this);
+    return DragEventBinding::Wrap(aCx, aScope, this);
   }
 
-  mozilla::dom::DataTransfer* GetDataTransfer();
+  DataTransfer* GetDataTransfer();
 
   void InitDragEvent(const nsAString& aType,
                      bool aCanBubble, bool aCancelable,
                      nsIDOMWindow* aView, int32_t aDetail,
                      int32_t aScreenX, int32_t aScreenY,
                      int32_t aClientX, int32_t aClientY,
                      bool aCtrlKey, bool aAltKey, bool aShiftKey,
                      bool aMetaKey, uint16_t aButton,
-                     mozilla::dom::EventTarget* aRelatedTarget,
-                     mozilla::dom::DataTransfer* aDataTransfer,
-                     mozilla::ErrorResult& aError);
+                     EventTarget* aRelatedTarget,
+                     DataTransfer* aDataTransfer,
+                     ErrorResult& aError);
 };
 
-nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
-                            mozilla::dom::EventTarget* aOwner,
-                            nsPresContext* aPresContext,
-                            mozilla::WidgetDragEvent* aEvent);
+} // namespace dom
+} // namespace mozilla
 
-#endif // nsDOMDragEvent_h__
+#endif // mozilla_dom_DragEvent_h_
rename from dom/events/nsDOMFocusEvent.cpp
rename to dom/events/FocusEvent.cpp
--- a/dom/events/nsDOMFocusEvent.cpp
+++ b/dom/events/FocusEvent.cpp
@@ -1,81 +1,88 @@
 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* 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 "nsDOMFocusEvent.h"
+#include "mozilla/dom/FocusEvent.h"
+#include "mozilla/ContentEvents.h"
 #include "prtime.h"
-#include "mozilla/ContentEvents.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_ISUPPORTS_INHERITED1(nsDOMFocusEvent, nsDOMUIEvent, nsIDOMFocusEvent)
+NS_IMPL_ISUPPORTS_INHERITED1(FocusEvent, nsDOMUIEvent, nsIDOMFocusEvent)
 
-nsDOMFocusEvent::nsDOMFocusEvent(mozilla::dom::EventTarget* aOwner,
-                                 nsPresContext* aPresContext,
-                                 InternalFocusEvent* aEvent)
+FocusEvent::FocusEvent(EventTarget* aOwner,
+                       nsPresContext* aPresContext,
+                       InternalFocusEvent* aEvent)
   : nsDOMUIEvent(aOwner, aPresContext,
                  aEvent ? aEvent :
                           new InternalFocusEvent(false, NS_FOCUS_CONTENT))
 {
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
   }
 }
 
 /* readonly attribute nsIDOMEventTarget relatedTarget; */
 NS_IMETHODIMP
-nsDOMFocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
+FocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
 {
   NS_ENSURE_ARG_POINTER(aRelatedTarget);
   NS_IF_ADDREF(*aRelatedTarget = GetRelatedTarget());
   return NS_OK;
 }
 
-mozilla::dom::EventTarget*
-nsDOMFocusEvent::GetRelatedTarget()
+EventTarget*
+FocusEvent::GetRelatedTarget()
 {
   return mEvent->AsFocusEvent()->relatedTarget;
 }
 
 nsresult
-nsDOMFocusEvent::InitFocusEvent(const nsAString& aType,
-                                bool aCanBubble,
-                                bool aCancelable,
-                                nsIDOMWindow* aView,
-                                int32_t aDetail,
-                                mozilla::dom::EventTarget* aRelatedTarget)
+FocusEvent::InitFocusEvent(const nsAString& aType,
+                           bool aCanBubble,
+                           bool aCancelable,
+                           nsIDOMWindow* aView,
+                           int32_t aDetail,
+                           EventTarget* aRelatedTarget)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
   mEvent->AsFocusEvent()->relatedTarget = aRelatedTarget;
   return NS_OK;
 }
 
-already_AddRefed<nsDOMFocusEvent>
-nsDOMFocusEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                             const nsAString& aType,
-                             const mozilla::dom::FocusEventInit& aParam,
-                             mozilla::ErrorResult& aRv)
+already_AddRefed<FocusEvent>
+FocusEvent::Constructor(const GlobalObject& aGlobal,
+                        const nsAString& aType,
+                        const FocusEventInit& aParam,
+                        ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMFocusEvent> e = new nsDOMFocusEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<FocusEvent> e = new FocusEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
   aRv = e->InitFocusEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
                           aParam.mDetail, aParam.mRelatedTarget);
   e->SetTrusted(trusted);
   return e.forget();
 }
 
-nsresult NS_NewDOMFocusEvent(nsIDOMEvent** aInstancePtrResult,
-                             mozilla::dom::EventTarget* aOwner,
-                             nsPresContext* aPresContext,
-                             InternalFocusEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMFocusEvent(nsIDOMEvent** aInstancePtrResult,
+                    EventTarget* aOwner,
+                    nsPresContext* aPresContext,
+                    InternalFocusEvent* aEvent)
 {
-  nsDOMFocusEvent* it = new nsDOMFocusEvent(aOwner, aPresContext, aEvent);
+  FocusEvent* it = new FocusEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMFocusEvent.h
rename to dom/events/FocusEvent.h
--- a/dom/events/nsDOMFocusEvent.h
+++ b/dom/events/FocusEvent.h
@@ -1,48 +1,54 @@
 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* 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 nsDOMFocusEvent_h_
-#define nsDOMFocusEvent_h_
+#ifndef mozilla_dom_FocusEvent_h_
+#define mozilla_dom_FocusEvent_h_
 
 #include "nsDOMUIEvent.h"
 #include "nsIDOMFocusEvent.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/FocusEventBinding.h"
 
-class nsDOMFocusEvent : public nsDOMUIEvent,
-                        public nsIDOMFocusEvent
+namespace mozilla {
+namespace dom {
+
+class FocusEvent : public nsDOMUIEvent,
+                   public nsIDOMFocusEvent
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMFOCUSEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::FocusEventBinding::Wrap(aCx, aScope, this);
+    return FocusEventBinding::Wrap(aCx, aScope, this);
   }
 
-  nsDOMFocusEvent(mozilla::dom::EventTarget* aOwner,
-                  nsPresContext* aPresContext,
-                  mozilla::InternalFocusEvent* aEvent);
+  FocusEvent(EventTarget* aOwner,
+             nsPresContext* aPresContext,
+             InternalFocusEvent* aEvent);
 
-  mozilla::dom::EventTarget* GetRelatedTarget();
+  EventTarget* GetRelatedTarget();
 
-  static already_AddRefed<nsDOMFocusEvent> Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                                                       const nsAString& aType,
-                                                       const mozilla::dom::FocusEventInit& aParam,
-                                                       mozilla::ErrorResult& aRv);
+  static already_AddRefed<FocusEvent> Constructor(const GlobalObject& aGlobal,
+                                                  const nsAString& aType,
+                                                  const FocusEventInit& aParam,
+                                                  ErrorResult& aRv);
 protected:
   nsresult InitFocusEvent(const nsAString& aType,
                           bool aCanBubble,
                           bool aCancelable,
                           nsIDOMWindow* aView,
                           int32_t aDetail,
-                          mozilla::dom::EventTarget* aRelatedTarget);
+                          EventTarget* aRelatedTarget);
 };
 
-#endif /* !defined(nsDOMFocusEvent_h_) */
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_FocusEvent_h_
copy from dom/events/MutationEvent.h
copy to dom/events/InternalMutationEvent.h
rename from dom/events/nsDOMKeyboardEvent.cpp
rename to dom/events/KeyboardEvent.cpp
--- a/dom/events/nsDOMKeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -1,174 +1,175 @@
 /* -*- 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 "nsDOMKeyboardEvent.h"
+#include "mozilla/dom/KeyboardEvent.h"
+#include "mozilla/TextEvents.h"
 #include "prtime.h"
-#include "mozilla/TextEvents.h"
 
-using namespace mozilla;
+namespace mozilla {
+namespace dom {
 
-nsDOMKeyboardEvent::nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner,
-                                       nsPresContext* aPresContext,
-                                       WidgetKeyboardEvent* aEvent)
+KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
+                             nsPresContext* aPresContext,
+                             WidgetKeyboardEvent* aEvent)
   : nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
                  new WidgetKeyboardEvent(false, 0, nullptr))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_KEY_EVENT, "event type mismatch");
 
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->AsKeyboardEvent()->mKeyNameIndex = KEY_NAME_INDEX_USE_STRING;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
+NS_IMPL_ADDREF_INHERITED(KeyboardEvent, nsDOMUIEvent)
+NS_IMPL_RELEASE_INHERITED(KeyboardEvent, nsDOMUIEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMKeyboardEvent)
+NS_INTERFACE_MAP_BEGIN(KeyboardEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
 
 bool
-nsDOMKeyboardEvent::AltKey()
+KeyboardEvent::AltKey()
 {
   return mEvent->AsKeyboardEvent()->IsAlt();
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetAltKey(bool* aIsDown)
+KeyboardEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = AltKey();
   return NS_OK;
 }
 
 bool
-nsDOMKeyboardEvent::CtrlKey()
+KeyboardEvent::CtrlKey()
 {
   return mEvent->AsKeyboardEvent()->IsControl();
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetCtrlKey(bool* aIsDown)
+KeyboardEvent::GetCtrlKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = CtrlKey();
   return NS_OK;
 }
 
 bool
-nsDOMKeyboardEvent::ShiftKey()
+KeyboardEvent::ShiftKey()
 {
   return mEvent->AsKeyboardEvent()->IsShift();
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetShiftKey(bool* aIsDown)
+KeyboardEvent::GetShiftKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = ShiftKey();
   return NS_OK;
 }
 
 bool
-nsDOMKeyboardEvent::MetaKey()
+KeyboardEvent::MetaKey()
 {
   return mEvent->AsKeyboardEvent()->IsMeta();
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetMetaKey(bool* aIsDown)
+KeyboardEvent::GetMetaKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = MetaKey();
   return NS_OK;
 }
 
 bool
-nsDOMKeyboardEvent::Repeat()
+KeyboardEvent::Repeat()
 {
   return mEvent->AsKeyboardEvent()->mIsRepeat;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetRepeat(bool* aIsRepeat)
+KeyboardEvent::GetRepeat(bool* aIsRepeat)
 {
   NS_ENSURE_ARG_POINTER(aIsRepeat);
   *aIsRepeat = Repeat();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetModifierState(const nsAString& aKey,
-                                     bool* aState)
+KeyboardEvent::GetModifierState(const nsAString& aKey,
+                                bool* aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
 
   *aState = GetModifierState(aKey);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetKey(nsAString& aKeyName)
+KeyboardEvent::GetKey(nsAString& aKeyName)
 {
   mEvent->AsKeyboardEvent()->GetDOMKeyName(aKeyName);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetCharCode(uint32_t* aCharCode)
+KeyboardEvent::GetCharCode(uint32_t* aCharCode)
 {
   NS_ENSURE_ARG_POINTER(aCharCode);
   *aCharCode = CharCode();
   return NS_OK;
 }
 
 uint32_t
-nsDOMKeyboardEvent::CharCode()
+KeyboardEvent::CharCode()
 {
   switch (mEvent->message) {
   case NS_KEY_UP:
   case NS_KEY_DOWN:
     return 0;
   case NS_KEY_PRESS:
     return mEvent->AsKeyboardEvent()->charCode;
   }
   return 0;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetKeyCode(uint32_t* aKeyCode)
+KeyboardEvent::GetKeyCode(uint32_t* aKeyCode)
 {
   NS_ENSURE_ARG_POINTER(aKeyCode);
   *aKeyCode = KeyCode();
   return NS_OK;
 }
 
 uint32_t
-nsDOMKeyboardEvent::KeyCode()
+KeyboardEvent::KeyCode()
 {
   switch (mEvent->message) {
   case NS_KEY_UP:
   case NS_KEY_PRESS:
   case NS_KEY_DOWN:
     return mEvent->AsKeyboardEvent()->keyCode;
   }
   return 0;
 }
 
 uint32_t
-nsDOMKeyboardEvent::Which()
+KeyboardEvent::Which()
 {
   switch (mEvent->message) {
     case NS_KEY_UP:
     case NS_KEY_DOWN:
       return KeyCode();
     case NS_KEY_PRESS:
       //Special case for 4xp bug 62878.  Try to make value of which
       //more closely mirror the values that 4.x gave for RETURN and BACKSPACE
@@ -180,47 +181,60 @@ nsDOMKeyboardEvent::Which()
         return CharCode();
       }
   }
 
   return 0;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetLocation(uint32_t* aLocation)
+KeyboardEvent::GetLocation(uint32_t* aLocation)
 {
   NS_ENSURE_ARG_POINTER(aLocation);
 
   *aLocation = Location();
   return NS_OK;
 }
 
 uint32_t
-nsDOMKeyboardEvent::Location()
+KeyboardEvent::Location()
 {
   return mEvent->AsKeyboardEvent()->location;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
-                                 nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
-                                 bool aShiftKey, bool aMetaKey,
-                                 uint32_t aKeyCode, uint32_t aCharCode)
+KeyboardEvent::InitKeyEvent(const nsAString& aType,
+                            bool aCanBubble,
+                            bool aCancelable,
+                            nsIDOMWindow* aView,
+                            bool aCtrlKey,
+                            bool aAltKey,
+                            bool aShiftKey,
+                            bool aMetaKey,
+                            uint32_t aKeyCode,
+                            uint32_t aCharCode)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
   keyEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
   keyEvent->keyCode = aKeyCode;
   keyEvent->charCode = aCharCode;
 
   return NS_OK;
 }
 
-nsresult NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
-                                mozilla::dom::EventTarget* aOwner,
-                                nsPresContext* aPresContext,
-                                WidgetKeyboardEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
+                       EventTarget* aOwner,
+                       nsPresContext* aPresContext,
+                       WidgetKeyboardEvent* aEvent)
 {
-  nsDOMKeyboardEvent* it = new nsDOMKeyboardEvent(aOwner, aPresContext, aEvent);
+  KeyboardEvent* it = new KeyboardEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMKeyboardEvent.h
rename to dom/events/KeyboardEvent.h
--- a/dom/events/nsDOMKeyboardEvent.h
+++ b/dom/events/KeyboardEvent.h
@@ -1,41 +1,44 @@
 /* -*- 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/. */
 
-#ifndef nsDOMKeyboardEvent_h__
-#define nsDOMKeyboardEvent_h__
+#ifndef mozilla_dom_KeyboardEvent_h_
+#define mozilla_dom_KeyboardEvent_h_
 
 #include "nsIDOMKeyEvent.h"
 #include "nsDOMUIEvent.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/KeyboardEventBinding.h"
 
-class nsDOMKeyboardEvent : public nsDOMUIEvent,
-                           public nsIDOMKeyEvent
+namespace mozilla {
+namespace dom {
+
+class KeyboardEvent : public nsDOMUIEvent,
+                      public nsIDOMKeyEvent
 {
 public:
-  nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner,
-                     nsPresContext* aPresContext,
-                     mozilla::WidgetKeyboardEvent* aEvent);
+  KeyboardEvent(EventTarget* aOwner,
+                nsPresContext* aPresContext,
+                WidgetKeyboardEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMKeyEvent Interface
   NS_DECL_NSIDOMKEYEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::KeyboardEventBinding::Wrap(aCx, aScope, this);
+    return KeyboardEventBinding::Wrap(aCx, aScope, this);
   }
 
   bool AltKey();
   bool CtrlKey();
   bool ShiftKey();
   bool MetaKey();
 
   bool GetModifierState(const nsAString& aKey)
@@ -48,18 +51,20 @@ public:
   uint32_t KeyCode();
   virtual uint32_t Which() MOZ_OVERRIDE;
   uint32_t Location();
 
   void InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
                     nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
                     bool aShiftKey, bool aMetaKey,
                     uint32_t aKeyCode, uint32_t aCharCode,
-                    mozilla::ErrorResult& aRv)
+                    ErrorResult& aRv)
   {
     aRv = InitKeyEvent(aType, aCanBubble, aCancelable, aView,
                        aCtrlKey, aAltKey, aShiftKey,aMetaKey,
                        aKeyCode, aCharCode);
   }
 };
 
+} // namespace dom
+} // namespace mozilla
 
-#endif // nsDOMKeyboardEvent_h__
+#endif // mozilla_dom_KeyboardEvent_h_
rename from dom/events/nsDOMMessageEvent.cpp
rename to dom/events/MessageEvent.cpp
--- a/dom/events/nsDOMMessageEvent.cpp
+++ b/dom/events/MessageEvent.cpp
@@ -1,131 +1,129 @@
 /* -*- 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 "nsDOMMessageEvent.h"
+#include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePort.h"
 #include "mozilla/dom/MessagePortBinding.h"
 #include "mozilla/dom/MessagePortList.h"
 #include "mozilla/dom/UnionTypes.h"
 
 #include "mozilla/HoldDropJSObjects.h"
 #include "jsapi.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMessageEvent)
+NS_IMPL_CYCLE_COLLECTION_CLASS(MessageEvent)
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   tmp->mData = JSVAL_VOID;
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindowSource)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPortSource)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPorts)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindowSource)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPortSource)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPorts)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mData)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMMessageEvent)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MessageEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMessageEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMessageEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_ADDREF_INHERITED(MessageEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(MessageEvent, nsDOMEvent)
 
-nsDOMMessageEvent::nsDOMMessageEvent(mozilla::dom::EventTarget* aOwner,
-                                     nsPresContext* aPresContext,
-                                     WidgetEvent* aEvent)
-  : nsDOMEvent(aOwner, aPresContext, aEvent),
-    mData(JSVAL_VOID)
+MessageEvent::MessageEvent(EventTarget* aOwner,
+                           nsPresContext* aPresContext,
+                           WidgetEvent* aEvent)
+  : nsDOMEvent(aOwner, aPresContext, aEvent)
+  , mData(JSVAL_VOID)
 {
 }
 
-nsDOMMessageEvent::~nsDOMMessageEvent()
+MessageEvent::~MessageEvent()
 {
   mData = JSVAL_VOID;
-  mozilla::DropJSObjects(this);
+  DropJSObjects(this);
 }
 
 JSObject*
-nsDOMMessageEvent::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
+MessageEvent::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return mozilla::dom::MessageEventBinding::Wrap(aCx, aScope, this);
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
+MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
 {
   ErrorResult rv;
   aData.set(GetData(aCx, rv));
   return rv.ErrorCode();
 }
 
 JS::Value
-nsDOMMessageEvent::GetData(JSContext* aCx, ErrorResult& aRv)
+MessageEvent::GetData(JSContext* aCx, ErrorResult& aRv)
 {
   JS::Rooted<JS::Value> data(aCx, mData);
   if (!JS_WrapValue(aCx, &data)) {
     aRv.Throw(NS_ERROR_FAILURE);
   }
   return data;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetOrigin(nsAString& aOrigin)
+MessageEvent::GetOrigin(nsAString& aOrigin)
 {
   aOrigin = mOrigin;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetLastEventId(nsAString& aLastEventId)
+MessageEvent::GetLastEventId(nsAString& aLastEventId)
 {
   aLastEventId = mLastEventId;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetSource(nsIDOMWindow** aSource)
+MessageEvent::GetSource(nsIDOMWindow** aSource)
 {
   NS_IF_ADDREF(*aSource = mWindowSource);
   return NS_OK;
 }
 
 void
-nsDOMMessageEvent::GetSource(Nullable<mozilla::dom::OwningWindowProxyOrMessagePort>& aValue) const
+MessageEvent::GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const
 {
   if (mWindowSource) {
     aValue.SetValue().SetAsWindowProxy() = mWindowSource;
   } else if (mPortSource) {
     aValue.SetValue().SetAsMessagePort() = mPortSource;
   }
 }
 
-/* static */ already_AddRefed<nsDOMMessageEvent>
-nsDOMMessageEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                               JSContext* aCx, const nsAString& aType,
-                               const mozilla::dom::MessageEventInit& aParam,
-                               mozilla::ErrorResult& aRv)
+/* static */ already_AddRefed<MessageEvent>
+MessageEvent::Constructor(const GlobalObject& aGlobal,
+                          JSContext* aCx, const nsAString& aType,
+                          const MessageEventInit& aParam,
+                          ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t =
-    do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMMessageEvent> event =
-    new nsDOMMessageEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<MessageEvent> event = new MessageEvent(t, nullptr, nullptr);
 
   aRv = event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   bool trusted = event->Init(t);
   event->SetTrusted(trusted);
@@ -161,45 +159,50 @@ nsDOMMessageEvent::Constructor(const moz
     event->mPorts = new MessagePortList(static_cast<nsDOMEventBase*>(event),
                                         ports);
   }
 
   return event.forget();
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::InitMessageEvent(const nsAString& aType,
-                                    bool aCanBubble,
-                                    bool aCancelable,
-                                    JS::Handle<JS::Value> aData,
-                                    const nsAString& aOrigin,
-                                    const nsAString& aLastEventId,
-                                    nsIDOMWindow* aSource)
+MessageEvent::InitMessageEvent(const nsAString& aType,
+                               bool aCanBubble,
+                               bool aCancelable,
+                               JS::Handle<JS::Value> aData,
+                               const nsAString& aOrigin,
+                               const nsAString& aLastEventId,
+                               nsIDOMWindow* aSource)
 {
   nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mData = aData;
   mozilla::HoldJSObjects(this);
   mOrigin = aOrigin;
   mLastEventId = aLastEventId;
   mWindowSource = aSource;
 
   return NS_OK;
 }
 
 void
-nsDOMMessageEvent::SetPorts(mozilla::dom::MessagePortList* aPorts)
+MessageEvent::SetPorts(MessagePortList* aPorts)
 {
   MOZ_ASSERT(!mPorts && aPorts);
   mPorts = aPorts;
 }
 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
 nsresult
 NS_NewDOMMessageEvent(nsIDOMEvent** aInstancePtrResult,
-                      mozilla::dom::EventTarget* aOwner,
+                      EventTarget* aOwner,
                       nsPresContext* aPresContext,
                       WidgetEvent* aEvent) 
 {
-  nsDOMMessageEvent* it = new nsDOMMessageEvent(aOwner, aPresContext, aEvent);
-
+  MessageEvent* it = new MessageEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMMessageEvent.h
rename to dom/events/MessageEvent.h
--- a/dom/events/nsDOMMessageEvent.h
+++ b/dom/events/MessageEvent.h
@@ -1,77 +1,79 @@
 /* -*- 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/. */
 
-#ifndef nsDOMMessageEvent_h__
-#define nsDOMMessageEvent_h__
+#ifndef mozilla_dom_MessageEvent_h_
+#define mozilla_dom_MessageEvent_h_
 
 #include "nsIDOMMessageEvent.h"
 #include "nsDOMEvent.h"
 #include "nsCycleCollectionParticipant.h"
 
 namespace mozilla {
 namespace dom {
+
 class MessageEventInit;
 class MessagePort;
 class MessagePortBase;
 class MessagePortList;
 class OwningWindowProxyOrMessagePort;
-}
-}
 
 /**
  * Implements the MessageEvent event, used for cross-document messaging and
  * server-sent events.
  *
  * See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for
  * further details.
  */
-class nsDOMMessageEvent : public nsDOMEvent,
-                          public nsIDOMMessageEvent
+class MessageEvent : public nsDOMEvent,
+                     public nsIDOMMessageEvent
 {
 public:
-  nsDOMMessageEvent(mozilla::dom::EventTarget* aOwner,
-                    nsPresContext* aPresContext,
-                    mozilla::WidgetEvent* aEvent);
-  ~nsDOMMessageEvent();
+  MessageEvent(EventTarget* aOwner,
+               nsPresContext* aPresContext,
+               WidgetEvent* aEvent);
+  ~MessageEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMMessageEvent,
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent,
                                                          nsDOMEvent)
 
   NS_DECL_NSIDOMMESSAGEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
-  JS::Value GetData(JSContext* aCx, mozilla::ErrorResult& aRv);
+  JS::Value GetData(JSContext* aCx, ErrorResult& aRv);
 
-  void GetSource(Nullable<mozilla::dom::OwningWindowProxyOrMessagePort>& aValue) const;
+  void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
 
-  mozilla::dom::MessagePortList* GetPorts()
+  MessagePortList* GetPorts()
   {
     return mPorts;
   }
 
-  void SetPorts(mozilla::dom::MessagePortList* aPorts);
+  void SetPorts(MessagePortList* aPorts);
 
-  static already_AddRefed<nsDOMMessageEvent>
-  Constructor(const mozilla::dom::GlobalObject& aGlobal, JSContext* aCx,
+  static already_AddRefed<MessageEvent>
+  Constructor(const GlobalObject& aGlobal, JSContext* aCx,
               const nsAString& aType,
-              const mozilla::dom::MessageEventInit& aEventInit,
-              mozilla::ErrorResult& aRv);
+              const MessageEventInit& aEventInit,
+              ErrorResult& aRv);
 
 private:
   JS::Heap<JS::Value> mData;
   nsString mOrigin;
   nsString mLastEventId;
   nsCOMPtr<nsIDOMWindow> mWindowSource;
-  nsRefPtr<mozilla::dom::MessagePortBase> mPortSource;
-  nsRefPtr<mozilla::dom::MessagePortList> mPorts;
+  nsRefPtr<MessagePortBase> mPortSource;
+  nsRefPtr<MessagePortList> mPorts;
 };
 
-#endif // nsDOMMessageEvent_h__
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_MessageEvent_h_
rename from dom/events/nsDOMMouseEvent.cpp
rename to dom/events/MouseEvent.cpp
--- a/dom/events/nsDOMMouseEvent.cpp
+++ b/dom/events/MouseEvent.cpp
@@ -1,24 +1,25 @@
 /* -*- 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 "nsDOMMouseEvent.h"
-#include "nsIContent.h"
+#include "mozilla/dom/MouseEvent.h"
+#include "mozilla/MouseEvents.h"
 #include "nsContentUtils.h"
+#include "nsIContent.h"
 #include "prtime.h"
-#include "mozilla/MouseEvents.h"
 
-using namespace mozilla;
+namespace mozilla {
+namespace dom {
 
-nsDOMMouseEvent::nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
-                                 nsPresContext* aPresContext,
-                                 WidgetMouseEventBase* aEvent)
+MouseEvent::MouseEvent(EventTarget* aOwner,
+                       nsPresContext* aPresContext,
+                       WidgetMouseEventBase* aEvent)
   : nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
                  new WidgetMouseEvent(false, 0, nullptr,
                                       WidgetMouseEvent::eReal))
 {
   // There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
   // It's not that important, though, since a scroll event is not a real
   // DOM event.
 
@@ -35,29 +36,39 @@ nsDOMMouseEvent::nsDOMMouseEvent(mozilla
 
   if (mouseEvent) {
     MOZ_ASSERT(mouseEvent->reason != WidgetMouseEvent::eSynthesized,
                "Don't dispatch DOM events from synthesized mouse events");
     mDetail = mouseEvent->clickCount;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMouseEvent, nsDOMUIEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMouseEvent, nsDOMUIEvent)
+NS_IMPL_ADDREF_INHERITED(MouseEvent, nsDOMUIEvent)
+NS_IMPL_RELEASE_INHERITED(MouseEvent, nsDOMUIEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMMouseEvent)
+NS_INTERFACE_MAP_BEGIN(MouseEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
 
 NS_IMETHODIMP
-nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                                nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX, 
-                                int32_t aScreenY, int32_t aClientX, int32_t aClientY, 
-                                bool aCtrlKey, bool aAltKey, bool aShiftKey, 
-                                bool aMetaKey, uint16_t aButton, nsIDOMEventTarget *aRelatedTarget)
+MouseEvent::InitMouseEvent(const nsAString& aType,
+                           bool aCanBubble,
+                           bool aCancelable,
+                           nsIDOMWindow* aView,
+                           int32_t aDetail,
+                           int32_t aScreenX,
+                           int32_t aScreenY,
+                           int32_t aClientX,
+                           int32_t aClientY, 
+                           bool aCtrlKey,
+                           bool aAltKey,
+                           bool aShiftKey,
+                           bool aMetaKey,
+                           uint16_t aButton,
+                           nsIDOMEventTarget* aRelatedTarget)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
 
   switch(mEvent->eventStructType) {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
@@ -82,28 +93,28 @@ nsDOMMouseEvent::InitMouseEvent(const ns
     default:
        break;
   }
 
   return NS_OK;
 }   
 
 nsresult
-nsDOMMouseEvent::InitMouseEvent(const nsAString& aType,
-                                bool aCanBubble,
-                                bool aCancelable,
-                                nsIDOMWindow* aView,
-                                int32_t aDetail,
-                                int32_t aScreenX,
-                                int32_t aScreenY,
-                                int32_t aClientX,
-                                int32_t aClientY,
-                                int16_t aButton,
-                                nsIDOMEventTarget *aRelatedTarget,
-                                const nsAString& aModifiersList)
+MouseEvent::InitMouseEvent(const nsAString& aType,
+                           bool aCanBubble,
+                           bool aCancelable,
+                           nsIDOMWindow* aView,
+                           int32_t aDetail,
+                           int32_t aScreenX,
+                           int32_t aScreenY,
+                           int32_t aClientX,
+                           int32_t aClientY,
+                           int16_t aButton,
+                           nsIDOMEventTarget* aRelatedTarget,
+                           const nsAString& aModifiersList)
 {
   Modifiers modifiers = ComputeModifierState(aModifiersList);
 
   nsresult rv = InitMouseEvent(aType, aCanBubble, aCancelable, aView,
                                aDetail, aScreenX, aScreenY, aClientX, aClientY,
                                (modifiers & MODIFIER_CONTROL) != 0,
                                (modifiers & MODIFIER_ALT) != 0,
                                (modifiers & MODIFIER_SHIFT) != 0,
@@ -120,24 +131,24 @@ nsDOMMouseEvent::InitMouseEvent(const ns
     case NS_SIMPLE_GESTURE_EVENT:
       mEvent->AsInputEvent()->modifiers = modifiers;
       return NS_OK;
     default:
       MOZ_CRASH("There is no space to store the modifiers");
   }
 }
 
-already_AddRefed<nsDOMMouseEvent>
-nsDOMMouseEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                             const nsAString& aType,
-                             const mozilla::dom::MouseEventInit& aParam,
-                             mozilla::ErrorResult& aRv)
+already_AddRefed<MouseEvent>
+MouseEvent::Constructor(const GlobalObject& aGlobal,
+                        const nsAString& aType,
+                        const MouseEventInit& aParam,
+                        ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMMouseEvent> e = new nsDOMMouseEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<MouseEvent> e = new MouseEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
   e->InitMouseEvent(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,
                     aRv);
   e->SetTrusted(trusted);
@@ -154,45 +165,57 @@ nsDOMMouseEvent::Constructor(const mozil
     default:
       break;
   }
 
   return e.forget();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::InitNSMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                                  nsIDOMWindow *aView, int32_t aDetail, int32_t aScreenX,
-                                  int32_t aScreenY, int32_t aClientX, int32_t aClientY,
-                                  bool aCtrlKey, bool aAltKey, bool aShiftKey,
-                                  bool aMetaKey, uint16_t aButton, nsIDOMEventTarget *aRelatedTarget,
-                                  float aPressure, uint16_t aInputSource)
+MouseEvent::InitNSMouseEvent(const nsAString& aType,
+                             bool aCanBubble,
+                             bool aCancelable,
+                             nsIDOMWindow* aView,
+                             int32_t aDetail,
+                             int32_t aScreenX,
+                             int32_t aScreenY,
+                             int32_t aClientX,
+                             int32_t aClientY,
+                             bool aCtrlKey,
+                             bool aAltKey,
+                             bool aShiftKey,
+                             bool aMetaKey,
+                             uint16_t aButton,
+                             nsIDOMEventTarget* aRelatedTarget,
+                             float aPressure,
+                             uint16_t aInputSource)
 {
-  nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
-                                                aView, aDetail, aScreenX, aScreenY,
-                                                aClientX, aClientY, aCtrlKey, aAltKey, aShiftKey,
-                                                aMetaKey, aButton, aRelatedTarget);
+  nsresult rv = MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
+                                           aView, aDetail, aScreenX, aScreenY,
+                                           aClientX, aClientY,
+                                           aCtrlKey, aAltKey, aShiftKey,
+                                           aMetaKey, aButton, aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
   mouseEventBase->pressure = aPressure;
   mouseEventBase->inputSource = aInputSource;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetButton(int16_t* aButton)
+MouseEvent::GetButton(int16_t* aButton)
 {
   NS_ENSURE_ARG_POINTER(aButton);
   *aButton = Button();
   return NS_OK;
 }
 
 int16_t
-nsDOMMouseEvent::Button()
+MouseEvent::Button()
 {
   switch(mEvent->eventStructType)
   {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
     case NS_DRAG_EVENT:
     case NS_POINTER_EVENT:
@@ -200,52 +223,52 @@ nsDOMMouseEvent::Button()
       return mEvent->AsMouseEventBase()->button;
     default:
       NS_WARNING("Tried to get mouse button for non-mouse event!");
       return WidgetMouseEvent::eLeftButton;
   }
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetButtons(uint16_t* aButtons)
+MouseEvent::GetButtons(uint16_t* aButtons)
 {
   NS_ENSURE_ARG_POINTER(aButtons);
   *aButtons = Buttons();
   return NS_OK;
 }
 
 uint16_t
-nsDOMMouseEvent::Buttons()
+MouseEvent::Buttons()
 {
   switch(mEvent->eventStructType)
   {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
     case NS_DRAG_EVENT:
     case NS_POINTER_EVENT:
     case NS_SIMPLE_GESTURE_EVENT:
       return mEvent->AsMouseEventBase()->buttons;
     default:
       MOZ_CRASH("Tried to get mouse buttons for non-mouse event!");
   }
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
+MouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
 {
   NS_ENSURE_ARG_POINTER(aRelatedTarget);
   *aRelatedTarget = GetRelatedTarget().get();
   return NS_OK;
 }
 
-already_AddRefed<mozilla::dom::EventTarget>
-nsDOMMouseEvent::GetRelatedTarget()
+already_AddRefed<EventTarget>
+MouseEvent::GetRelatedTarget()
 {
-  nsCOMPtr<mozilla::dom::EventTarget> relatedTarget;
+  nsCOMPtr<EventTarget> relatedTarget;
   switch(mEvent->eventStructType)
   {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
     case NS_DRAG_EVENT:
     case NS_POINTER_EVENT:
     case NS_SIMPLE_GESTURE_EVENT:
@@ -267,192 +290,201 @@ nsDOMMouseEvent::GetRelatedTarget()
       relatedTarget = relatedTarget->GetTargetForDOMEvent();
     }
     return relatedTarget.forget();
   }
   return nullptr;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMozMovementX(int32_t* aMovementX)
+MouseEvent::GetMozMovementX(int32_t* aMovementX)
 {
   NS_ENSURE_ARG_POINTER(aMovementX);
   *aMovementX = MozMovementX();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMozMovementY(int32_t* aMovementY)
+MouseEvent::GetMozMovementY(int32_t* aMovementY)
 {
   NS_ENSURE_ARG_POINTER(aMovementY);
   *aMovementY = MozMovementY();
 
   return NS_OK;
 }
 
-NS_METHOD nsDOMMouseEvent::GetScreenX(int32_t* aScreenX)
+NS_IMETHODIMP
+MouseEvent::GetScreenX(int32_t* aScreenX)
 {
   NS_ENSURE_ARG_POINTER(aScreenX);
   *aScreenX = ScreenX();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseEvent::ScreenX()
+MouseEvent::ScreenX()
 {
   return nsDOMEvent::GetScreenCoords(mPresContext,
                                      mEvent,
                                      mEvent->refPoint).x;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetScreenY(int32_t* aScreenY)
+MouseEvent::GetScreenY(int32_t* aScreenY)
 {
   NS_ENSURE_ARG_POINTER(aScreenY);
   *aScreenY = ScreenY();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseEvent::ScreenY()
+MouseEvent::ScreenY()
 {
   return nsDOMEvent::GetScreenCoords(mPresContext,
                                      mEvent,
                                      mEvent->refPoint).y;
 }
 
 
-NS_METHOD nsDOMMouseEvent::GetClientX(int32_t* aClientX)
+NS_IMETHODIMP
+MouseEvent::GetClientX(int32_t* aClientX)
 {
   NS_ENSURE_ARG_POINTER(aClientX);
   *aClientX = ClientX();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseEvent::ClientX()
+MouseEvent::ClientX()
 {
   return nsDOMEvent::GetClientCoords(mPresContext,
                                      mEvent,
                                      mEvent->refPoint,
                                      mClientPoint).x;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetClientY(int32_t* aClientY)
+MouseEvent::GetClientY(int32_t* aClientY)
 {
   NS_ENSURE_ARG_POINTER(aClientY);
   *aClientY = ClientY();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseEvent::ClientY()
+MouseEvent::ClientY()
 {
   return nsDOMEvent::GetClientCoords(mPresContext,
                                      mEvent,
                                      mEvent->refPoint,
                                      mClientPoint).y;
 }
 
 bool
-nsDOMMouseEvent::AltKey()
+MouseEvent::AltKey()
 {
   return mEvent->AsInputEvent()->IsAlt();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetAltKey(bool* aIsDown)
+MouseEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = AltKey();
   return NS_OK;
 }
 
 bool
-nsDOMMouseEvent::CtrlKey()
+MouseEvent::CtrlKey()
 {
   return mEvent->AsInputEvent()->IsControl();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetCtrlKey(bool* aIsDown)
+MouseEvent::GetCtrlKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = CtrlKey();
   return NS_OK;
 }
 
 bool
-nsDOMMouseEvent::ShiftKey()
+MouseEvent::ShiftKey()
 {
   return mEvent->AsInputEvent()->IsShift();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetShiftKey(bool* aIsDown)
+MouseEvent::GetShiftKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = ShiftKey();
   return NS_OK;
 }
 
 bool
-nsDOMMouseEvent::MetaKey()
+MouseEvent::MetaKey()
 {
   return mEvent->AsInputEvent()->IsMeta();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMetaKey(bool* aIsDown)
+MouseEvent::GetMetaKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = MetaKey();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetModifierState(const nsAString& aKey,
+MouseEvent::GetModifierState(const nsAString& aKey,
                                   bool* aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
 
   *aState = GetModifierState(aKey);
   return NS_OK;
 }
 
 float
-nsDOMMouseEvent::MozPressure() const
+MouseEvent::MozPressure() const
 {
   return mEvent->AsMouseEventBase()->pressure;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMozPressure(float* aPressure)
+MouseEvent::GetMozPressure(float* aPressure)
 {
   NS_ENSURE_ARG_POINTER(aPressure);
   *aPressure = MozPressure();
   return NS_OK;
 }
 
 uint16_t
-nsDOMMouseEvent::MozInputSource() const
+MouseEvent::MozInputSource() const
 {
   return mEvent->AsMouseEventBase()->inputSource;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMozInputSource(uint16_t* aInputSource)
+MouseEvent::GetMozInputSource(uint16_t* aInputSource)
 {
   NS_ENSURE_ARG_POINTER(aInputSource);
   *aInputSource = MozInputSource();
   return NS_OK;
 }
 
-nsresult NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
-                             mozilla::dom::EventTarget* aOwner,
-                             nsPresContext* aPresContext,
-                             WidgetMouseEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
+                    EventTarget* aOwner,
+                    nsPresContext* aPresContext,
+                    WidgetMouseEvent* aEvent)
 {
-  nsDOMMouseEvent* it = new nsDOMMouseEvent(aOwner, aPresContext, aEvent);
+  MouseEvent* it = new MouseEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMMouseEvent.h
rename to dom/events/MouseEvent.h
--- a/dom/events/nsDOMMouseEvent.h
+++ b/dom/events/MouseEvent.h
@@ -1,41 +1,44 @@
 /* -*- 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/. */
 
-#ifndef nsDOMMouseEvent_h__
-#define nsDOMMouseEvent_h__
+#ifndef mozilla_dom_MouseEvent_h_
+#define mozilla_dom_MouseEvent_h_
 
 #include "nsIDOMMouseEvent.h"
 #include "nsDOMUIEvent.h"
 #include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/EventForwards.h"
 
-class nsDOMMouseEvent : public nsDOMUIEvent,
-                        public nsIDOMMouseEvent
+namespace mozilla {
+namespace dom {
+
+class MouseEvent : public nsDOMUIEvent,
+                   public nsIDOMMouseEvent
 {
 public:
-  nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
-                  nsPresContext* aPresContext,
-                  mozilla::WidgetMouseEventBase* aEvent);
+  MouseEvent(EventTarget* aOwner,
+             nsPresContext* aPresContext,
+             WidgetMouseEventBase* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMMouseEvent Interface
   NS_DECL_NSIDOMMOUSEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::MouseEventBinding::Wrap(aCx, aScope, this);
+    return MouseEventBinding::Wrap(aCx, aScope, this);
   }
 
   // Web IDL binding methods
   virtual uint32_t Which() MOZ_OVERRIDE
   {
     return Button() + 1;
   }
 
@@ -44,57 +47,57 @@ public:
   int32_t ClientX();
   int32_t ClientY();
   bool CtrlKey();
   bool ShiftKey();
   bool AltKey();
   bool MetaKey();
   int16_t Button();
   uint16_t Buttons();
-  already_AddRefed<mozilla::dom::EventTarget> GetRelatedTarget();
-  void InitMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
+  already_AddRefed<EventTarget> GetRelatedTarget();
+  void InitMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
                       nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX,
                       int32_t aScreenY, int32_t aClientX, int32_t aClientY,
                       bool aCtrlKey, bool aAltKey, bool aShiftKey,
                       bool aMetaKey, uint16_t aButton,
-                      mozilla::dom::EventTarget *aRelatedTarget,
-                      mozilla::ErrorResult& aRv)
+                      EventTarget* aRelatedTarget, ErrorResult& aRv)
   {
     aRv = InitMouseEvent(aType, aCanBubble, aCancelable,
                          aView, aDetail, aScreenX, aScreenY,
                          aClientX, aClientY, aCtrlKey, aAltKey,
                          aShiftKey, aMetaKey, aButton,
                          aRelatedTarget);
   }
   bool GetModifierState(const nsAString& aKeyArg)
   {
     return GetModifierStateInternal(aKeyArg);
   }
-  static already_AddRefed<nsDOMMouseEvent> Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                                                       const nsAString& aType,
-                                                       const mozilla::dom::MouseEventInit& aParam,
-                                                       mozilla::ErrorResult& aRv);
+  static already_AddRefed<MouseEvent> Constructor(const GlobalObject& aGlobal,
+                                                  const nsAString& aType,
+                                                  const MouseEventInit& aParam,
+                                                  ErrorResult& aRv);
   int32_t MozMovementX()
   {
     return GetMovementPoint().x;
   }
   int32_t MozMovementY()
   {
     return GetMovementPoint().y;
   }
   float MozPressure() const;
   uint16_t MozInputSource() const;
-  void InitNSMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                        nsIDOMWindow *aView, int32_t aDetail, int32_t aScreenX,
+  void InitNSMouseEvent(const nsAString& aType,
+                        bool aCanBubble, bool aCancelable,
+                        nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX,
                         int32_t aScreenY, int32_t aClientX, int32_t aClientY,
                         bool aCtrlKey, bool aAltKey, bool aShiftKey,
                         bool aMetaKey, uint16_t aButton,
-                        mozilla::dom::EventTarget *aRelatedTarget,
+                        EventTarget* aRelatedTarget,
                         float aPressure, uint16_t aInputSource,
-                        mozilla::ErrorResult& aRv)
+                        ErrorResult& aRv)
   {
     aRv = InitNSMouseEvent(aType, aCanBubble, aCancelable,
                            aView, aDetail, aScreenX, aScreenY,
                            aClientX, aClientY, aCtrlKey, aAltKey,
                            aShiftKey, aMetaKey, aButton,
                            aRelatedTarget, aPressure, aInputSource);
   }
 
@@ -104,17 +107,20 @@ protected:
                           bool aCancelable,
                           nsIDOMWindow* aView,
                           int32_t aDetail,
                           int32_t aScreenX,
                           int32_t aScreenY,
                           int32_t aClientX,
                           int32_t aClientY,
                           int16_t aButton,
-                          nsIDOMEventTarget *aRelatedTarget,
+                          nsIDOMEventTarget* aRelatedTarget,
                           const nsAString& aModifiersList);
 };
 
-#define NS_FORWARD_TO_NSDOMMOUSEEVENT         \
-  NS_FORWARD_NSIDOMMOUSEEVENT(nsDOMMouseEvent::) \
+} // namespace dom
+} // namespace mozilla
+
+#define NS_FORWARD_TO_MOUSEEVENT \
+  NS_FORWARD_NSIDOMMOUSEEVENT(MouseEvent::) \
   NS_FORWARD_TO_NSDOMUIEVENT
 
-#endif // nsDOMMouseEvent_h__
+#endif // mozilla_dom_MouseEvent_h_
rename from dom/events/nsDOMMouseScrollEvent.cpp
rename to dom/events/MouseScrollEvent.cpp
--- a/dom/events/nsDOMMouseScrollEvent.cpp
+++ b/dom/events/MouseScrollEvent.cpp
@@ -1,80 +1,98 @@
 /* -*- 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 "nsDOMMouseScrollEvent.h"
-#include "prtime.h"
+#include "mozilla/dom/MouseScrollEvent.h"
 #include "mozilla/MouseEvents.h"
-
-using namespace mozilla;
+#include "prtime.h"
 
-nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner,
-                                             nsPresContext* aPresContext,
-                                             WidgetMouseScrollEvent* aEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext,
-                    aEvent ? aEvent :
-                             new WidgetMouseScrollEvent(false, 0, nullptr))
+namespace mozilla {
+namespace dom {
+
+MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner,
+                                   nsPresContext* aPresContext,
+                                   WidgetMouseScrollEvent* aEvent)
+  : MouseEvent(aOwner, aPresContext,
+               aEvent ? aEvent : new WidgetMouseScrollEvent(false, 0, nullptr))
 {
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
       nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 
   mDetail = mEvent->AsMouseScrollEvent()->delta;
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMouseScrollEvent, nsDOMMouseEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMouseScrollEvent, nsDOMMouseEvent)
+NS_IMPL_ADDREF_INHERITED(MouseScrollEvent, MouseEvent)
+NS_IMPL_RELEASE_INHERITED(MouseScrollEvent, MouseEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMMouseScrollEvent)
+NS_INTERFACE_MAP_BEGIN(MouseScrollEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMouseScrollEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
+NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
 
 NS_IMETHODIMP
-nsDOMMouseScrollEvent::InitMouseScrollEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                                nsIDOMWindow *aView, int32_t aDetail, int32_t aScreenX, 
-                                int32_t aScreenY, int32_t aClientX, int32_t aClientY, 
-                                bool aCtrlKey, bool aAltKey, bool aShiftKey, 
-                                bool aMetaKey, uint16_t aButton, nsIDOMEventTarget *aRelatedTarget,
-                                int32_t aAxis)
+MouseScrollEvent::InitMouseScrollEvent(const nsAString& aType,
+                                       bool aCanBubble,
+                                       bool aCancelable,
+                                       nsIDOMWindow* aView,
+                                       int32_t aDetail,
+                                       int32_t aScreenX,
+                                       int32_t aScreenY,
+                                       int32_t aClientX,
+                                       int32_t aClientY,
+                                       bool aCtrlKey,
+                                       bool aAltKey,
+                                       bool aShiftKey,
+                                       bool aMetaKey,
+                                       uint16_t aButton,
+                                       nsIDOMEventTarget* aRelatedTarget,
+                                       int32_t aAxis)
 {
-  nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
-                                                aScreenX, aScreenY, aClientX, aClientY, aCtrlKey,
-                                                aAltKey, aShiftKey, aMetaKey, aButton, aRelatedTarget);
+  nsresult rv =
+    MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
+                               aScreenX, aScreenY, aClientX, aClientY,
+                               aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
+                               aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
   mEvent->AsMouseScrollEvent()->isHorizontal = (aAxis == HORIZONTAL_AXIS);
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsDOMMouseScrollEvent::GetAxis(int32_t* aResult)
+MouseScrollEvent::GetAxis(int32_t* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = Axis();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseScrollEvent::Axis()
+MouseScrollEvent::Axis()
 {
   return mEvent->AsMouseScrollEvent()->isHorizontal ?
            static_cast<int32_t>(HORIZONTAL_AXIS) :
            static_cast<int32_t>(VERTICAL_AXIS);
 }
 
-nsresult NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
-                                   mozilla::dom::EventTarget* aOwner,
-                                   nsPresContext* aPresContext,
-                                   WidgetMouseScrollEvent* aEvent) 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace dom;
+
+nsresult
+NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
+                          EventTarget* aOwner,
+                          nsPresContext* aPresContext,
+                          WidgetMouseScrollEvent* aEvent)
 {
-  nsDOMMouseScrollEvent* it =
-    new nsDOMMouseScrollEvent(aOwner, aPresContext, aEvent);
+  MouseScrollEvent* it = new MouseScrollEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMMouseScrollEvent.h
rename to dom/events/MouseScrollEvent.h
--- a/dom/events/nsDOMMouseScrollEvent.h
+++ b/dom/events/MouseScrollEvent.h
@@ -1,53 +1,59 @@
 /* -*- 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/. */
 
-#ifndef nsDOMMouseScrollEvent_h__
-#define nsDOMMouseScrollEvent_h__
+#ifndef mozilla_dom_MouseScrollEvent_h_
+#define mozilla_dom_MouseScrollEvent_h_
 
 #include "nsIDOMMouseScrollEvent.h"
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/MouseScrollEventBinding.h"
 
-class nsDOMMouseScrollEvent : public nsDOMMouseEvent,
-                              public nsIDOMMouseScrollEvent
+namespace mozilla {
+namespace dom {
+
+class MouseScrollEvent : public MouseEvent,
+                         public nsIDOMMouseScrollEvent
 {
 public:
-  nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner,
-                        nsPresContext* aPresContext,
-                        mozilla::WidgetMouseScrollEvent* aEvent);
+  MouseScrollEvent(EventTarget* aOwner,
+                   nsPresContext* aPresContext,
+                   WidgetMouseScrollEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMMouseScrollEvent Interface
   NS_DECL_NSIDOMMOUSESCROLLEVENT
-  
+
   // Forward to base class
-  NS_FORWARD_TO_NSDOMMOUSEEVENT
+  NS_FORWARD_TO_MOUSEEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::MouseScrollEventBinding::Wrap(aCx, aScope, this);
+    return MouseScrollEventBinding::Wrap(aCx, aScope, this);
   }
 
   int32_t Axis();
 
   void InitMouseScrollEvent(const nsAString& aType, bool aCanBubble,
                             bool aCancelable, nsIDOMWindow* aView,
                             int32_t aDetail, int32_t aScreenX, int32_t aScreenY,
                             int32_t aClientX, int32_t aClientY,
                             bool aCtrlKey, bool aAltKey, bool aShiftKey,
                             bool aMetaKey, uint16_t aButton,
                             nsIDOMEventTarget* aRelatedTarget, int32_t aAxis,
-                            mozilla::ErrorResult& aRv)
+                            ErrorResult& aRv)
   {
     aRv = InitMouseScrollEvent(aType, aCanBubble, aCancelable, aView,
                                aDetail, aScreenX, aScreenY, aClientX, aClientY,
                                aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
                                aRelatedTarget, aAxis);
   }
 };
 
-#endif // nsDOMMouseScrollEvent_h__
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_MouseScrollEvent_h_
rename from dom/events/nsDOMMutationEvent.cpp
rename to dom/events/MutationEvent.cpp
--- a/dom/events/nsDOMMutationEvent.cpp
+++ b/dom/events/MutationEvent.cpp
@@ -1,96 +1,104 @@
 /* -*- 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 "nsCOMPtr.h"
-#include "nsDOMMutationEvent.h"
-#include "mozilla/MutationEvent.h"
-
-using namespace mozilla;
+#include "mozilla/dom/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 
 class nsPresContext;
 
-nsDOMMutationEvent::nsDOMMutationEvent(mozilla::dom::EventTarget* aOwner,
-                                       nsPresContext* aPresContext,
-                                       InternalMutationEvent* aEvent)
+namespace mozilla {
+namespace dom {
+
+MutationEvent::MutationEvent(EventTarget* aOwner,
+                             nsPresContext* aPresContext,
+                             InternalMutationEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext,
                aEvent ? aEvent : new InternalMutationEvent(false, 0))
 {
   mEventIsInternal = (aEvent == nullptr);
 }
 
-NS_INTERFACE_MAP_BEGIN(nsDOMMutationEvent)
+NS_INTERFACE_MAP_BEGIN(MutationEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMutationEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMutationEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMutationEvent, nsDOMEvent)
+NS_IMPL_ADDREF_INHERITED(MutationEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(MutationEvent, nsDOMEvent)
 
 already_AddRefed<nsINode>
-nsDOMMutationEvent::GetRelatedNode()
+MutationEvent::GetRelatedNode()
 {
   nsCOMPtr<nsINode> n =
     do_QueryInterface(mEvent->AsMutationEvent()->mRelatedNode);
   return n.forget();
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
+MutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
 {
   nsCOMPtr<nsINode> relatedNode = GetRelatedNode();
   nsCOMPtr<nsIDOMNode> relatedDOMNode = relatedNode ? relatedNode->AsDOMNode() : nullptr;
   relatedDOMNode.forget(aRelatedNode);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetPrevValue(nsAString& aPrevValue)
+MutationEvent::GetPrevValue(nsAString& aPrevValue)
 {
   InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mPrevAttrValue)
     mutation->mPrevAttrValue->ToString(aPrevValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetNewValue(nsAString& aNewValue)
+MutationEvent::GetNewValue(nsAString& aNewValue)
 {
   InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mNewAttrValue)
       mutation->mNewAttrValue->ToString(aNewValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetAttrName(nsAString& aAttrName)
+MutationEvent::GetAttrName(nsAString& aAttrName)
 {
   InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mAttrName)
       mutation->mAttrName->ToString(aAttrName);
   return NS_OK;
 }
 
 uint16_t
-nsDOMMutationEvent::AttrChange()
+MutationEvent::AttrChange()
 {
   return mEvent->AsMutationEvent()->mAttrChange;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetAttrChange(uint16_t* aAttrChange)
+MutationEvent::GetAttrChange(uint16_t* aAttrChange)
 {
   *aAttrChange = AttrChange();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::InitMutationEvent(const nsAString& aTypeArg, bool aCanBubbleArg, bool aCancelableArg, nsIDOMNode* aRelatedNodeArg, const nsAString& aPrevValueArg, const nsAString& aNewValueArg, const nsAString& aAttrNameArg, uint16_t aAttrChangeArg)
+MutationEvent::InitMutationEvent(const nsAString& aTypeArg,
+                                 bool aCanBubbleArg,
+                                 bool aCancelableArg,
+                                 nsIDOMNode* aRelatedNodeArg,
+                                 const nsAString& aPrevValueArg,
+                                 const nsAString& aNewValueArg,
+                                 const nsAString& aAttrNameArg,
+                                 uint16_t aAttrChangeArg)
 {
   nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
   NS_ENSURE_SUCCESS(rv, rv);
 
   InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   mutation->mRelatedNode = aRelatedNodeArg;
   if (!aPrevValueArg.IsEmpty())
     mutation->mPrevAttrValue = do_GetAtom(aPrevValueArg);
@@ -99,17 +107,23 @@ nsDOMMutationEvent::InitMutationEvent(co
   if (!aAttrNameArg.IsEmpty()) {
     mutation->mAttrName = do_GetAtom(aAttrNameArg);
   }
   mutation->mAttrChange = aAttrChangeArg;
     
   return NS_OK;
 }
 
-nsresult NS_NewDOMMutationEvent(nsIDOMEvent** aInstancePtrResult,
-                                mozilla::dom::EventTarget* aOwner,
-                                nsPresContext* aPresContext,
-                                InternalMutationEvent* aEvent) 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMMutationEvent(nsIDOMEvent** aInstancePtrResult,
+                       EventTarget* aOwner,
+                       nsPresContext* aPresContext,
+                       InternalMutationEvent* aEvent) 
 {
-  nsDOMMutationEvent* it = new nsDOMMutationEvent(aOwner, aPresContext, aEvent);
-
+  MutationEvent* it = new MutationEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/dom/events/MutationEvent.h
+++ b/dom/events/MutationEvent.h
@@ -1,70 +1,65 @@
 /* -*- 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/. */
 
-#ifndef mozilla_MutationEvent_h__
-#define mozilla_MutationEvent_h__
+#ifndef mozilla_dom_MutationEvent_h_
+#define mozilla_dom_MutationEvent_h_
 
-#include "mozilla/BasicEvents.h"
-#include "nsCOMPtr.h"
-#include "nsIAtom.h"
-#include "nsIDOMNode.h"
+#include "nsIDOMMutationEvent.h"
+#include "nsINode.h"
+#include "nsDOMEvent.h"
+#include "mozilla/dom/MutationEventBinding.h"
+#include "mozilla/EventForwards.h"
 
 namespace mozilla {
+namespace dom {
 
-class InternalMutationEvent : public WidgetEvent
+class MutationEvent : public nsDOMEvent,
+                      public nsIDOMMutationEvent
 {
 public:
-  virtual InternalMutationEvent* AsMutationEvent() MOZ_OVERRIDE { return this; }
+  MutationEvent(EventTarget* aOwner,
+                nsPresContext* aPresContext,
+                InternalMutationEvent* aEvent);
+
+  NS_DECL_ISUPPORTS_INHERITED
+
+  NS_DECL_NSIDOMMUTATIONEVENT
 
-  InternalMutationEvent(bool aIsTrusted, uint32_t aMessage) :
-    WidgetEvent(aIsTrusted, aMessage, NS_MUTATION_EVENT),
-    mAttrChange(0)
+  // Forward to base class
+  NS_FORWARD_TO_NSDOMEVENT
+
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    mFlags.mCancelable = false;
+    return MutationEventBinding::Wrap(aCx, aScope, this);
   }
 
-  virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
-  {
-    MOZ_ASSERT(eventStructType == NS_MUTATION_EVENT,
-               "Duplicate() must be overridden by sub class");
-    InternalMutationEvent* result = new InternalMutationEvent(false, message);
-    result->AssignMutationEventData(*this, true);
-    result->mFlags = mFlags;
-    return result;
-  }
+  // xpidl implementation
+  // GetPrevValue(nsAString& aPrevValue);
+  // GetNewValue(nsAString& aNewValue);
+  // GetAttrName(nsAString& aAttrName);
+
+  already_AddRefed<nsINode> GetRelatedNode();
+
+  uint16_t AttrChange();
 
-  nsCOMPtr<nsIDOMNode> mRelatedNode;
-  nsCOMPtr<nsIAtom>    mAttrName;
-  nsCOMPtr<nsIAtom>    mPrevAttrValue;
-  nsCOMPtr<nsIAtom>    mNewAttrValue;
-  unsigned short       mAttrChange;
-
-  void AssignMutationEventData(const InternalMutationEvent& aEvent,
-                               bool aCopyTargets)
+  void InitMutationEvent(const nsAString& aType,
+                         bool& aCanBubble, bool& aCancelable,
+                         nsINode* aRelatedNode,
+                         const nsAString& aPrevValue,
+                         const nsAString& aNewValue,
+                         const nsAString& aAttrName,
+                         uint16_t& aAttrChange, ErrorResult& aRv)
   {
-    AssignEventData(aEvent, aCopyTargets);
-
-    mRelatedNode = aEvent.mRelatedNode;
-    mAttrName = aEvent.mAttrName;
-    mPrevAttrValue = aEvent.mPrevAttrValue;
-    mNewAttrValue = aEvent.mNewAttrValue;
-    mAttrChange = aEvent.mAttrChange;
+    aRv = InitMutationEvent(aType, aCanBubble, aCancelable,
+                            aRelatedNode ? aRelatedNode->AsDOMNode() : nullptr,
+                            aPrevValue, aNewValue, aAttrName, aAttrChange);
   }
 };
 
-// Bits are actually checked to optimize mutation event firing.
-// That's why I don't number from 0x00.  The first event should
-// always be 0x01.
-#define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED                0x01
-#define NS_EVENT_BITS_MUTATION_NODEINSERTED                   0x02
-#define NS_EVENT_BITS_MUTATION_NODEREMOVED                    0x04
-#define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT        0x08
-#define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT       0x10
-#define NS_EVENT_BITS_MUTATION_ATTRMODIFIED                   0x20
-#define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED          0x40
-
+} // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_MutationEvent_h__
+#endif // mozilla_dom_MutationEvent_h_
--- a/dom/events/PointerEvent.cpp
+++ b/dom/events/PointerEvent.cpp
@@ -1,28 +1,30 @@
 /* -*- 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/.
  *
  * Portions Copyright 2013 Microsoft Open Technologies, Inc. */
 
-#include "PointerEvent.h"
+#include "mozilla/dom/PointerEvent.h"
 #include "mozilla/MouseEvents.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 PointerEvent::PointerEvent(EventTarget* aOwner,
                            nsPresContext* aPresContext,
                            WidgetPointerEvent* aEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext, aEvent ? aEvent : new WidgetPointerEvent(false, 0, nullptr))
+  : MouseEvent(aOwner, aPresContext,
+               aEvent ? aEvent : new WidgetPointerEvent(false, 0, nullptr))
 {
-  NS_ASSERTION(mEvent->eventStructType == NS_POINTER_EVENT, "event type mismatch NS_POINTER_EVENT");
+  NS_ASSERTION(mEvent->eventStructType == NS_POINTER_EVENT,
+               "event type mismatch NS_POINTER_EVENT");
 
   WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
@@ -43,30 +45,31 @@ ConvertStringToPointerType(const nsAStri
     return nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
   }
 
   return nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
 }
 
 //static
 already_AddRefed<PointerEvent>
-PointerEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
+PointerEvent::Constructor(const GlobalObject& aGlobal,
                           const nsAString& aType,
-                          const mozilla::dom::PointerEventInit& aParam,
-                          mozilla::ErrorResult& aRv)
+                          const PointerEventInit& aParam,
+                          ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
   nsRefPtr<PointerEvent> e = new PointerEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
 
   aRv = e->InitMouseEvent(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.mMetaKey, aParam.mButton,
+                          aParam.mRelatedTarget);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   WidgetPointerEvent* widgetEvent = e->mEvent->AsPointerEvent();
   widgetEvent->pointerId = aParam.mPointerId;
   widgetEvent->width = aParam.mWidth;
   widgetEvent->height = aParam.mHeight;
@@ -95,56 +98,65 @@ PointerEvent::GetPointerType(nsAString& 
       aPointerType.AssignLiteral("touch");
       break;
     case nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN:
       aPointerType.AssignLiteral("");
       break;
   }
 }
 
-int32_t PointerEvent::PointerId()
+int32_t
+PointerEvent::PointerId()
 {
   return mEvent->AsPointerEvent()->pointerId;
 }
 
-int32_t PointerEvent::Width()
+int32_t
+PointerEvent::Width()
 {
   return mEvent->AsPointerEvent()->width;
 }
 
-int32_t PointerEvent::Height()
+int32_t
+PointerEvent::Height()
 {
   return mEvent->AsPointerEvent()->height;
 }
 
-float PointerEvent::Pressure()
+float
+PointerEvent::Pressure()
 {
   return mEvent->AsPointerEvent()->pressure;
 }
 
-int32_t PointerEvent::TiltX()
+int32_t
+PointerEvent::TiltX()
 {
   return mEvent->AsPointerEvent()->tiltX;
 }
 
-int32_t PointerEvent::TiltY()
+int32_t
+PointerEvent::TiltY()
 {
   return mEvent->AsPointerEvent()->tiltY;
 }
 
-bool PointerEvent::IsPrimary()
+bool
+PointerEvent::IsPrimary()
 {
   return mEvent->AsPointerEvent()->isPrimary;
 }
 
 } // namespace dom
 } // namespace mozilla
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
-nsresult NS_NewDOMPointerEvent(nsIDOMEvent** aInstancePtrResult,
-                               dom::EventTarget* aOwner,
-                               nsPresContext* aPresContext,
-                               WidgetPointerEvent *aEvent)
+nsresult
+NS_NewDOMPointerEvent(nsIDOMEvent** aInstancePtrResult,
+                      EventTarget* aOwner,
+                      nsPresContext* aPresContext,
+                      WidgetPointerEvent *aEvent)
 {
-  dom::PointerEvent *it = new dom::PointerEvent(aOwner, aPresContext, aEvent);
+  PointerEvent *it = new PointerEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/dom/events/PointerEvent.h
+++ b/dom/events/PointerEvent.h
@@ -1,50 +1,50 @@
 /* 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/.
  *
  * Portions Copyright 2013 Microsoft Open Technologies, Inc. */
 
-#ifndef PointerEvent_h__
-#define PointerEvent_h__
+#ifndef mozilla_dom_PointerEvent_h_
+#define mozilla_dom_PointerEvent_h_
 
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/PointerEventBinding.h"
 
 class nsPresContext;
 
 namespace mozilla {
 namespace dom {
 
-class PointerEvent : public nsDOMMouseEvent
+class PointerEvent : public MouseEvent
 {
 public:
   PointerEvent(EventTarget* aOwner,
                nsPresContext* aPresContext,
                WidgetPointerEvent* aEvent);
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::PointerEventBinding::Wrap(aCx, aScope, this);
+    return PointerEventBinding::Wrap(aCx, aScope, this);
   }
 
   static already_AddRefed<PointerEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const PointerEventInit& aParam,
-              mozilla::ErrorResult& aRv);
+              ErrorResult& aRv);
 
   int32_t PointerId();
   int32_t Width();
   int32_t Height();
   float Pressure();
   int32_t TiltX();
   int32_t TiltY();
   bool IsPrimary();
   void GetPointerType(nsAString& aPointerType);
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // mozilla_dom_PointerEvent_h_
rename from dom/events/nsDOMSimpleGestureEvent.cpp
rename to dom/events/SimpleGestureEvent.cpp
--- a/dom/events/nsDOMSimpleGestureEvent.cpp
+++ b/dom/events/SimpleGestureEvent.cpp
@@ -1,161 +1,159 @@
 /* -*- 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 "nsDOMSimpleGestureEvent.h"
-#include "prtime.h"
+#include "mozilla/dom/SimpleGestureEvent.h"
 #include "mozilla/TouchEvents.h"
+#include "prtime.h"
 
-using namespace mozilla;
+namespace mozilla {
+namespace dom {
 
-nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
-                                                 nsPresContext* aPresContext,
-                                                 WidgetSimpleGestureEvent* aEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext,
-                    aEvent ? aEvent :
-                             new WidgetSimpleGestureEvent(false, 0, nullptr))
+SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
+                                       nsPresContext* aPresContext,
+                                       WidgetSimpleGestureEvent* aEvent)
+  : MouseEvent(aOwner, aPresContext,
+               aEvent ? aEvent :
+                        new WidgetSimpleGestureEvent(false, 0, nullptr))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_SIMPLE_GESTURE_EVENT, "event type mismatch");
 
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
       nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
+NS_IMPL_ADDREF_INHERITED(SimpleGestureEvent, MouseEvent)
+NS_IMPL_RELEASE_INHERITED(SimpleGestureEvent, MouseEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMSimpleGestureEvent)
+NS_INTERFACE_MAP_BEGIN(SimpleGestureEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMSimpleGestureEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
+NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
 
 /* attribute unsigned long allowedDirections; */
 uint32_t
-nsDOMSimpleGestureEvent::AllowedDirections()
+SimpleGestureEvent::AllowedDirections()
 {
   return mEvent->AsSimpleGestureEvent()->allowedDirections;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::GetAllowedDirections(uint32_t *aAllowedDirections)
+SimpleGestureEvent::GetAllowedDirections(uint32_t* aAllowedDirections)
 {
   NS_ENSURE_ARG_POINTER(aAllowedDirections);
   *aAllowedDirections = AllowedDirections();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
+SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
 {
   mEvent->AsSimpleGestureEvent()->allowedDirections = aAllowedDirections;
   return NS_OK;
 }
 
 /* readonly attribute unsigned long direction; */
 uint32_t
-nsDOMSimpleGestureEvent::Direction()
+SimpleGestureEvent::Direction()
 {
   return mEvent->AsSimpleGestureEvent()->direction;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::GetDirection(uint32_t *aDirection)
+SimpleGestureEvent::GetDirection(uint32_t* aDirection)
 {
   NS_ENSURE_ARG_POINTER(aDirection);
   *aDirection = Direction();
   return NS_OK;
 }
 
 /* readonly attribute float delta; */
 double
-nsDOMSimpleGestureEvent::Delta()
+SimpleGestureEvent::Delta()
 {
   return mEvent->AsSimpleGestureEvent()->delta;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
+SimpleGestureEvent::GetDelta(double* aDelta)
 {
   NS_ENSURE_ARG_POINTER(aDelta);
   *aDelta = Delta();
   return NS_OK;
 }
 
 /* readonly attribute unsigned long clickCount; */
 uint32_t
-nsDOMSimpleGestureEvent::ClickCount()
+SimpleGestureEvent::ClickCount()
 {
   return mEvent->AsSimpleGestureEvent()->clickCount;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::GetClickCount(uint32_t *aClickCount)
+SimpleGestureEvent::GetClickCount(uint32_t* aClickCount)
 {
   NS_ENSURE_ARG_POINTER(aClickCount);
   *aClickCount = ClickCount();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
-                                                bool aCanBubbleArg,
-                                                bool aCancelableArg,
-                                                nsIDOMWindow* aViewArg,
-                                                int32_t aDetailArg,
-                                                int32_t aScreenX, 
-                                                int32_t aScreenY,
-                                                int32_t aClientX,
-                                                int32_t aClientY,
-                                                bool aCtrlKeyArg,
-                                                bool aAltKeyArg,
-                                                bool aShiftKeyArg,
-                                                bool aMetaKeyArg,
-                                                uint16_t aButton,
-                                                nsIDOMEventTarget* aRelatedTarget,
-                                                uint32_t aAllowedDirectionsArg,
-                                                uint32_t aDirectionArg,
-                                                double aDeltaArg,
-                                                uint32_t aClickCountArg)
+SimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
+                                           bool aCanBubbleArg,
+                                           bool aCancelableArg,
+                                           nsIDOMWindow* aViewArg,
+                                           int32_t aDetailArg,
+                                           int32_t aScreenX, 
+                                           int32_t aScreenY,
+                                           int32_t aClientX,
+                                           int32_t aClientY,
+                                           bool aCtrlKeyArg,
+                                           bool aAltKeyArg,
+                                           bool aShiftKeyArg,
+                                           bool aMetaKeyArg,
+                                           uint16_t aButton,
+                                           nsIDOMEventTarget* aRelatedTarget,
+                                           uint32_t aAllowedDirectionsArg,
+                                           uint32_t aDirectionArg,
+                                           double aDeltaArg,
+                                           uint32_t aClickCountArg)
 {
-  nsresult rv = nsDOMMouseEvent::InitMouseEvent(aTypeArg,
-                                                aCanBubbleArg,
-                                                aCancelableArg,
-                                                aViewArg,
-                                                aDetailArg,
-                                                aScreenX, 
-                                                aScreenY,
-                                                aClientX,
-                                                aClientY,
-                                                aCtrlKeyArg,
-                                                aAltKeyArg,
-                                                aShiftKeyArg,
-                                                aMetaKeyArg,
-                                                aButton,
-                                                aRelatedTarget);
+  nsresult rv =
+    MouseEvent::InitMouseEvent(aTypeArg, aCanBubbleArg, aCancelableArg,
+                               aViewArg, aDetailArg,
+                               aScreenX, aScreenY, aClientX, aClientY,
+                               aCtrlKeyArg, aAltKeyArg, aShiftKeyArg,
+                               aMetaKeyArg, aButton, aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
   simpleGestureEvent->allowedDirections = aAllowedDirectionsArg;
   simpleGestureEvent->direction = aDirectionArg;
   simpleGestureEvent->delta = aDeltaArg;
   simpleGestureEvent->clickCount = aClickCountArg;
 
   return NS_OK;
 }
 
-nsresult NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
-                                     mozilla::dom::EventTarget* aOwner,
-                                     nsPresContext* aPresContext,
-                                     WidgetSimpleGestureEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
+                            EventTarget* aOwner,
+                            nsPresContext* aPresContext,
+                            WidgetSimpleGestureEvent* aEvent)
 {
-  nsDOMSimpleGestureEvent* it =
-    new nsDOMSimpleGestureEvent(aOwner, aPresContext, aEvent);
+  SimpleGestureEvent* it = new SimpleGestureEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMSimpleGestureEvent.h
rename to dom/events/SimpleGestureEvent.h
--- a/dom/events/nsDOMSimpleGestureEvent.h
+++ b/dom/events/SimpleGestureEvent.h
@@ -1,40 +1,44 @@
 /* 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 nsDOMSimpleGestureEvent_h__
-#define nsDOMSimpleGestureEvent_h__
+#ifndef mozilla_dom_SimpleGestureEvent_h_
+#define mozilla_dom_SimpleGestureEvent_h_
 
 #include "nsIDOMSimpleGestureEvent.h"
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
+#include "mozilla/dom/SimpleGestureEventBinding.h"
 #include "mozilla/EventForwards.h"
-#include "mozilla/dom/SimpleGestureEventBinding.h"
 
 class nsPresContext;
 
-class nsDOMSimpleGestureEvent : public nsDOMMouseEvent,
-                                public nsIDOMSimpleGestureEvent
+namespace mozilla {
+namespace dom {
+
+class SimpleGestureEvent : public MouseEvent,
+                           public nsIDOMSimpleGestureEvent
 {
 public:
-  nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
-                          nsPresContext*, mozilla::WidgetSimpleGestureEvent*);
+  SimpleGestureEvent(EventTarget* aOwner,
+                     nsPresContext* aPresContext,
+                     WidgetSimpleGestureEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMSIMPLEGESTUREEVENT
 
   // Forward to base class
-  NS_FORWARD_TO_NSDOMMOUSEEVENT
+  NS_FORWARD_TO_MOUSEEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
-			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::SimpleGestureEventBinding::Wrap(aCx, aScope, this);
+    return SimpleGestureEventBinding::Wrap(aCx, aScope, this);
   }
 
   uint32_t AllowedDirections();
   uint32_t Direction();
   double Delta();
   uint32_t ClickCount();
 
   void InitSimpleGestureEvent(const nsAString& aType,
@@ -46,25 +50,28 @@ public:
                               int32_t aScreenY,
                               int32_t aClientX,
                               int32_t aClientY,
                               bool aCtrlKey,
                               bool aAltKey,
                               bool aShiftKey,
                               bool aMetaKey,
                               uint16_t aButton,
-                              mozilla::dom::EventTarget* aRelatedTarget,
+                              EventTarget* aRelatedTarget,
                               uint32_t aAllowedDirections,
                               uint32_t aDirection,
                               double aDelta,
                               uint32_t aClickCount,
-                              mozilla::ErrorResult& aRv)
+                              ErrorResult& aRv)
   {
     aRv = InitSimpleGestureEvent(aType, aCanBubble, aCancelable,
                                  aView, aDetail, aScreenX, aScreenY,
                                  aClientX, aClientY, aCtrlKey, aAltKey,
                                  aShiftKey, aMetaKey, aButton,
                                  aRelatedTarget, aAllowedDirections,
                                  aDirection, aDelta, aClickCount);
   }
 };
 
-#endif
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_SimpleGestureEvent_h_
--- a/dom/events/WheelEvent.cpp
+++ b/dom/events/WheelEvent.cpp
@@ -9,36 +9,36 @@
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 WheelEvent::WheelEvent(EventTarget* aOwner,
                        nsPresContext* aPresContext,
                        WidgetWheelEvent* aWheelEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext,
-                    aWheelEvent ? aWheelEvent :
-                                  new WidgetWheelEvent(false, 0, nullptr))
+  : MouseEvent(aOwner, aPresContext,
+               aWheelEvent ? aWheelEvent :
+                             new WidgetWheelEvent(false, 0, nullptr))
 {
   if (aWheelEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     mEvent->AsWheelEvent()->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(WheelEvent, nsDOMMouseEvent)
-NS_IMPL_RELEASE_INHERITED(WheelEvent, nsDOMMouseEvent)
+NS_IMPL_ADDREF_INHERITED(WheelEvent, MouseEvent)
+NS_IMPL_RELEASE_INHERITED(WheelEvent, MouseEvent)
 
 NS_INTERFACE_MAP_BEGIN(WheelEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMWheelEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
+NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
 
 NS_IMETHODIMP
 WheelEvent::InitWheelEvent(const nsAString& aType,
                            bool aCanBubble,
                            bool aCancelable,
                            nsIDOMWindow* aView,
                            int32_t aDetail,
                            int32_t aScreenX,
@@ -49,20 +49,19 @@ WheelEvent::InitWheelEvent(const nsAStri
                            nsIDOMEventTarget* aRelatedTarget,
                            const nsAString& aModifiersList,
                            double aDeltaX,
                            double aDeltaY,
                            double aDeltaZ,
                            uint32_t aDeltaMode)
 {
   nsresult rv =
-    nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView,
-                                    aDetail, aScreenX, aScreenY,
-                                    aClientX, aClientY, aButton,
-                                    aRelatedTarget, aModifiersList);
+    MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
+                               aScreenX, aScreenY, aClientX, aClientY, aButton,
+                               aRelatedTarget, aModifiersList);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WidgetWheelEvent* wheelEvent = mEvent->AsWheelEvent();
   wheelEvent->deltaX = aDeltaX;
   wheelEvent->deltaY = aDeltaY;
   wheelEvent->deltaZ = aDeltaZ;
   wheelEvent->deltaMode = aDeltaMode;
 
--- a/dom/events/WheelEvent.h
+++ b/dom/events/WheelEvent.h
@@ -3,38 +3,38 @@
 /* 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_WheelEvent_h_
 #define mozilla_dom_WheelEvent_h_
 
 #include "nsIDOMWheelEvent.h"
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
+#include "mozilla/dom/WheelEventBinding.h"
 #include "mozilla/EventForwards.h"
-#include "mozilla/dom/WheelEventBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-class WheelEvent : public nsDOMMouseEvent,
+class WheelEvent : public MouseEvent,
                    public nsIDOMWheelEvent
 {
 public:
   WheelEvent(EventTarget* aOwner,
              nsPresContext* aPresContext,
              WidgetWheelEvent* aWheelEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMWheelEvent Interface
   NS_DECL_NSIDOMWHEELEVENT
   
   // Forward to base class
-  NS_FORWARD_TO_NSDOMMOUSEEVENT
+  NS_FORWARD_TO_MOUSEEVENT
 
   static
   already_AddRefed<WheelEvent> Constructor(const GlobalObject& aGlobal,
                                            const nsAString& aType,
                                            const WheelEventInit& aParam,
                                            ErrorResult& aRv);
 
   virtual JSObject* WrapObject(JSContext* aCx,
--- a/dom/events/moz.build
+++ b/dom/events/moz.build
@@ -27,69 +27,78 @@ EXPORTS += [
     'nsEventStates.h',
     'nsIJSEventListener.h',
     'nsIPrivateTextEvent.h',
     'nsIPrivateTextRange.h',
     'nsVKList.h',
 ]
 
 EXPORTS.mozilla += [
-    'MutationEvent.h',
+    'InternalMutationEvent.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'AnimationEvent.h',
     'BeforeUnloadEvent.h',
     'ClipboardEvent.h',
     'CommandEvent.h',
     'CompositionEvent.h',
     'DataContainerEvent.h',
     'DataTransfer.h',
+    'DeviceMotionEvent.h',
+    'DragEvent.h',
     'EventTarget.h',
+    'FocusEvent.h',
+    'KeyboardEvent.h',
+    'MessageEvent.h',
+    'MouseEvent.h',
+    'MouseScrollEvent.h',
+    'MutationEvent.h',
     'PointerEvent.h',
+    'SimpleGestureEvent.h',
     'Touch.h',
     'WheelEvent.h',
 ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     EXPORTS.mozilla.dom += ['SpeechRecognitionError.h']
 
 UNIFIED_SOURCES += [
     'AnimationEvent.cpp',
     'BeforeUnloadEvent.cpp',
     'ClipboardEvent.cpp',
     'CommandEvent.cpp',
     'CompositionEvent.cpp',
     'DataContainerEvent.cpp',
     'DataTransfer.cpp',
+    'DeviceMotionEvent.cpp',
+    'DragEvent.cpp',
     'EventTarget.cpp',
+    'FocusEvent.cpp',
+    'KeyboardEvent.cpp',
+    'MessageEvent.cpp',
+    'MouseEvent.cpp',
+    'MouseScrollEvent.cpp',
+    'MutationEvent.cpp',
     'nsAsyncDOMEvent.cpp',
     'nsContentEventHandler.cpp',
-    'nsDOMDeviceMotionEvent.cpp',
-    'nsDOMDragEvent.cpp',
     'nsDOMEventTargetHelper.cpp',
-    'nsDOMFocusEvent.cpp',
-    'nsDOMKeyboardEvent.cpp',
-    'nsDOMMessageEvent.cpp',
-    'nsDOMMouseEvent.cpp',
-    'nsDOMMouseScrollEvent.cpp',
-    'nsDOMMutationEvent.cpp',
     'nsDOMNotifyAudioAvailableEvent.cpp',
-    'nsDOMSimpleGestureEvent.cpp',
     'nsDOMTextEvent.cpp',
     'nsDOMTouchEvent.cpp',
     'nsDOMTransitionEvent.cpp',
     'nsDOMXULCommandEvent.cpp',
     'nsEventDispatcher.cpp',
     'nsEventListenerService.cpp',
     'nsIMEStateManager.cpp',
     'nsJSEventListener.cpp',
     'nsPaintRequest.cpp',
     'nsPrivateTextRange.cpp',
     'PointerEvent.cpp',
+    'SimpleGestureEvent.cpp',
     'TextComposition.cpp',
     'Touch.cpp',
     'WheelEvent.cpp',
 ]
 
 SOURCES += [
     # nsDOMEvent.cpp should be built separately because it includes
     # ipc/IPCMessageUtils.h, which on Windows includes windows.h.
--- a/dom/events/nsDOMEvent.cpp
+++ b/dom/events/nsDOMEvent.cpp
@@ -11,19 +11,19 @@
 #include "nsError.h"
 #include "nsDOMEvent.h"
 #include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
 #include "mozilla/ContentEvents.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "nsContentUtils.h"
 #include "nsJSEnvironment.h"
 #include "mozilla/Preferences.h"
 #include "nsLayoutUtils.h"
 #include "nsIScrollableFrame.h"
 #include "nsDOMEventTargetHelper.h"
deleted file mode 100644
--- a/dom/events/nsDOMMutationEvent.h
+++ /dev/null
@@ -1,59 +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/. */
-
-#ifndef nsDOMMutationEvent_h__
-#define nsDOMMutationEvent_h__
-
-#include "nsIDOMMutationEvent.h"
-#include "nsINode.h"
-#include "nsDOMEvent.h"
-#include "mozilla/dom/MutationEventBinding.h"
-#include "mozilla/EventForwards.h"
-
-class nsDOMMutationEvent : public nsDOMEvent,
-                           public nsIDOMMutationEvent
-{
-public:
-  nsDOMMutationEvent(mozilla::dom::EventTarget* aOwner,
-                     nsPresContext* aPresContext,
-                     mozilla::InternalMutationEvent* aEvent);
-
-  NS_DECL_ISUPPORTS_INHERITED
-
-  NS_DECL_NSIDOMMUTATIONEVENT
-
-  // Forward to base class
-  NS_FORWARD_TO_NSDOMEVENT
-
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
-  {
-    return mozilla::dom::MutationEventBinding::Wrap(aCx, aScope, this);
-  }
-
-  // xpidl implementation
-  // GetPrevValue(nsAString& aPrevValue);
-  // GetNewValue(nsAString& aNewValue);
-  // GetAttrName(nsAString& aAttrName);
-
-  already_AddRefed<nsINode> GetRelatedNode();
-
-  uint16_t AttrChange();
-
-  void InitMutationEvent(const nsAString& aType,
-                         bool& aCanBubble, bool& aCancelable,
-                         nsINode* aRelatedNode,
-                         const nsAString& aPrevValue,
-                         const nsAString& aNewValue,
-                         const nsAString& aAttrName,
-                         uint16_t& aAttrChange, mozilla::ErrorResult& aRv)
-  {
-    aRv = InitMutationEvent(aType, aCanBubble, aCancelable,
-                            aRelatedNode ? aRelatedNode->AsDOMNode() : nullptr,
-                            aPrevValue, aNewValue, aAttrName, aAttrChange);
-  }
-};
-
-#endif // nsDOMMutationEvent_h__
--- a/dom/events/nsEventDispatcher.cpp
+++ b/dom/events/nsEventDispatcher.cpp
@@ -14,19 +14,19 @@
 #include "nsIDocument.h"
 #include "nsINode.h"
 #include "nsPIDOMWindow.h"
 #include "nsDOMTouchEvent.h"
 #include "GeckoProfiler.h"
 #include "GeneratedEvents.h"
 #include "mozilla/ContentEvents.h"
 #include "mozilla/dom/EventTarget.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/unused.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 class ELMCreationDetector
--- a/dom/events/nsEventListenerManager.cpp
+++ b/dom/events/nsEventListenerManager.cpp
@@ -21,17 +21,17 @@
 #include "nsIJSEventListener.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsINameSpaceManager.h"
 #include "nsIContent.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsCOMPtr.h"
 #include "nsError.h"
 #include "nsIDocument.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsIXPConnect.h"
 #include "nsDOMCID.h"
 #include "nsContentUtils.h"
 #include "nsJSUtils.h"
 #include "nsEventDispatcher.h"
 #include "nsCOMArray.h"
 #include "nsEventListenerService.h"
 #include "nsIContentSecurityPolicy.h"
--- a/dom/events/nsEventStateManager.cpp
+++ b/dom/events/nsEventStateManager.cpp
@@ -45,17 +45,17 @@
 #include "nsIDOMXULElement.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIObserverService.h"
 #include "nsIDocShell.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIDOMWheelEvent.h"
 #include "nsIDOMDragEvent.h"
 #include "nsIDOMUIEvent.h"
-#include "nsDOMDragEvent.h"
+#include "nsDOMUIEvent.h"
 #include "nsIMozBrowserFrame.h"
 
 #include "nsSubDocumentFrame.h"
 #include "nsLayoutUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsContentUtils.h"
 
@@ -3561,17 +3561,17 @@ nsEventStateManager::PostHandleEvent(nsP
           dataTransfer = do_QueryInterface(dragEvent->dataTransfer);
           dataTransfer->GetDropEffectInt(&dropEffect);
         }
         else {
           // if dragEvent->dataTransfer is null, it means that no attempt was
           // made to access the dataTransfer during the event, yet the event
           // was cancelled. Instead, use the initial data transfer available
           // from the drag session. The drop effect would not have been
-          // initialized (which is done in nsDOMDragEvent::GetDataTransfer),
+          // initialized (which is done in DragEvent::GetDataTransfer),
           // so set it from the drag action. We'll still want to filter it
           // based on the effectAllowed below.
           dataTransfer = initialDataTransfer;
 
           uint32_t action;
           dragSession->GetDragAction(&action);
 
           // filter the drop effect based on the action. Use UNINITIALIZED as
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -7,19 +7,20 @@
 #include "base/basictypes.h"
 
 #include "IDBDatabase.h"
 
 #include "DictionaryHelpers.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/storage.h"
 #include "mozilla/dom/ContentParent.h"
+#include "mozilla/dom/DOMStringList.h"
+#include "mozilla/dom/DOMStringListBinding.h"
 #include "mozilla/dom/quota/Client.h"
 #include "mozilla/dom/quota/QuotaManager.h"
-#include "nsDOMLists.h"
 #include "nsJSUtils.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 
 #include "AsyncConnectionHelper.h"
 #include "DatabaseInfo.h"
 #include "IDBEvents.h"
 #include "IDBFactory.h"
@@ -489,40 +490,30 @@ IDBDatabase::WrapObject(JSContext* aCx, 
 uint64_t
 IDBDatabase::Version() const
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   DatabaseInfo* info = Info();
   return info->version;
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 IDBDatabase::GetObjectStoreNames(ErrorResult& aRv) const
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   DatabaseInfo* info = Info();
 
-  nsAutoTArray<nsString, 10> objectStoreNames;
-  if (!info->GetObjectStoreNames(objectStoreNames)) {
+  nsRefPtr<DOMStringList> list(new DOMStringList());
+  if (!info->GetObjectStoreNames(list->StringArray())) {
     IDB_WARNING("Couldn't get names!");
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
     return nullptr;
   }
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
-  uint32_t count = objectStoreNames.Length();
-  for (uint32_t index = 0; index < count; index++) {
-    if (!list->Add(objectStoreNames[index])) {
-      IDB_WARNING("Failed to add element");
-      aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
-      return nullptr;
-    }
-  }
-
   return list.forget();
 }
 
 already_AddRefed<IDBObjectStore>
 IDBDatabase::CreateObjectStore(
                             JSContext* aCx, const nsAString& aName,
                             const IDBObjectStoreParameters& aOptionalParameters,
                             ErrorResult& aRv)
--- a/dom/indexedDB/IDBDatabase.h
+++ b/dom/indexedDB/IDBDatabase.h
@@ -184,17 +184,17 @@ public:
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     aName.Assign(mName);
   }
 
   uint64_t
   Version() const;
 
-  already_AddRefed<nsIDOMDOMStringList>
+  already_AddRefed<mozilla::dom::DOMStringList>
   GetObjectStoreNames(ErrorResult& aRv) const;
 
   already_AddRefed<IDBObjectStore>
   CreateObjectStore(JSContext* aCx, const nsAString& aName,
                     const IDBObjectStoreParameters& aOptionalParameters,
                     ErrorResult& aRv);
 
   void
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -19,17 +19,17 @@
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/dom/ipc/Blob.h"
 #include "mozilla/dom/quota/FileStreams.h"
 #include "mozilla/Endian.h"
 #include "mozilla/storage.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsDOMFile.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsEventDispatcher.h"
 #include "nsJSUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "snappy/snappy.h"
 
 #include "AsyncConnectionHelper.h"
 #include "IDBCursor.h"
@@ -2632,39 +2632,31 @@ IDBObjectStore::GetKeyPath(JSContext* aC
   if (JSVAL_IS_GCTHING(mCachedKeyPath)) {
     mozilla::HoldJSObjects(this);
     mRooted = true;
   }
 
   return mCachedKeyPath;
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 IDBObjectStore::GetIndexNames(ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
-
-  nsAutoTArray<nsString, 10> names;
+  nsRefPtr<DOMStringList> list(new DOMStringList());
+
+  nsTArray<nsString>& names = list->StringArray();
   uint32_t count = mInfo->indexes.Length();
   names.SetCapacity(count);
 
   for (uint32_t index = 0; index < count; index++) {
     names.InsertElementSorted(mInfo->indexes[index].name);
   }
 
-  for (uint32_t index = 0; index < count; index++) {
-    if (!list->Add(names[index])) {
-      IDB_WARNING("Failed to add element!");
-      aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
-      return nullptr;
-    }
-  }
-
   return list.forget();
 }
 
 already_AddRefed<IDBRequest>
 IDBObjectStore::Get(JSContext* aCx, JS::Handle<JS::Value> aKey,
                     ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
--- a/dom/indexedDB/IDBObjectStore.h
+++ b/dom/indexedDB/IDBObjectStore.h
@@ -280,17 +280,17 @@ public:
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     aName.Assign(mName);
   }
 
   JS::Value
   GetKeyPath(JSContext* aCx, ErrorResult& aRv);
 
-  already_AddRefed<nsIDOMDOMStringList>
+  already_AddRefed<DOMStringList>
   GetIndexNames(ErrorResult& aRv);
 
   IDBTransaction*
   Transaction() const
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     return mTransaction;
   }
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -9,17 +9,17 @@
 #include "IDBTransaction.h"
 
 #include "nsIAppShell.h"
 #include "nsIScriptContext.h"
 
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "mozilla/storage.h"
 #include "nsDOMClassInfoID.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsEventDispatcher.h"
 #include "nsPIDOMWindow.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 #include "nsWidgetsCID.h"
 
 #include "AsyncConnectionHelper.h"
 #include "DatabaseInfo.h"
@@ -666,42 +666,28 @@ IDBTransaction::GetError(ErrorResult& aR
   if (IsOpen()) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
   return mError;
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 IDBTransaction::GetObjectStoreNames(ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
-
-  nsAutoTArray<nsString, 10> stackArray;
-  nsTArray<nsString>* arrayOfNames;
+  nsRefPtr<DOMStringList> list(new DOMStringList());
 
   if (mMode == IDBTransaction::VERSION_CHANGE) {
-    mDatabaseInfo->GetObjectStoreNames(stackArray);
-
-    arrayOfNames = &stackArray;
+    mDatabaseInfo->GetObjectStoreNames(list->StringArray());
   }
   else {
-    arrayOfNames = &mObjectStoreNames;
-  }
-
-  uint32_t count = arrayOfNames->Length();
-  for (uint32_t index = 0; index < count; index++) {
-    if (!list->Add(arrayOfNames->ElementAt(index))) {
-      IDB_WARNING("Failed to add element!");
-      aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
-      return nullptr;
-    }
+    list->StringArray() = mObjectStoreNames;
   }
 
   return list.forget();
 }
 
 already_AddRefed<IDBObjectStore>
 IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv)
 {
--- a/dom/indexedDB/IDBTransaction.h
+++ b/dom/indexedDB/IDBTransaction.h
@@ -249,17 +249,17 @@ public:
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     aRv = AbortInternal(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR, nullptr);
   }
 
   IMPL_EVENT_HANDLER(abort)
   IMPL_EVENT_HANDLER(complete)
   IMPL_EVENT_HANDLER(error)
 
-  already_AddRefed<nsIDOMDOMStringList>
+  already_AddRefed<DOMStringList>
   GetObjectStoreNames(ErrorResult& aRv);
 
 private:
   nsresult
   AbortInternal(nsresult aAbortCode,
                 already_AddRefed<mozilla::dom::DOMError> aError);
 
   // Should only be called directly through IndexedDBDatabaseChild.
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -23,17 +23,16 @@ interface nsIDOMDOMImplementation;
 interface nsIDOMDocument;
 interface nsIDOMDocumentFragment;
 interface nsIDOMDocumentType;
 interface nsIDOMElement;
 interface nsIDOMNode;
 interface nsIDOMNodeList;
 interface nsIDOMProcessingInstruction;
 interface nsIDOMText;
-interface nsIDOMDOMStringList;
 interface nsIDOMClientRect;
 interface nsIDOMClientRectList;
 
 // Needed for raises() in our IDL
 interface DOMException;
 
 // Style Sheets
 interface nsIDOMStyleSheetList;
--- a/dom/interfaces/core/moz.build
+++ b/dom/interfaces/core/moz.build
@@ -9,17 +9,16 @@ XPIDL_SOURCES += [
     'nsIDOMCDATASection.idl',
     'nsIDOMCharacterData.idl',
     'nsIDOMComment.idl',
     'nsIDOMDocument.idl',
     'nsIDOMDocumentFragment.idl',
     'nsIDOMDocumentType.idl',
     'nsIDOMDOMException.idl',
     'nsIDOMDOMImplementation.idl',
-    'nsIDOMDOMStringList.idl',
     'nsIDOMElement.idl',
     'nsIDOMMozNamedAttrMap.idl',
     'nsIDOMNode.idl',
     'nsIDOMNodeList.idl',
     'nsIDOMNSEditableElement.idl',
     'nsIDOMProcessingInstruction.idl',
     'nsIDOMText.idl',
     'nsIDOMUserDataHandler.idl',
deleted file mode 100644
--- a/dom/interfaces/core/nsIDOMDOMStringList.idl
+++ /dev/null
@@ -1,18 +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/. */
-
-/**
- * Corresponds to http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407
- */
-
-#include "domstubs.idl"
-
-[scriptable, uuid(0bbae65c-1dde-11d9-8c46-000a95dc234c)]
-interface nsIDOMDOMStringList : nsISupports
-{
-  DOMString          item(in unsigned long index);
-  readonly attribute unsigned long   length;
-  boolean            contains(in DOMString str);
-};
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -27,17 +27,17 @@ interface nsIDOMLocation;
  * cannot exist outside the context of a Document, the nsIDOMDocument 
  * interface also contains the factory methods needed to create these 
  * objects.
  *
  * For more information on this interface please see 
  * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  */
 
-[scriptable, uuid(aa4b59de-462a-4f61-abd9-4232fef3dacc)]
+[scriptable, uuid(d24d1118-a527-4d5a-9c4e-fb07dfc2fc27)]
 interface nsIDOMDocument : nsIDOMNode
 {
   readonly attribute nsIDOMDocumentType         doctype;
   readonly attribute nsIDOMDOMImplementation    implementation;
   readonly attribute nsIDOMElement              documentElement;
   nsIDOMElement                 createElement([Null(Stringify)] in DOMString tagName)
                                   raises(DOMException);
   nsIDOMDocumentFragment        createDocumentFragment();
@@ -223,17 +223,17 @@ interface nsIDOMDocument : nsIDOMNode
    * this document available to the implementation, in the order they are
    * listed in the styleSheets attribute, adding the title of each style sheet
    * with a title to the list, avoiding duplicates by dropping titles that
    * match (case-sensitively) titles that have already been added to the
    * list.
    *
    * @see <http://dev.w3.org/csswg/cssom/#dom-document-styleSheetSets>
    */
-  readonly attribute nsIDOMDOMStringList styleSheetSets;
+  readonly attribute nsISupports styleSheetSets;
 
   /**
    * Calling this method must change the disabled attribute on each StyleSheet
    * object with a title attribute with a length greater than 0 in the
    * styleSheets attribute, so that all those whose title matches the name
    * argument are enabled, and all others are disabled. Title matches must be
    * case-sensitive. Calling this method with the empty string disables all
    * alternate and preferred style sheets (but does not change the state of
--- a/dom/interfaces/core/nsIDOMXMLDocument.idl
+++ b/dom/interfaces/core/nsIDOMXMLDocument.idl
@@ -1,16 +1,16 @@
 /* -*- 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/. */
 
 #include "nsIDOMDocument.idl"
 
-[scriptable, uuid(90903f50-7611-42c1-a13c-dac4e735bee2)]
+[scriptable, uuid(ebf9f390-7cd2-4456-bc53-4869019370ea)]
 interface nsIDOMXMLDocument : nsIDOMDocument
 {
   // DOM Level 3 Load & Save, DocumentLS
   // http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS
   /**
    * Whether to load synchronously or asynchronously.
    * The default is async==true.
    */
--- a/dom/interfaces/events/nsIDOMDataTransfer.idl
+++ b/dom/interfaces/events/nsIDOMDataTransfer.idl
@@ -3,17 +3,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 "domstubs.idl"
 
 interface nsIVariant;
 interface nsIDOMFileList;
 
-[scriptable, builtinclass, uuid(4ba241dd-a964-4077-bc30-515a657772e4)]
+[scriptable, builtinclass, uuid(c71180e3-298b-4fbb-9ccb-82c822474741)]
 interface nsIDOMDataTransfer : nsISupports
 {
   /**
    * The actual effect that will be used, and should always be one of the
    * possible values of effectAllowed.
    *
    * For dragstart, drag and dragleave events, the dropEffect is initialized
    * to none. Any value assigned to the dropEffect will be set, but the value
@@ -66,17 +66,17 @@ interface nsIDOMDataTransfer : nsISuppor
    */
   readonly attribute nsIDOMFileList files;
 
   /**
    * Holds a list of the format types of the data that is stored for the first
    * item, in the same order the data was added. An empty list will be
    * returned if no data was added.
    */
-  readonly attribute nsIDOMDOMStringList types;
+  readonly attribute nsISupports types;
 
   /**
    * Remove the data associated with a given format. If format is empty or not
    * specified, the data associated with all formats is removed. If data for
    * the specified format does not exist, or the data transfer contains no
    * data, this method will have no effect.
    */
   void clearData([optional] in DOMString format);
@@ -148,17 +148,17 @@ interface nsIDOMDataTransfer : nsISuppor
    */
   attribute DOMString mozCursor;
 
   /**
    * Holds a list of the format types of the data that is stored for an item
    * at the specified index. If the index is not in the range from 0 to
    * itemCount - 1, an empty string list is returned.
    */
-  nsIDOMDOMStringList mozTypesAt(in unsigned long index);
+  nsISupports mozTypesAt(in unsigned long index);
 
   /**
    * Remove the data associated with the given format for an item at the
    * specified index. The index is in the range from zero to itemCount - 1.
    *
    * If the last format for the item is removed, the entire item is removed,
    * reducing the itemCount by one.
    *
--- a/dom/interfaces/html/nsIDOMHTMLDocument.idl
+++ b/dom/interfaces/html/nsIDOMHTMLDocument.idl
@@ -8,17 +8,17 @@
 /**
  * The nsIDOMHTMLDocument interface is the interface to a [X]HTML
  * document object.
  *
  * @see <http://www.whatwg.org/html/>
  */
 interface nsISelection;
 
-[scriptable, uuid(7147c7ea-393e-454f-8de8-e356861bd9a7)]
+[scriptable, uuid(b73be9dd-bcc8-44df-8b01-3389e277427f)]
 interface nsIDOMHTMLDocument : nsIDOMDocument
 {
            attribute DOMString            domain;
            attribute DOMString            cookie;
 
   readonly attribute nsIDOMHTMLHeadElement head;
            attribute nsIDOMHTMLElement    body;
 
--- a/dom/interfaces/offline/nsIDOMOfflineResourceList.idl
+++ b/dom/interfaces/offline/nsIDOMOfflineResourceList.idl
@@ -1,24 +1,22 @@
 /* -*- 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/. */
 
 #include "domstubs.idl"
 
-interface nsIDOMDOMStringList;
-
-[scriptable, uuid(c105fe6f-5603-40b2-b3d0-84cb51fab9f4)]
+[scriptable, uuid(6044702d-e4a9-420c-b711-558b7d6a3b9f)]
 interface nsIDOMOfflineResourceList : nsISupports
 {
   /**
    * Get the list of dynamically-managed entries.
    */
-  readonly attribute nsIDOMDOMStringList mozItems;
+  readonly attribute nsISupports mozItems;
 
   /**
    * Check that an entry exists in the list of dynamically-managed entries.
    *
    * @param uri
    *        The resource to check.
    */
   boolean mozHasItem(in DOMString uri);
--- a/dom/interfaces/xul/nsIDOMXULDocument.idl
+++ b/dom/interfaces/xul/nsIDOMXULDocument.idl
@@ -5,17 +5,17 @@
 
 #include "domstubs.idl"
 #include "nsIDOMDocument.idl"
 
 interface nsIDOMXULCommandDispatcher;
 interface nsIObserver;
 interface nsIBoxObject;
 
-[scriptable, uuid(e057a0ef-4be3-4d60-b45a-6cb9d35d8563)]
+[scriptable, uuid(efdb94fb-642f-4a79-ae20-9a5f7cb7f736)]
 interface nsIDOMXULDocument : nsIDOMDocument
 {
   attribute nsIDOMNode                          popupNode;
 
   /**
    * These attributes correspond to trustedGetPopupNode().rangeOffset and
    * rangeParent. They will help you find where in the DOM the popup is
    * happening. Can be accessed from chrome only, and only during a popup
--- a/dom/mobileconnection/tests/marionette/test_mobile_set_radio.js
+++ b/dom/mobileconnection/tests/marionette/test_mobile_set_radio.js
@@ -142,17 +142,19 @@ function testDisableRadioWhenDataConnect
   log("= testDisableRadioWhenDataConnected =");
   return waitRadioState("enabled")
     .then(enableData)
     .then(setRadioEnabled.bind(null, false, "disabling", "disabled"))
     .then(() => {
       // Data should be disconnected.
       is(connection.data.connected, false);
     })
-    .then(setRadioEnabled.bind(null, true, "enabling", "enabled"));
+    .then(setRadioEnabled.bind(null, true, "enabling", "enabled"))
+    // Disable data
+    .then(setSetting.bind(null, DATA_KEY, false));
 }
 
 function cleanUp() {
   SpecialPowers.removePermission("mobileconnection", document);
   SpecialPowers.removePermission("settings-write", document);
   SpecialPowers.removePermission("settings-read", document);
   SpecialPowers.clearUserPref("dom.mozSettings.enabled");
   finish();
--- a/dom/src/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/src/offline/nsDOMOfflineResourceList.cpp
@@ -1,17 +1,17 @@
 /* -*- 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 "nsDOMOfflineResourceList.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsError.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsIPrefetchService.h"
 #include "nsCPrefetchService.h"
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "nsICacheSession.h"
 #include "nsICacheService.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsAutoPtr.h"
@@ -176,51 +176,61 @@ nsDOMOfflineResourceList::Disconnect()
     mListenerManager = nullptr;
   }
 }
 
 //
 // nsDOMOfflineResourceList::nsIDOMOfflineResourceList
 //
 
-NS_IMETHODIMP
-nsDOMOfflineResourceList::GetMozItems(nsIDOMDOMStringList **aItems)
+already_AddRefed<DOMStringList>
+nsDOMOfflineResourceList::GetMozItems(ErrorResult& aRv)
 {
-  if (IS_CHILD_PROCESS()) 
-    return NS_ERROR_NOT_IMPLEMENTED;
+  if (IS_CHILD_PROCESS()) {
+    aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+    return nullptr;
+  }
 
-  *aItems = nullptr;
-
-  nsRefPtr<nsDOMStringList> items = new nsDOMStringList();
+  nsRefPtr<DOMStringList> items = new DOMStringList();
 
   // If we are not associated with an application cache, return an
   // empty list.
   nsCOMPtr<nsIApplicationCache> appCache = GetDocumentAppCache();
   if (!appCache) {
-    NS_ADDREF(*aItems = items);
-    return NS_OK;
+    return items.forget();
   }
 
-  nsresult rv = Init();
-  NS_ENSURE_SUCCESS(rv, rv);
+  aRv = Init();
+  if (aRv.Failed()) {
+    return nullptr;
+  }
 
   uint32_t length;
   char **keys;
-  rv = appCache->GatherEntries(nsIApplicationCache::ITEM_DYNAMIC,
-                               &length, &keys);
-  NS_ENSURE_SUCCESS(rv, rv);
+  aRv = appCache->GatherEntries(nsIApplicationCache::ITEM_DYNAMIC,
+                                &length, &keys);
+  if (aRv.Failed()) {
+    return nullptr;
+  }
 
   for (uint32_t i = 0; i < length; i++) {
     items->Add(NS_ConvertUTF8toUTF16(keys[i]));
   }
 
   NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(length, keys);
 
-  NS_ADDREF(*aItems = items);
-  return NS_OK;
+  return items.forget();
+}
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::GetMozItems(nsISupports** aItems)
+{
+  ErrorResult rv;
+  *aItems = GetMozItems(rv).get();
+  return rv.ErrorCode();
 }
 
 NS_IMETHODIMP
 nsDOMOfflineResourceList::MozHasItem(const nsAString& aURI, bool* aExists)
 {
   if (IS_CHILD_PROCESS()) 
     return NS_ERROR_NOT_IMPLEMENTED;
 
--- a/dom/src/offline/nsDOMOfflineResourceList.h
+++ b/dom/src/offline/nsDOMOfflineResourceList.h
@@ -21,20 +21,25 @@
 #include "nsIDOMEventListener.h"
 #include "nsDOMEvent.h"
 #include "nsIObserver.h"
 #include "nsIScriptContext.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsPIDOMWindow.h"
 #include "nsDOMEventTargetHelper.h"
 #include "mozilla/ErrorResult.h"
-#include "nsIDOMDOMStringList.h"
 
 class nsIDOMWindow;
 
+namespace mozilla {
+namespace dom {
+class DOMStringList;
+} // namespace dom
+} // namespace mozilla
+
 class nsDOMOfflineResourceList : public nsDOMEventTargetHelper,
                                  public nsIDOMOfflineResourceList,
                                  public nsIObserver,
                                  public nsIOfflineCacheUpdateObserver,
                                  public nsSupportsWeakReference
 {
   typedef mozilla::ErrorResult ErrorResult;
 
@@ -83,22 +88,17 @@ public:
   IMPL_EVENT_HANDLER(error)
   IMPL_EVENT_HANDLER(noupdate)
   IMPL_EVENT_HANDLER(downloading)
   IMPL_EVENT_HANDLER(progress)
   IMPL_EVENT_HANDLER(cached)
   IMPL_EVENT_HANDLER(updateready)
   IMPL_EVENT_HANDLER(obsolete)
 
-  already_AddRefed<nsIDOMDOMStringList> GetMozItems(ErrorResult& aRv)
-  {
-    nsCOMPtr<nsIDOMDOMStringList> items;
-    aRv = GetMozItems(getter_AddRefs(items));
-    return items.forget();
-  }
+  already_AddRefed<mozilla::dom::DOMStringList> GetMozItems(ErrorResult& aRv);
   bool MozHasItem(const nsAString& aURI, ErrorResult& aRv)
   {
     bool hasItem = false;
     aRv = MozHasItem(aURI, &hasItem);
     return hasItem;
   }
   uint32_t GetMozLength(ErrorResult& aRv)
   {
--- a/dom/system/gonk/NetworkInterfaceListService.js
+++ b/dom/system/gonk/NetworkInterfaceListService.js
@@ -30,17 +30,20 @@ NetworkInterfaceListService.prototype = 
       cpmm.sendSyncMessage(
         'NetworkInterfaceList:ListInterface',
         {
           excludeSupl: (aConditions &
                         Ci.nsINetworkInterfaceListService.
                         LIST_NOT_INCLUDE_SUPL_INTERFACES) != 0,
           excludeMms: (aConditions &
                        Ci.nsINetworkInterfaceListService.
-                       LIST_NOT_INCLUDE_MMS_INTERFACES) != 0
+                       LIST_NOT_INCLUDE_MMS_INTERFACES) != 0,
+          excludeIms: (aConditions &
+                       Ci.nsINetworkInterfaceListService.
+                       LIST_NOT_INCLUDE_IMS_INTERFACES) != 0
         }
       )[0]);
   }
 };
 
 function NetworkInterfaceList (aInterfaces) {
   this._interfaces = aInterfaces;
 }
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -187,19 +187,17 @@ NetworkManager.prototype = {
     switch (topic) {
       case TOPIC_INTERFACE_STATE_CHANGED:
         let network = subject.QueryInterface(Ci.nsINetworkInterface);
         debug("Network " + network.name + " changed state to " + network.state);
         switch (network.state) {
           case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED:
 #ifdef MOZ_B2G_RIL
             // Add host route for data calls
-            if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
-                network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
-                network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
+            if (this.isNetworkTypeMobile(network.type)) {
               gNetworkService.removeHostRoutes(network.name);
               gNetworkService.addHostRoute(network);
             }
             // Add extra host route. For example, mms proxy or mmsc.
             this.setExtraHostRoute(network);
 #endif
             // Remove pre-created default route and let setAndConfigureActive()
             // to set default route only on preferred network
@@ -218,19 +216,17 @@ NetworkManager.prototype = {
 
             // Probing the public network accessibility after routing table is ready
             CaptivePortalDetectionHelper
               .notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active);
             break;
           case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED:
 #ifdef MOZ_B2G_RIL
             // Remove host route for data calls
-            if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
-                network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
-                network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
+            if (this.isNetworkTypeMobile(network.type)) {
               gNetworkService.removeHostRoute(network);
             }
             // Remove extra host route. For example, mms proxy or mmsc.
             this.removeExtraHostRoute(network);
 #endif
             // Remove routing table in /proc/net/route
             if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
               gNetworkService.resetRoutingTable(network);
@@ -287,34 +283,36 @@ NetworkManager.prototype = {
         break;
     }
   },
 
   receiveMessage: function(aMsg) {
     switch (aMsg.name) {
       case "NetworkInterfaceList:ListInterface": {
 #ifdef MOZ_B2G_RIL
-        let excludeMms = aMsg.json.exculdeMms;
-        let excludeSupl = aMsg.json.exculdeSupl;
+        let excludeMms = aMsg.json.excludeMms;
+        let excludeSupl = aMsg.json.excludeSupl;
+        let excludeIms = aMsg.json.excludeIms;
 #endif
         let interfaces = [];
 
         for each (let i in this.networkInterfaces) {
 #ifdef MOZ_B2G_RIL
           if ((i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
-              (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL && excludeSupl)) {
+              (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL && excludeSupl) ||
+              (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS && excludeIms)) {
             continue;
           }
 #endif
           interfaces.push({
             state: i.state,
             type: i.type,
             name: i.name,
             ip: i.ip,
-            netmask: i.netmask,
+            prefixLength: i.prefixLength,
             broadcast: i.broadcast,
             gateway: i.gateway,
             dns1: i.dns1,
             dns2: i.dns2,
             httpProxyHost: i.httpProxyHost,
             httpProxyPort: i.httpProxyPort
           });
         }
@@ -332,19 +330,17 @@ NetworkManager.prototype = {
     }
     if (network.name in this.networkInterfaces) {
       throw Components.Exception("Network with that name already registered!",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
     this.networkInterfaces[network.name] = network;
 #ifdef MOZ_B2G_RIL
     // Add host route for data calls
-    if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
-        network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
-        network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
+    if (this.isNetworkTypeMobile(network.type)) {
       gNetworkService.addHostRoute(network);
     }
 #endif
     // Remove pre-created default route and let setAndConfigureActive()
     // to set default route only on preferred network
     gNetworkService.removeDefaultRoute(network.name);
     this.setAndConfigureActive();
     Services.obs.notifyObservers(network, TOPIC_INTERFACE_REGISTERED, null);
@@ -358,19 +354,17 @@ NetworkManager.prototype = {
     }
     if (!(network.name in this.networkInterfaces)) {
       throw Components.Exception("No network with that name registered.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
     delete this.networkInterfaces[network.name];
 #ifdef MOZ_B2G_RIL
     // Remove host route for data calls
-    if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
-        network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
-        network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
+    if (this.isNetworkTypeMobile(network.type)) {
       gNetworkService.removeHostRoute(network);
     }
 #endif
     this.setAndConfigureActive();
     Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null);
     debug("Network '" + network.name + "' unregistered.");
   },
 
@@ -392,31 +386,38 @@ NetworkManager.prototype = {
       throw "Invalid network type";
     }
     this._preferredNetworkType = val;
   },
 
   active: null,
   _overriddenActive: null,
 
-  // Clone network info so we can still get information when network is disconnected
-  _activeInfo: null,
-
   overrideActive: function(network) {
 #ifdef MOZ_B2G_RIL
-    if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
-        network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
+    if (this.isNetworkTypeSecondaryMobile(network.type)) {
       throw "Invalid network type";
     }
 #endif
     this._overriddenActive = network;
     this.setAndConfigureActive();
   },
 
 #ifdef MOZ_B2G_RIL
+  isNetworkTypeSecondaryMobile: function(type) {
+    return (type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
+            type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL ||
+            type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS);
+  },
+
+  isNetworkTypeMobile: function(type) {
+    return (type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
+            this.isNetworkTypeSecondaryMobile(type));
+  },
+
   setExtraHostRoute: function(network) {
     if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
       if (!(network instanceof Ci.nsIRilNetworkInterface)) {
         debug("Network for MMS must be an instance of nsIRilNetworkInterface");
         return;
       }
 
       network = network.QueryInterface(Ci.nsIRilNetworkInterface);
@@ -482,50 +483,46 @@ NetworkManager.prototype = {
         this.active.type == this._preferredNetworkType) {
       debug("Active network is already our preferred type.");
       gNetworkService.setDefaultRouteAndDNS(this.active, oldActive);
       return;
     }
 
     // Find a suitable network interface to activate.
     this.active = null;
-    this._activeInfo = Object.create(null);
 #ifdef MOZ_B2G_RIL
     let defaultDataNetwork;
 #endif
     for each (let network in this.networkInterfaces) {
       if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
         continue;
       }
 #ifdef MOZ_B2G_RIL
       if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
         defaultDataNetwork = network;
       }
 #endif
       this.active = network;
-      this._activeInfo = {name:network.name, ip:network.ip, netmask:network.netmask};
       if (network.type == this.preferredNetworkType) {
         debug("Found our preferred type of network: " + network.name);
         break;
       }
     }
     if (this.active) {
 #ifdef MOZ_B2G_RIL
       // Give higher priority to default data APN than seconary APN.
       // If default data APN is not connected, we still set default route
       // and DNS on seconary APN.
       if (defaultDataNetwork &&
-          (this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
-           this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) &&
+          this.isNetworkTypeSecondaryMobile(this.active.type) &&
           this.active.type != this.preferredNetworkType) {
         this.active = defaultDataNetwork;
       }
       // Don't set default route on secondary APN
-      if (this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
-          this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
+      if (this.isNetworkTypeSecondaryMobile(this.active.type)) {
         gNetworkService.setDNS(this.active);
       } else {
 #endif // MOZ_B2G_RIL
         gNetworkService.setDefaultRouteAndDNS(this.active, oldActive);
 #ifdef MOZ_B2G_RIL
       }
 #endif
       if (this.active != oldActive) {
--- a/dom/system/gonk/NetworkService.js
+++ b/dom/system/gonk/NetworkService.js
@@ -260,25 +260,25 @@ NetworkService.prototype = {
         callback.wifiOperationModeResult("netd command error");
       } else {
         callback.wifiOperationModeResult(null);
       }
     });
   },
 
   resetRoutingTable: function(network) {
-    if (!network.ip || !network.netmask) {
-      if(DEBUG) debug("Either ip or netmask is null. Cannot reset routing table.");
+    if (!network.ip || !network.prefixLength) {
+      if(DEBUG) debug("Either ip or prefixLength is null. Cannot reset routing table.");
       return;
     }
     let options = {
       cmd: "removeNetworkRoute",
       ifname: network.name,
       ip: network.ip,
-      netmask: network.netmask
+      prefixLength: network.prefixLength
     };
     this.controlMessage(options, function() {});
   },
 
   setDNS: function(networkInterface) {
     if(DEBUG) debug("Going DNS to " + networkInterface.name);
     let options = {
       cmd: "setDNS",
@@ -510,25 +510,27 @@ NetworkService.prototype = {
       callback.enableUsbRndisResult(data.result, data.enable);
     });
   },
 
   updateUpStream: function(previous, current, callback) {
     let params = {
       cmd: "updateUpStream",
       isAsync: true,
-      previous: previous,
-      current: current
+      preInternalIfname: previous.internalIfname,
+      preExternalIfname: previous.externalIfname,
+      curInternalIfname: current.internalIfname,
+      curExternalIfname: current.externalIfname
     };
 
     this.controlMessage(params, function(data) {
       let code = data.resultCode;
       let reason = data.resultReason;
       if(DEBUG) debug("updateUpStream result: Code " + code + " reason " + reason);
-      callback.updateUpStreamResult(!isError(code), data.current.externalIfname);
+      callback.updateUpStreamResult(!isError(code), data.curExternalIfname);
     });
   },
 
   shutdown: false,
 
   observe: function observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case "xpcom-shutdown":
--- a/dom/system/gonk/NetworkUtils.cpp
+++ b/dom/system/gonk/NetworkUtils.cpp
@@ -17,17 +17,17 @@
 
 #include <android/log.h>
 #include <cutils/properties.h>
 #include <limits>
 #include "mozilla/dom/network/NetUtils.h"
 
 #define _DEBUG 0
 
-#define WARN(args...)   __android_log_print(ANDROID_LOG_WARN,  "NetworlUtils", ## args)
+#define WARN(args...)   __android_log_print(ANDROID_LOG_WARN,  "NetworkUtils", ## args)
 #define ERROR(args...)  __android_log_print(ANDROID_LOG_ERROR,  "NetworkUtils", ## args)
 
 #if _DEBUG
 #define DEBUG(args...)  __android_log_print(ANDROID_LOG_DEBUG, "NetworkUtils" , ## args)
 #else
 #define DEBUG(args...)
 #endif
 
@@ -60,17 +60,17 @@ static const uint32_t NETD_COMMAND_FAIL 
 static const uint32_t NETD_COMMAND_ERROR        = 500;
 // 6xx - Unsolicited broadcasts
 static const uint32_t NETD_COMMAND_UNSOLICITED  = 600;
 
 // Broadcast messages
 static const uint32_t NETD_COMMAND_INTERFACE_CHANGE     = 600;
 static const uint32_t NETD_COMMAND_BANDWIDTH_CONTROLLER = 601;
 
-static const char* INTERFACE_DELIMIT = "\0";
+static const char* INTERFACE_DELIMIT = ",";
 static const char* USB_CONFIG_DELIMIT = ",";
 static const char* NETD_MESSAGE_DELIMIT = " ";
 
 static const uint32_t BUF_SIZE = 1024;
 
 static uint32_t SDK_VERSION;
 
 struct IFProperties {
@@ -206,27 +206,25 @@ CommandFunc NetworkUtils::sNetworkInterf
 };
 
 CommandFunc NetworkUtils::sSetDnsChain[] = {
   NetworkUtils::setDefaultInterface,
   NetworkUtils::setInterfaceDns
 };
 
 /**
- * Helper function to get the bit length from given mask.
+ * Helper function to get the mask from given prefix length.
  */
-static uint32_t getMaskLength(const uint32_t mask)
+static uint32_t makeMask(const uint32_t prefixLength)
 {
-  uint32_t netmask = ntohl(mask);
-  uint32_t len = 0;
-  while (netmask & 0x80000000) {
-    len++;
-    netmask = netmask << 1;
+  uint32_t mask = 0;
+  for (uint32_t i = 0; i < prefixLength; ++i) {
+    mask |= (0x80000000 >> i);
   }
-  return len;
+  return ntohl(mask);
 }
 
 /**
  * Helper function to split string by seperator, store split result as an nsTArray.
  */
 static void split(char* str, const char* sep, nsTArray<nsCString>& result)
 {
   char *s = strtok(str, sep);
@@ -438,23 +436,38 @@ void NetworkUtils::stopAccessPointDriver
  *     argv[8] - Max SCB
  *
  * Command format for sdk version >= 16
  *   Arguments:
  *     argv[2] - wlan interface
  *     argv[3] - SSID
  *     argv[4] - Security
  *     argv[5] - Key
+ *
+ * Command format for sdk version >= 18
+ *   Arguments:
+ *      argv[2] - wlan interface
+ *      argv[3] - SSID
+ *      argv[4] - Broadcast/Hidden
+ *      argv[5] - Channel
+ *      argv[6] - Security
+ *      argv[7] - Key
  */
 void NetworkUtils::setAccessPoint(CommandChain* aChain,
                                   CommandCallback aCallback,
                                   NetworkResultOptions& aResult)
 {
   char command[MAX_COMMAND_SIZE];
-  if (SDK_VERSION >= 16) {
+  if (SDK_VERSION >= 19) {
+    snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" broadcast 6 %s \"%s\"",
+                     GET_CHAR(mIfname),
+                     GET_CHAR(mSsid),
+                     GET_CHAR(mSecurity),
+                     GET_CHAR(mKey));
+  } else if (SDK_VERSION >= 16) {
     snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s \"%s\" %s \"%s\"",
                      GET_CHAR(mIfname),
                      GET_CHAR(mSsid),
                      GET_CHAR(mSecurity),
                      GET_CHAR(mKey));
   } else {
     snprintf(command, MAX_COMMAND_SIZE - 1, "softap set %s %s \"%s\" %s \"%s\" 6 0 8",
                      GET_CHAR(mIfname),
@@ -913,16 +926,17 @@ NetworkUtils::NetworkUtils(MessageCallba
   gNetworkUtils = this;
 }
 
 NetworkUtils::~NetworkUtils()
 {
 }
 
 #define GET_CHAR(prop) NS_ConvertUTF16toUTF8(aOptions.prop).get()
+#define GET_FIELD(prop) aOptions.prop
 
 void NetworkUtils::ExecuteCommand(NetworkParams aOptions)
 {
   bool ret = true;
 
   if (aOptions.mCmd.EqualsLiteral("removeNetworkRoute")) {
     removeNetworkRoute(aOptions);
   } else if (aOptions.mCmd.EqualsLiteral("setDNS")) {
@@ -1021,17 +1035,16 @@ void NetworkUtils::onNetdMessage(NetdCom
 
   if (gCurrentCommand.callback) {
     char buf[BUF_SIZE];
     join(gReason, INTERFACE_DELIMIT, BUF_SIZE, buf);
 
     NetworkResultOptions result;
     result.mResultCode = code;
     result.mResultReason = NS_ConvertUTF8toUTF16(buf);
-    join(gReason, INTERFACE_DELIMIT, BUF_SIZE, buf);
     (*gCurrentCommand.callback)(gCurrentCommand.chain, isError(code), result);
     gReason.Clear();
   }
 
   // Handling pending commands if any.
   if (isComplete(code)) {
     nextNetdCommand();
   }
@@ -1154,19 +1167,19 @@ bool NetworkUtils::removeHostRoutes(Netw
 {
   mNetUtils->do_ifc_remove_host_routes(GET_CHAR(mIfname));
   return true;
 }
 
 bool NetworkUtils::removeNetworkRoute(NetworkParams& aOptions)
 {
   uint32_t ip = inet_addr(GET_CHAR(mIp));
-  uint32_t netmask = inet_addr(GET_CHAR(mNetmask));
+  uint32_t prefixLength = GET_FIELD(mPrefixLength);
+  uint32_t netmask = makeMask(prefixLength);
   uint32_t subnet = ip & netmask;
-  uint32_t prefixLength = getMaskLength(netmask);
   const char* gateway = "0.0.0.0";
   struct in_addr addr;
   addr.s_addr = subnet;
   const char* dst = inet_ntoa(addr);
 
   mNetUtils->do_ifc_remove_default_route(GET_CHAR(mIfname));
   mNetUtils->do_ifc_remove_route(GET_CHAR(mIfname), dst, prefixLength, gateway);
   return true;
@@ -1470,8 +1483,9 @@ void NetworkUtils::dumpParams(NetworkPar
     DEBUG("     ssid: %s", GET_CHAR(mSsid));
     DEBUG("     security: %s", GET_CHAR(mSecurity));
     DEBUG("     key: %s", GET_CHAR(mKey));
   }
 #endif
 }
 
 #undef GET_CHAR
+#undef GET_FIELD
--- a/dom/system/gonk/NetworkUtils.h
+++ b/dom/system/gonk/NetworkUtils.h
@@ -33,17 +33,17 @@ public:
     mDomain = aOther.mDomain;
     mDns1_str = aOther.mDns1_str;
     mDns2_str = aOther.mDns2_str;
     mGateway = aOther.mGateway;
     mGateway_str = aOther.mGateway_str;
     mHostnames = aOther.mHostnames;
     mId = aOther.mId;
     mIfname = aOther.mIfname;
-    mNetmask = aOther.mNetmask;
+    mPrefixLength = aOther.mPrefixLength;
     mOldIfname = aOther.mOldIfname;
     mMode = aOther.mMode;
     mReport = aOther.mReport;
     mIsAsync = aOther.mIsAsync;
     mEnabled = aOther.mEnabled;
     mWifictrlinterfacename = aOther.mWifictrlinterfacename;
     mInternalIfname = aOther.mInternalIfname;
     mExternalIfname = aOther.mExternalIfname;
@@ -110,17 +110,17 @@ public:
     COPY_OPT_STRING_FIELD(mDomain, EmptyString())
     COPY_OPT_STRING_FIELD(mDns1_str, EmptyString())
     COPY_OPT_STRING_FIELD(mDns2_str, EmptyString())
     COPY_OPT_STRING_FIELD(mGateway, EmptyString())
     COPY_OPT_STRING_FIELD(mGateway_str, EmptyString())
     COPY_SEQUENCE_FIELD(mHostnames, nsString)
     COPY_OPT_STRING_FIELD(mIfname, EmptyString())
     COPY_OPT_STRING_FIELD(mIp, EmptyString())
-    COPY_OPT_STRING_FIELD(mNetmask, EmptyString())
+    COPY_OPT_FIELD(mPrefixLength, 0)
     COPY_OPT_STRING_FIELD(mOldIfname, EmptyString())
     COPY_OPT_STRING_FIELD(mMode, EmptyString())
     COPY_OPT_FIELD(mReport, false)
     COPY_OPT_FIELD(mIsAsync, true)
     COPY_OPT_FIELD(mEnabled, false)
     COPY_OPT_STRING_FIELD(mWifictrlinterfacename, EmptyString())
     COPY_OPT_STRING_FIELD(mInternalIfname, EmptyString())
     COPY_OPT_STRING_FIELD(mExternalIfname, EmptyString())
@@ -161,17 +161,17 @@ public:
   nsString mDomain;
   nsString mDns1_str;
   nsString mDns2_str;
   nsString mGateway;
   nsString mGateway_str;
   nsTArray<nsString> mHostnames;
   nsString mIfname;
   nsString mIp;
-  nsString mNetmask;
+  uint32_t mPrefixLength;
   nsString mOldIfname;
   nsString mMode;
   bool mReport;
   bool mIsAsync;
   bool mEnabled;
   nsString mWifictrlinterfacename;
   nsString mInternalIfname;
   nsString mExternalIfname;
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -2147,33 +2147,28 @@ RadioInterface.prototype = {
       case "cdmaCallWaiting":
         gTelephonyProvider.notifyCdmaCallWaiting(this.clientId, message.number);
         break;
       case "suppSvcNotification":
         gTelephonyProvider.notifySupplementaryService(this.clientId,
                                                       message.callIndex,
                                                       message.notification);
         break;
-      case "conferenceError":
-        gTelephonyProvider.notifyConferenceError(message.errorName,
-                                                 message.errorMsg);
-        break;
       case "datacallerror":
         connHandler.handleDataCallError(message);
         break;
       case "datacallstatechange":
         message.ip = null;
-        message.netmask = null;
+        message.prefixLength = 0;
         message.broadcast = null;
         if (message.ipaddr) {
           message.ip = message.ipaddr.split("/")[0];
+          message.prefixLength = parseInt(message.ipaddr.split("/")[1], 10);
           let ip_value = netHelpers.stringToIP(message.ip);
-          let prefix_len = message.ipaddr.split("/")[1];
-          let mask_value = netHelpers.makeMask(prefix_len);
-          message.netmask = netHelpers.ipToString(mask_value);
+          let mask_value = netHelpers.makeMask(message.prefixLength);
           message.broadcast = netHelpers.ipToString((ip_value & mask_value) + ~mask_value);
         }
         connHandler.handleDataCallState(message);
         break;
       case "datacalllist":
         connHandler.handleDataCallList(message);
         break;
       case "emergencyCbModeChange":
@@ -4175,19 +4170,23 @@ RadioInterface.prototype = {
   },
 
   deactivateDataCall: function(cid, reason) {
     this.workerMessenger.send("deactivateDataCall", { cid: cid,
                                                       reason: reason });
   },
 
   sendWorkerMessage: function(rilMessageType, message, callback) {
-    this.workerMessenger.send(rilMessageType, message, function(response) {
-      return callback.handleResponse(response);
-    });
+    if (callback) {
+      this.workerMessenger.send(rilMessageType, message, function(response) {
+        return callback.handleResponse(response);
+      });
+    } else {
+      this.workerMessenger.send(rilMessageType, message);
+    }
   }
 };
 
 function RILNetworkInterface(dataConnectionHandler, apnSetting) {
   this.dataConnectionHandler = dataConnectionHandler;
   this.apnSetting = apnSetting;
   this.connectedTypes = [];
 }
@@ -4210,16 +4209,17 @@ RILNetworkInterface.prototype = {
   NETWORK_STATE_CONNECTED:     Ci.nsINetworkInterface.CONNECTED,
   NETWORK_STATE_DISCONNECTING: Ci.nsINetworkInterface.DISCONNECTING,
   NETWORK_STATE_DISCONNECTED:  Ci.nsINetworkInterface.DISCONNECTED,
 
   NETWORK_TYPE_WIFI:        Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
   NETWORK_TYPE_MOBILE:      Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE,
   NETWORK_TYPE_MOBILE_MMS:  Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS,
   NETWORK_TYPE_MOBILE_SUPL: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL,
+  NETWORK_TYPE_MOBILE_IMS:  Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS,
   // The network manager should only need to add the host route for "other"
   // types, which is the same handling method as the supl type. So let the
   // definition of other types to be the same as the one of supl type.
   NETWORK_TYPE_MOBILE_OTHERS: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL,
 
   /**
    * Standard values for the APN connection retry process
    * Retry funcion: time(secs) = A * numer_of_retries^2 + B
@@ -4242,24 +4242,27 @@ RILNetworkInterface.prototype = {
       return this.NETWORK_TYPE_MOBILE;
     }
     if (this.connectedTypes.indexOf("mms") != -1) {
       return this.NETWORK_TYPE_MOBILE_MMS;
     }
     if (this.connectedTypes.indexOf("supl") != -1) {
       return this.NETWORK_TYPE_MOBILE_SUPL;
     }
+    if (this.connectedTypes.indexOf("ims") != -1) {
+      return this.NETWORK_TYPE_MOBILE_IMS;
+    }
     return this.NETWORK_TYPE_MOBILE_OTHERS;
   },
 
   name: null,
 
   ip: null,
 
-  netmask: null,
+  prefixLength: 0,
 
   broadcast: null,
 
   dns1: null,
 
   dns2: null,
 
   get httpProxyHost() {
@@ -4370,17 +4373,17 @@ RILNetworkInterface.prototype = {
     }
     if (this.connecting &&
         (datacall.state == RIL.GECKO_NETWORK_STATE_CONNECTING ||
          datacall.state == RIL.GECKO_NETWORK_STATE_CONNECTED)) {
       this.connecting = false;
       this.cid = datacall.cid;
       this.name = datacall.ifname;
       this.ip = datacall.ip;
-      this.netmask = datacall.netmask;
+      this.prefixLength = datacall.prefixLength;
       this.broadcast = datacall.broadcast;
       this.gateway = datacall.gw;
       if (datacall.dns) {
         this.dns1 = datacall.dns[0];
         this.dns2 = datacall.dns[1];
       }
       if (!this.registeredAsNetworkInterface) {
         gNetworkManager.registerNetworkInterface(this);
--- a/dom/system/gonk/nsINetworkInterfaceListService.idl
+++ b/dom/system/gonk/nsINetworkInterfaceListService.idl
@@ -15,21 +15,22 @@ interface nsINetworkInterfaceList : nsIS
 
   /**
    * Get the i-th interface from the list.
    * @param interfaceIndex index of interface, from 0 to number of interface - 1.
    */
   nsINetworkInterface getInterface(in long interfaceIndex);
 };
 
-[scriptable, uuid(5be50bcb-bfe9-4742-b7e6-3e9bb4835369)]
+[scriptable, uuid(e3cf9355-086e-46e3-bb3d-378bd58d578b)]
 interface nsINetworkInterfaceListService : nsISupports
 {
-  const long LIST_NOT_INCLUDE_MMS_INTERFACES = 1;
-  const long LIST_NOT_INCLUDE_SUPL_INTERFACES = 2;
+  const long LIST_NOT_INCLUDE_MMS_INTERFACES  = (1 << 0);
+  const long LIST_NOT_INCLUDE_SUPL_INTERFACES = (1 << 1);
+  const long LIST_NOT_INCLUDE_IMS_INTERFACES  = (1 << 2);
 
   /**
    * Obtain a list of network interfaces that satisfy the specified condition.
    * @param condition flags that specify the interfaces to be returned. This
    *        can be OR combination of LIST_* flags, or zero to make all available
    *        interfaces returned.
    */
   nsINetworkInterfaceList getDataInterfaceList(in long condition);
--- a/dom/system/gonk/nsINetworkManager.idl
+++ b/dom/system/gonk/nsINetworkManager.idl
@@ -4,17 +4,17 @@
 
 #include "nsISupports.idl"
 
 interface nsIWifiTetheringCallback;
 
 /**
  * Information about networks that is exposed to network manager API consumers.
  */
-[scriptable, uuid(e2f5c6e0-4203-11e3-aa6e-0800200c9a66)]
+[scriptable, uuid(4d738144-ac69-48ef-b97e-49cc627fae67)]
 interface nsINetworkInterface : nsISupports
 {
   const long NETWORK_STATE_UNKNOWN = -1;
   const long NETWORK_STATE_CONNECTING = 0;
   const long NETWORK_STATE_CONNECTED = 1;
   const long NETWORK_STATE_DISCONNECTING = 2;
   const long NETWORK_STATE_DISCONNECTED = 3;
 
@@ -27,16 +27,17 @@ interface nsINetworkInterface : nsISuppo
   readonly attribute long state;
 
   const long NETWORK_TYPE_UNKNOWN     = -1;
   const long NETWORK_TYPE_WIFI        = 0;
   const long NETWORK_TYPE_MOBILE      = 1;
   const long NETWORK_TYPE_MOBILE_MMS  = 2;
   const long NETWORK_TYPE_MOBILE_SUPL = 3;
   const long NETWORK_TYPE_WIFI_P2P    = 4;
+  const long NETWORK_TYPE_MOBILE_IMS  = 5;
 
   /**
    * Network type. One of the NETWORK_TYPE_* constants.
    */
   readonly attribute long type;
 
   /**
    * Name of the network interface. This identifier is unique.
@@ -44,19 +45,19 @@ interface nsINetworkInterface : nsISuppo
   readonly attribute DOMString name;
 
   /**
    * IP Address
    */
   readonly attribute DOMString ip;
 
   /**
-   * Netmask
+   * Network prefix length
    */
-  readonly attribute DOMString netmask;
+  readonly attribute unsigned long prefixLength;
 
   /**
    * Broadcast
    */
   readonly attribute DOMString broadcast;
 
   /**
    * Default gateway
--- a/dom/system/gonk/nsIRadioInterfaceLayer.idl
+++ b/dom/system/gonk/nsIRadioInterfaceLayer.idl
@@ -16,29 +16,29 @@ interface nsIRilNetworkInterface : nsINe
   readonly attribute DOMString iccId;
 
   /* The following attributes are for MMS proxy settings. */
   readonly attribute DOMString mmsc;     // Empty string if not set.
   readonly attribute DOMString mmsProxy; // Empty string if not set.
   readonly attribute long      mmsPort;  // -1 if not set.
 };
 
-[scriptable, uuid(1e602d20-d066-4399-8997-daf36b3158ef)]
+[scriptable, uuid(83dd3394-5de0-4485-a0b9-c1ed537507a3)]
 interface nsIRILDataCallInfo : nsISupports
 {
   /**
    * Current data call state, one of the
    * nsINetworkInterface::NETWORK_STATE_* constants.
    */
   readonly attribute unsigned long state;
   readonly attribute AString cid;
   readonly attribute AString apn;
   readonly attribute AString ifname;
   readonly attribute AString ip;
-  readonly attribute AString netmask;
+  readonly attribute unsigned long prefixLength;
   readonly attribute AString broadcast;
   readonly attribute AString gw;
   readonly attribute jsval dns;
 };
 
 [scriptable, uuid(5bcac053-c245-46f0-bb45-d0039bfb89f5)]
 interface nsIRILDataCallback : nsISupports
 {
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -31,17 +31,16 @@ this.REQUEST_CHANGE_SIM_PIN2 = 7;
 this.REQUEST_ENTER_NETWORK_DEPERSONALIZATION_CODE = 8;
 this.REQUEST_GET_CURRENT_CALLS = 9;
 this.REQUEST_DIAL = 10;
 this.REQUEST_GET_IMSI = 11;
 this.REQUEST_HANGUP = 12;
 this.REQUEST_HANGUP_WAITING_OR_BACKGROUND = 13;
 this.REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND = 14;
 this.REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE = 15;
-this.REQUEST_SWITCH_HOLDING_AND_ACTIVE = 15;
 this.REQUEST_CONFERENCE = 16;
 this.REQUEST_UDUB = 17;
 this.REQUEST_LAST_CALL_FAIL_CAUSE = 18;
 this.REQUEST_SIGNAL_STRENGTH = 19;
 this.REQUEST_VOICE_REGISTRATION_STATE = 20;
 this.REQUEST_DATA_REGISTRATION_STATE = 21;
 this.REQUEST_OPERATOR = 22;
 this.REQUEST_RADIO_POWER = 23;
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -1461,53 +1461,73 @@ RilObject.prototype = {
       return;
     }
 
     // Exit emergency callback mode when user dial a non-emergency call.
     if (this._isInEmergencyCbMode) {
       this.exitEmergencyCbMode();
     }
 
-    options.request = REQUEST_DIAL;
-    this.sendDialRequest(options);
+    if (this._isCdma && Object.keys(this.currentCalls).length == 1) {
+      // Make a Cdma 3way call.
+      options.featureStr = options.number;
+      this.sendCdmaFlashCommand(options);
+    } else {
+      options.request = REQUEST_DIAL;
+      this.sendDialRequest(options);
+    }
   },
 
   dialEmergencyNumber: function(options, onerror) {
     options.request = RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL ?
                       REQUEST_DIAL_EMERGENCY_CALL : REQUEST_DIAL;
-
     if (this.radioState == GECKO_RADIOSTATE_OFF) {
       if (DEBUG) {
         this.context.debug("Automatically enable radio for an emergency call.");
       }
 
       if (!this.cachedDialRequest) {
         this.cachedDialRequest = {};
       }
       this.cachedDialRequest.onerror = onerror;
       this.cachedDialRequest.callback = this.sendDialRequest.bind(this, options);
       this.setRadioEnabled({enabled: true});
       return;
     }
 
-    this.sendDialRequest(options);
+    if (this._isCdma && Object.keys(this.currentCalls).length == 1) {
+      // Make a Cdma 3way call.
+      options.featureStr = options.number;
+      this.sendCdmaFlashCommand(options);
+    } else {
+      this.sendDialRequest(options);
+    }
   },
 
   sendDialRequest: function(options) {
     let Buf = this.context.Buf;
     Buf.newParcel(options.request, options);
     Buf.writeString(options.number);
     Buf.writeInt32(options.clirMode || 0);
     Buf.writeInt32(options.uusInfo || 0);
     // TODO Why do we need this extra 0? It was put it in to make this
     // match the format of the binary message.
     Buf.writeInt32(0);
     Buf.sendParcel();
   },
 
+  sendCdmaFlashCommand: function(options) {
+    let Buf = this.context.Buf;
+    options.isCdma = true;
+    options.request = REQUEST_CDMA_FLASH;
+    Buf.newParcel(options.request, options);
+    Buf.writeString(options.featureStr);
+    Buf.sendParcel();
+  },
+
   /**
    * Hang up all calls
    */
   hangUpAll: function() {
     for (let callIndex in this.currentCalls) {
       this.hangUp({callIndex: callIndex});
     }
   },
@@ -1613,57 +1633,100 @@ RilObject.prototype = {
         // Reject the waiting (second) call, and remain the first call.
         Buf.simpleRequest(REQUEST_HANGUP_WAITING_OR_BACKGROUND);
         break;
     }
   },
 
   holdCall: function(options) {
     let call = this.currentCalls[options.callIndex];
-    if (call && call.state == CALL_STATE_ACTIVE) {
-      let Buf = this.context.Buf;
-      if (this._isCdma) {
-        Buf.newParcel(REQUEST_CDMA_FLASH);
-        Buf.writeString("");
-        Buf.sendParcel();
-      } else {
-        Buf.simpleRequest(REQUEST_SWITCH_HOLDING_AND_ACTIVE);
-      }
-    }
-  },
+    if (!call) {
+      options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
+      options.success = false;
+      this.sendChromeMessage(options);
+      return;
+    }
+
+    let Buf = this.context.Buf;
+    if (this._isCdma) {
+      options.featureStr = "";
+      this.sendCdmaFlashCommand(options);
+    } else if (call.state == CALL_STATE_ACTIVE) {
+      Buf.simpleRequest(REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE, options);
+    }
+ },
 
   resumeCall: function(options) {
     let call = this.currentCalls[options.callIndex];
-    if (call && call.state == CALL_STATE_HOLDING) {
-      this.context.Buf.simpleRequest(REQUEST_SWITCH_HOLDING_AND_ACTIVE);
+    if (!call) {
+      options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
+      options.success = false;
+      this.sendChromeMessage(options);
+      return;
+    }
+
+    let Buf = this.context.Buf;
+    if (this._isCdma) {
+      options.featureStr = "";
+      this.sendCdmaFlashCommand(options);
+    } else if (call.state == CALL_STATE_HOLDING) {
+      Buf.simpleRequest(REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE, options);
     }
   },
 
   // Flag indicating whether user has requested making a conference call.
   _hasConferenceRequest: false,
 
   conferenceCall: function(options) {
-    this._hasConferenceRequest = true;
-    this.context.Buf.simpleRequest(REQUEST_CONFERENCE, options);
+    let Buf = this.context.Buf;
+    if (this._isCdma) {
+      options.featureStr = "";
+      this.sendCdmaFlashCommand(options);
+    } else {
+      this._hasConferenceRequest = true;
+      Buf.simpleRequest(REQUEST_CONFERENCE, options);
+    }
   },
 
   separateCall: function(options) {
-    let Buf = this.context.Buf;
-    Buf.newParcel(REQUEST_SEPARATE_CONNECTION, options);
-    Buf.writeInt32(1);
-    Buf.writeInt32(options.callIndex);
-    Buf.sendParcel();
-  },
+    let call = this.currentCalls[options.callIndex];
+    if (!call) {
+      options.errorName = "removeError";
+      options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
+      options.success = false;
+      this.sendChromeMessage(options);
+      return;
+    }
+
+    let Buf = this.context.Buf;
+    if (this._isCdma) {
+      options.featureStr = "";
+      this.sendCdmaFlashCommand(options);
+    } else {
+      Buf.newParcel(REQUEST_SEPARATE_CONNECTION, options);
+      Buf.writeInt32(1);
+      Buf.writeInt32(options.callIndex);
+      Buf.sendParcel();
+    }
+ },
 
   holdConference: function() {
-    this.context.Buf.simpleRequest(REQUEST_SWITCH_HOLDING_AND_ACTIVE);
+    if (this._isCdma) {
+      return;
+    }
+
+    this.context.Buf.simpleRequest(REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
   },
 
   resumeConference: function() {
-    this.context.Buf.simpleRequest(REQUEST_SWITCH_HOLDING_AND_ACTIVE);
+    if (this._isCdma) {
+      return;
+    }
+
+    this.context.Buf.simpleRequest(REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
   },
 
   /**
    * Send an SMS.
    *
    * The `options` parameter object should contain the following attributes:
    *
    * @param number
@@ -5287,41 +5350,37 @@ RilObject.prototype[REQUEST_HANGUP_WAITI
 RilObject.prototype[REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND] = function REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND(length, options) {
   if (options.rilRequestError) {
     return;
   }
 
   this.getCurrentCalls();
 };
 RilObject.prototype[REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE] = function REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE(length, options) {
-  if (options.rilRequestError) {
+  options.success = (options.rilRequestError === 0);
+  if (!options.success) {
+    options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
+    this.sendChromeMessage(options);
     return;
   }
 
-  this.getCurrentCalls();
-};
-RilObject.prototype[REQUEST_SWITCH_HOLDING_AND_ACTIVE] = function REQUEST_SWITCH_HOLDING_AND_ACTIVE(length, options) {
-  if (options.rilRequestError) {
-    return;
-  }
-
-  // XXX Normally we should get a UNSOLICITED_RESPONSE_CALL_STATE_CHANGED parcel
-  // notifying us of call state changes, but sometimes we don't (have no idea why).
-  // this.getCurrentCalls() helps update the call state actively.
+  this.sendChromeMessage(options);
   this.getCurrentCalls();
 };
 RilObject.prototype[REQUEST_CONFERENCE] = function REQUEST_CONFERENCE(length, options) {
-  if (options.rilRequestError) {
+  options.success = (options.rilRequestError === 0);
+  if (!options.success) {
     this._hasConferenceRequest = false;
-    options = {rilMessageType: "conferenceError",
-               errorName: "addError",
-               errorMsg: RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]};
+    options.errorName = "addError";
+    options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
+
+  this.sendChromeMessage(options);
 };
 RilObject.prototype[REQUEST_UDUB] = null;
 RilObject.prototype[REQUEST_LAST_CALL_FAIL_CAUSE] = function REQUEST_LAST_CALL_FAIL_CAUSE(length, options) {
   let Buf = this.context.Buf;
   let num = length ? Buf.readInt32() : 0;
   let failCause = num ? RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[Buf.readInt32()] : null;
   if (options.callback) {
     options.callback(failCause);
@@ -5898,23 +5957,25 @@ RilObject.prototype[REQUEST_BASEBAND_VER
   if (options.rilRequestError) {
     return;
   }
 
   this.basebandVersion = this.context.Buf.readString();
   if (DEBUG) this.context.debug("Baseband version: " + this.basebandVersion);
 };
 RilObject.prototype[REQUEST_SEPARATE_CONNECTION] = function REQUEST_SEPARATE_CONNECTION(length, options) {
-  if (options.rilRequestError) {
-    options = {rilMessageType: "conferenceError",
-               errorName: "removeError",
-               errorMsg: RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]};
+  options.success = (options.rilRequestError === 0);
+  if (!options.success) {
+    options.errorName = "removeError";
+    options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
     return;
   }
+
+  this.sendChromeMessage(options);
 };
 RilObject.prototype[REQUEST_SET_MUTE] = null;
 RilObject.prototype[REQUEST_GET_MUTE] = null;
 RilObject.prototype[REQUEST_QUERY_CLIP] = function REQUEST_QUERY_CLIP(length, options) {
   options.success = (options.rilRequestError === 0);
   if (!options.success) {
     options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
     this.sendChromeMessage(options);
@@ -6120,17 +6181,29 @@ RilObject.prototype[REQUEST_CDMA_QUERY_P
     this.sendChromeMessage(options);
     return;
   }
 
   let enabled = this.context.Buf.readInt32List();
   options.enabled = enabled[0] ? true : false;
   this.sendChromeMessage(options);
 };
-RilObject.prototype[REQUEST_CDMA_FLASH] = null;
+RilObject.prototype[REQUEST_CDMA_FLASH] = function REQUEST_CDMA_FLASH(length, options) {
+  options.success = (options.rilRequestError === 0);
+  if (!options.success) {
+    if (options.rilMessageType === "conferenceCall") {
+      options.errorName = "addError";
+    } else if (options.rilMessageType === "separateCall") {
+      options.errorName = "removeError";
+    }
+    options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
+  }
+
+  this.sendChromeMessage(options);
+};
 RilObject.prototype[REQUEST_CDMA_BURST_DTMF] = null;
 RilObject.prototype[REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY] = null;
 RilObject.prototype[REQUEST_CDMA_SEND_SMS] = function REQUEST_CDMA_SEND_SMS(length, options) {
   this._processSmsSendResult(length, options);
 };
 RilObject.prototype[REQUEST_CDMA_SMS_ACKNOWLEDGE] = null;
 RilObject.prototype[REQUEST_GSM_GET_BROADCAST_SMS_CONFIG] = null;
 RilObject.prototype[REQUEST_GSM_SET_BROADCAST_SMS_CONFIG] = function REQUEST_GSM_SET_BROADCAST_SMS_CONFIG(length, options) {
--- a/dom/system/gonk/tests/marionette/manifest.ini
+++ b/dom/system/gonk/tests/marionette/manifest.ini
@@ -4,8 +4,9 @@ browser = false
 qemu = true
 
 [test_geolocation.js]
 disabled = Bug 808783
 [test_fakevolume.js]
 [test_ril_code_quality.py]
 [test_screen_state.js]
 [test_dsds_numRadioInterfaces.js]
+[test_data_connection.js]
new file mode 100644
--- /dev/null
+++ b/dom/system/gonk/tests/marionette/test_data_connection.js
@@ -0,0 +1,204 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_CONTEXT = "chrome";
+
+Cu.import("resource://gre/modules/Promise.jsm");
+
+const DATA_KEY = "ril.data.enabled";
+const APN_KEY  = "ril.data.apnSettings";
+
+let ril = Cc["@mozilla.org/ril;1"].getService(Ci.nsIRadioInterfaceLayer);
+ok(ril, "ril.constructor is " + ril.constructor);
+
+let radioInterface = ril.getRadioInterface(0);
+ok(radioInterface, "radioInterface.constructor is " + radioInterface.constrctor);
+
+function setSetting(key, value) {
+  log("setSetting: '" + key + "'' -> " + JSON.stringify(value));
+
+  let deferred = Promise.defer();
+  let obj = {};
+  obj[key] = value;
+
+  let setRequest = window.navigator.mozSettings.createLock().set(obj);
+  setRequest.addEventListener("success", function() {
+    log("set '" + key + "' to " + JSON.stringify(value) + " success");
+    deferred.resolve();
+  });
+  setRequest.addEventListener("error", function() {
+    ok(false, "cannot set '" + key + "' to " + JSON.stringify(value));
+    deferred.reject();
+  });
+
+  return deferred.promise;
+}
+
+function getSetting(key) {
+  log("getSetting: '" + key + "'");
+
+  let deferred = Promise.defer();
+
+  let getRequest = window.navigator.mozSettings.createLock().get(key);
+  getRequest.addEventListener("success", function() {
+    let result = getRequest.result[key];
+	  log("setting '" + key + "': " + JSON.stringify(result));
+	  deferred.resolve(result);
+  });
+  getRequest.addEventListener("error", function() {
+    ok(false, "cannot get '" + key + "'");
+    deferred.reject();
+  });
+
+  return deferred.promise;
+}
+
+function setEmulatorAPN() {
+  let apn = [
+    [{"carrier":"T-Mobile US",
+      "apn":"epc.tmobile.com",
+      "mmsc":"http://mms.msg.eng.t-mobile.com/mms/wapenc",
+      "types":["default","supl","mms","ims"]}]
+  ];
+
+  return setSetting(APN_KEY, apn);
+}
+
+function waitNetworkConnected(networkType) {
+  log("wait network " + networkType + " connected");
+
+  let interfaceStateChangeTopic = "network-interface-state-changed";
+  let obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+  let deferred = Promise.defer();
+
+  function observer(subject, topic, data) {
+    let network = subject.QueryInterface(Ci.nsINetworkInterface);
+    log("Network " + network.type + " state changes to " + network.state);
+    if (network.type == networkType &&
+        network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
+      obs.removeObserver(observer, interfaceStateChangeTopic);
+      deferred.resolve();
+    }
+  }
+
+  obs.addObserver(observer, interfaceStateChangeTopic, false);
+
+  return deferred.promise;
+}
+
+function waitNetworkDisconnected(networkType) {
+  log("wait network " + networkType + " disconnected");
+
+  let interfaceStateChangeTopic = "network-interface-state-changed";
+  let obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+  let deferred = Promise.defer();
+
+  function observer(subject, topic, data) {
+    let network = subject.QueryInterface(Ci.nsINetworkInterface);
+    log("Network " + network.type + " state changes to " + network.state);
+    // We can not check network.type here cause network.type would return
+    // NETWORK_TYPE_MOBILE_SUPL (NETWORK_TYPE_MOBILE_OTHERS) when disconnecting
+    // and disconnected, see bug 939046.
+    if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED ||
+        network.state == Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN) {
+      obs.removeObserver(observer, interfaceStateChangeTopic);
+      deferred.resolve();
+    }
+  }
+
+  obs.addObserver(observer, interfaceStateChangeTopic, false);
+
+  return deferred.promise;
+}
+
+// Test initial State
+function testInitialState() {
+  log("= testInitialState =");
+
+  // Data should be off before starting any test.
+  return Promise.resolve()
+    .then(() => getSetting(DATA_KEY))
+    .then(value => {
+      is(value, false, "Data must be off");
+    })
+    .then(null, () => {
+      ok(false, "promise rejected during test");
+    })
+    .then(runNextTest);
+}
+
+// Test default data Connection
+function testDefaultDataConnection() {
+  log("= testDefaultDataConnection =");
+
+  return Promise.resolve()
+    // Enable data
+    .then(() => setSetting(DATA_KEY, true))
+    .then(() => waitNetworkConnected(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE))
+    // Disable data
+    .then(() => setSetting(DATA_KEY, false))
+    .then(() => waitNetworkDisconnected(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE))
+    .then(null, () => {
+      ok(false, "promise rejected during test");
+    })
+    .then(runNextTest);
+}
+
+// Test non default data connection
+function testNonDefaultDataConnection() {
+  log("= testNonDefaultDataConnection =");
+
+  function doTestNonDefaultDataConnection(type) {
+    log("doTestNonDefaultDataConnection: " + type);
+
+    let typeMapping = {
+      "mms": Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS,
+      "supl": Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL,
+      "ims": Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS
+    };
+    let networkType = typeMapping[type];
+
+    return Promise.resolve()
+      .then(() => radioInterface.setupDataCallByType(type))
+      .then(() => waitNetworkConnected(networkType))
+      .then(() => radioInterface.deactivateDataCallByType(type))
+      .then(() => waitNetworkDisconnected(networkType));
+  }
+
+  let currentApn;
+  return Promise.resolve()
+    .then(() => getSetting(APN_KEY))
+    .then(value => {
+      currentApn = value;
+    })
+    .then(setEmulatorAPN)
+    .then(() => doTestNonDefaultDataConnection("mms"))
+    .then(() => doTestNonDefaultDataConnection("supl"))
+    .then(() => doTestNonDefaultDataConnection("ims"))
+    // Restore APN settings
+    .then(() => setSetting(APN_KEY, currentApn))
+    .then(null, () => {
+      ok(false, "promise rejected during test");
+    })
+    .then(runNextTest);
+}
+
+let tests = [
+  testInitialState,
+  testDefaultDataConnection,
+  testNonDefaultDataConnection
+];
+
+function runNextTest() {
+  let test = tests.shift();
+  if (!test) {
+    finish();
+    return;
+  }
+
+  test();
+}
+
+// Start Tests
+runNextTest();
--- a/dom/system/nsDeviceSensors.cpp
+++ b/dom/system/nsDeviceSensors.cpp
@@ -387,17 +387,17 @@ nsDeviceSensors::FireDOMMotionEvent(nsID
              mLastAccelerationIncluduingGravity.empty() ||
              mLastRotationRate.empty()) {
     return;
   }
 
   nsCOMPtr<nsIDOMEvent> event;
   domdoc->CreateEvent(NS_LITERAL_STRING("DeviceMotionEvent"), getter_AddRefs(event));
 
-  nsDOMDeviceMotionEvent* me = static_cast<nsDOMDeviceMotionEvent*>(event.get());
+  DeviceMotionEvent* me = static_cast<DeviceMotionEvent*>(event.get());
 
   ErrorResult rv;
   me->InitDeviceMotionEvent(NS_LITERAL_STRING("devicemotion"),
                             true,
                             false,
                             mLastAcceleration.ref(),
                             mLastAccelerationIncluduingGravity.ref(),
                             mLastRotationRate.ref(),
--- a/dom/system/nsDeviceSensors.h
+++ b/dom/system/nsDeviceSensors.h
@@ -6,17 +6,17 @@
 #define nsDeviceSensors_h
 
 #include "nsIDeviceSensors.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsITimer.h"
 #include "nsIDOMDeviceOrientationEvent.h"
-#include "nsDOMDeviceMotionEvent.h"
+#include "mozilla/dom/DeviceMotionEvent.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/HalSensor.h"
 #include "nsDataHashtable.h"
 
 class nsIDOMWindow;
 
 namespace mozilla {
 namespace dom {
--- a/dom/telephony/Telephony.cpp
+++ b/dom/telephony/Telephony.cpp
@@ -531,17 +531,17 @@ Telephony::EventListenerAdded(nsIAtom* a
 }
 
 // nsITelephonyListener
 
 NS_IMETHODIMP
 Telephony::CallStateChanged(uint32_t aServiceId, uint32_t aCallIndex,
                             uint16_t aCallState, const nsAString& aNumber,
                             bool aIsActive, bool aIsOutgoing, bool aIsEmergency,
-                            bool aIsConference)
+                            bool aIsConference, bool aIsSwitchable, bool aIsMergeable)
 {
   NS_ASSERTION(aCallIndex != kOutgoingPlaceholderCallIndex,
                "This should never happen!");
 
   nsRefPtr<TelephonyCall> modifiedCall
       = GetCallFromEverywhere(aServiceId, aCallIndex);
 
   // Try to use the outgoing call if we don't find the modified call.
@@ -554,16 +554,19 @@ Telephony::CallStateChanged(uint32_t aSe
         aCallState != nsITelephonyProvider::CALL_STATE_INCOMING) {
       outgoingCall->UpdateCallIndex(aCallIndex);
       outgoingCall->UpdateEmergency(aIsEmergency);
       modifiedCall.swap(outgoingCall);
     }
   }
 
   if (modifiedCall) {
+    modifiedCall->UpdateSwitchable(aIsSwitchable);
+    modifiedCall->UpdateMergeable(aIsMergeable);
+
     if (!aIsConference) {
       UpdateActiveCall(modifiedCall, aIsActive);
     }
 
     if (modifiedCall->CallState() != aCallState) {
       // We don't fire the statechange event on a call in conference here.
       // Instead, the event will be fired later in
       // TelephonyCallGroup::ChangeState(). Thus the sequence of firing the
@@ -594,17 +597,18 @@ Telephony::CallStateChanged(uint32_t aSe
   // ended already.
   if (aCallState == nsITelephonyProvider::CALL_STATE_DISCONNECTED) {
     return NS_OK;
   }
 
   // Didn't find this call in mCalls or mGroup. Create a new call.
   nsRefPtr<TelephonyCall> call =
       TelephonyCall::Create(this, aServiceId, aNumber, aCallState, aCallIndex,
-                            aIsEmergency, aIsConference);
+                            aIsEmergency, aIsConference, aIsSwitchable,
+                            aIsMergeable);
   NS_ASSERTION(call, "This should never fail!");
 
   NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) :
                                mCalls.Contains(call),
                "Should have auto-added new call!");
 
   if (aCallState == nsITelephonyProvider::CALL_STATE_INCOMING) {
     nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("incoming"), call);
@@ -633,33 +637,34 @@ Telephony::EnumerateCallStateComplete()
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Telephony::EnumerateCallState(uint32_t aServiceId, uint32_t aCallIndex,
                               uint16_t aCallState, const nsAString& aNumber,
                               bool aIsActive, bool aIsOutgoing, bool aIsEmergency,
-                              bool aIsConference)
+                              bool aIsConference, bool aIsSwitchable, bool aIsMergeable)
 {
   nsRefPtr<TelephonyCall> call;
 
   // We request calls enumeration in constructor, and the asynchronous result
   // will be sent back through the callback function EnumerateCallState().
   // However, it is likely to have call state changes, i.e. CallStateChanged()
   // being called, before the enumeration result comes back. We'd make sure
   // we don't somehow add duplicates due to the race condition.
   call = GetCallFromEverywhere(aServiceId, aCallIndex);
   if (call) {
     return NS_OK;
   }
 
   // Didn't know anything about this call before now.
   call = TelephonyCall::Create(this, aServiceId, aNumber, aCallState,
-                               aCallIndex, aIsEmergency, aIsConference);
+                               aCallIndex, aIsEmergency, aIsConference,
+                               aIsSwitchable, aIsMergeable);
   NS_ASSERTION(call, "This should never fail!");
 
   NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) :
                                mCalls.Contains(call),
                "Should have auto-added new call!");
 
   return NS_OK;
 }
--- a/dom/telephony/TelephonyCall.cpp
+++ b/dom/telephony/TelephonyCall.cpp
@@ -16,31 +16,34 @@
 using namespace mozilla::dom;
 using mozilla::ErrorResult;
 using mozilla::dom::telephony::kOutgoingPlaceholderCallIndex;
 
 // static
 already_AddRefed<TelephonyCall>
 TelephonyCall::Create(Telephony* aTelephony, uint32_t aServiceId,
                       const nsAString& aNumber, uint16_t aCallState,
-                      uint32_t aCallIndex, bool aEmergency, bool aIsConference)
+                      uint32_t aCallIndex, bool aEmergency, bool aIsConference,
+                      bool aSwitchable, bool aMergeable)
 {
   NS_ASSERTION(aTelephony, "Null pointer!");
   NS_ASSERTION(!aNumber.IsEmpty(), "Empty number!");
   NS_ASSERTION(aCallIndex >= 1, "Invalid call index!");
 
   nsRefPtr<TelephonyCall> call = new TelephonyCall(aTelephony->GetOwner());
 
   call->mTelephony = aTelephony;
   call->mServiceId = aServiceId;
   call->mNumber = aNumber;
   call->mCallIndex = aCallIndex;
   call->mError = nullptr;
   call->mEmergency = aEmergency;
   call->mGroup = aIsConference ? aTelephony->ConferenceGroup() : nullptr;
+  call->mSwitchable = aSwitchable;
+  call->mMergeable = aMergeable;
 
   call->ChangeStateInternal(aCallState, false);
 
   return call.forget();
 }
 
 TelephonyCall::TelephonyCall(nsPIDOMWindow* aOwner)
   : nsDOMEventTargetHelper(aOwner),
@@ -250,16 +253,21 @@ TelephonyCall::Hold(ErrorResult& aRv)
     return;
   }
 
   if (mGroup) {
     NS_WARNING("Hold a call in conference ignored!");
     return;
   }
 
+  if (!mSwitchable) {
+    NS_WARNING("Hold a non-switchable call ignored!");
+    return;
+  }
+
   nsresult rv = mTelephony->Provider()->HoldCall(mServiceId, mCallIndex);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return;
   }
 
   if (!mSecondNumber.IsEmpty()) {
     // No state transition when we switch two numbers within one TelephonyCall
@@ -279,16 +287,21 @@ TelephonyCall::Resume(ErrorResult& aRv)
     return;
   }
 
   if (mGroup) {
     NS_WARNING("Resume a call in conference ignored!");
     return;
   }
 
+  if (!mSwitchable) {
+    NS_WARNING("Resume a non-switchable call ignored!");
+    return;
+  }
+
   nsresult rv = mTelephony->Provider()->ResumeCall(mServiceId, mCallIndex);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return;
   }
 
   ChangeStateInternal(nsITelephonyProvider::CALL_STATE_RESUMING, true);
 }
--- a/dom/telephony/TelephonyCall.h
+++ b/dom/telephony/TelephonyCall.h
@@ -22,16 +22,18 @@ class TelephonyCall MOZ_FINAL : public n
   nsRefPtr<TelephonyCallGroup> mGroup;
 
   uint32_t mServiceId;
   nsString mNumber;
   nsString mSecondNumber;
   nsString mState;
   bool mEmergency;
   nsRefPtr<DOMError> mError;
+  bool mSwitchable;
+  bool mMergeable;
 
   uint32_t mCallIndex;
   uint16_t mCallState;
   bool mLive;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
@@ -70,16 +72,28 @@ public:
   }
 
   bool
   Emergency() const
   {
     return mEmergency;
   }
 
+  bool
+  Switchable() const
+  {
+    return mSwitchable;
+  }
+
+  bool
+  Mergeable() const
+  {
+    return mMergeable;
+  }
+
   already_AddRefed<DOMError>
   GetError() const;
 
   already_AddRefed<TelephonyCallGroup>
   GetGroup() const;
 
   void
   Answer(ErrorResult& aRv);
@@ -105,17 +119,18 @@ public:
   IMPL_EVENT_HANDLER(resuming)
   IMPL_EVENT_HANDLER(error)
   IMPL_EVENT_HANDLER(groupchange)
 
   static already_AddRefed<TelephonyCall>
   Create(Telephony* aTelephony, uint32_t aServiceId,
          const nsAString& aNumber, uint16_t aCallState,
          uint32_t aCallIndex = telephony::kOutgoingPlaceholderCallIndex,
-         bool aEmergency = false, bool aIsConference = false);
+         bool aEmergency = false, bool aIsConference = false,
+         bool aSwitchable = true, bool aMergeable = true);
 
   void
   ChangeState(uint16_t aCallState)
   {
     ChangeStateInternal(aCallState, true);
   }
 
   uint32_t
@@ -152,16 +167,26 @@ public:
 
   void
   UpdateSecondNumber(const nsAString& aNumber)
   {
     mSecondNumber = aNumber;
   }
 
   void
+  UpdateSwitchable(bool aSwitchable) {
+    mSwitchable = aSwitchable;
+  }
+
+  void
+  UpdateMergeable(bool aMergeable) {
+    mMergeable = aMergeable;
+  }
+
+  void
   NotifyError(const nsAString& aError);
 
   void
   ChangeGroup(TelephonyCallGroup* aGroup);
 
 private:
   TelephonyCall(nsPIDOMWindow* aOwner);
 
--- a/dom/telephony/TelephonyCallGroup.cpp
+++ b/dom/telephony/TelephonyCallGroup.cpp
@@ -145,31 +145,39 @@ TelephonyCallGroup::DispatchCallEvent(co
   nsRefPtr<CallEvent> event = CallEvent::Create(this, aType, aCall, false, false);
   return DispatchTrustedEvent(event);
 }
 
 bool
 TelephonyCallGroup::CanConference(const TelephonyCall& aCall,
                                   TelephonyCall* aSecondCall)
 {
+  if (!aCall.Mergeable()) {
+    return false;
+  }
+
   if (!aSecondCall) {
     MOZ_ASSERT(!mCalls.IsEmpty());
 
     return (mCallState == nsITelephonyProvider::CALL_STATE_CONNECTED &&
             aCall.CallState() == nsITelephonyProvider::CALL_STATE_HELD) ||
            (mCallState == nsITelephonyProvider::CALL_STATE_HELD &&
             aCall.CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED);
   }
 
   MOZ_ASSERT(mCallState == nsITelephonyProvider::CALL_STATE_UNKNOWN);
 
   if (aCall.ServiceId() != aSecondCall->ServiceId()) {
     return false;
   }
 
+  if (!aSecondCall->Mergeable()) {
+    return false;
+  }
+
   return (aCall.CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED &&
           aSecondCall->CallState() == nsITelephonyProvider::CALL_STATE_HELD) ||
          (aCall.CallState() == nsITelephonyProvider::CALL_STATE_HELD &&
           aSecondCall->CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED);
 }
 
 already_AddRefed<TelephonyCall>
 TelephonyCallGroup::GetCall(uint32_t aServiceId, uint32_t aCallIndex)
--- a/dom/telephony/gonk/TelephonyProvider.js
+++ b/dom/telephony/gonk/TelephonyProvider.js
@@ -27,16 +27,19 @@ const kPrefRilNumRadioInterfaces = "ril.
 const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
 const kPrefDefaultServiceId = "dom.telephony.defaultServiceId";
 
 const nsIAudioManager = Ci.nsIAudioManager;
 const nsITelephonyProvider = Ci.nsITelephonyProvider;
 
 const CALL_WAKELOCK_TIMEOUT = 5000;
 
+// Index of the CDMA second call which isn't held in RIL but only in TelephoyProvider.
+const CDMA_SECOND_CALL_INDEX = 2;
+
 let DEBUG;
 function debug(s) {
   dump("TelephonyProvider: " + s + "\n");
 }
 
 XPCOMUtils.defineLazyGetter(this, "gAudioManager", function getAudioManager() {
   try {
     return Cc["@mozilla.org/telephony/audiomanager;1"]
@@ -107,23 +110,28 @@ function ConferenceCall(state){
 }
 ConferenceCall.prototype = {
   state: null
 };
 
 function TelephonyProvider() {
   this._numClients = gRadioInterfaceLayer.numRadioInterfaces;
   this._listeners = [];
+  this._currentCalls = {};
   this._updateDebugFlag();
   this.defaultServiceId = this._getDefaultServiceId();
 
   Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
   Services.prefs.addObserver(kPrefDefaultServiceId, this, false);
 
   Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
+
+  for (let i = 0; i < this._numClients; ++i) {
+    this._enumerateCallsForClient(i);
+  }
 }
 TelephonyProvider.prototype = {
   classID: GONK_TELEPHONYPROVIDER_CID,
   classInfo: XPCOMUtils.generateCI({classID: GONK_TELEPHONYPROVIDER_CID,
                                     contractID: GONK_TELEPHONYPROVIDER_CONTRACTID,
                                     classDescription: "TelephonyProvider",
                                     interfaces: [Ci.nsITelephonyProvider,
                                                  Ci.nsIGonkTelephonyProvider],
@@ -335,16 +343,39 @@ TelephonyProvider.prototype = {
 
     if (id >= numRil || id < 0) {
       id = 0;
     }
 
     return id;
   },
 
+  _currentCalls: null,
+  _enumerateCallsForClient: function(aClientId) {
+    if (DEBUG) debug("Enumeration of calls for client " + aClientId);
+
+    this._getClient(aClientId).sendWorkerMessage("enumerateCalls", null,
+                                                 (function(response) {
+      if (!this._currentCalls[aClientId]) {
+        this._currentCalls[aClientId] = {};
+      }
+      for (let call of response.calls) {
+        call.clientId = aClientId;
+        call.state = this._convertRILCallState(call.state);
+        call.isActive = this._matchActiveSingleCall(call);
+        call.isSwitchable = true;
+        call.isMergeable = true;
+
+        this._currentCalls[aClientId][call.callIndex] = call;
+      }
+
+      return false;
+    }).bind(this));
+  },
+
   /**
    * nsITelephonyProvider interface.
    */
 
   defaultServiceId: 0,
 
   registerListener: function(aListener) {
     if (this._listeners.indexOf(aListener) >= 0) {
@@ -358,51 +389,34 @@ TelephonyProvider.prototype = {
     let index = this._listeners.indexOf(aListener);
     if (index < 0) {
       throw Cr.NS_ERROR_UNEXPECTED;
     }
 
     this._listeners.splice(index, 1);
   },
 
-  _enumerateCallsForClient: function(aClientId, aListener) {
-    if (DEBUG) debug("Enumeration of calls for client " + aClientId);
-
-    let deferred = Promise.defer();
+  enumerateCalls: function(aListener) {
+    if (DEBUG) debug("Requesting enumeration of calls for callback");
 
-    this._getClient(aClientId).sendWorkerMessage("enumerateCalls", null,
-                                                 (function(response) {
-      for (let call of response.calls) {
-        call.clientId = aClientId;
-        call.state = this._convertRILCallState(call.state);
-        call.isActive = this._matchActiveSingleCall(call);
-
+    for (let cid = 0; cid < this._numClients; ++cid) {
+      let calls = this._currentCalls[cid];
+      if (!calls) {
+        continue;
+      }
+      for (let i = 0, indexes = Object.keys(calls); i < indexes.length; ++i) {
+        let call = calls[indexes[i]];
         aListener.enumerateCallState(call.clientId, call.callIndex,
                                      call.state, call.number,
                                      call.isActive, call.isOutgoing,
-                                     call.isEmergency, call.isConference);
+                                     call.isEmergency, call.isConference,
+                                     call.isSwitchable, call.isMergeable);
       }
-      deferred.resolve();
-
-      return false;
-    }).bind(this));
-
-    return deferred.promise;
-  },
-
-  enumerateCalls: function(aListener) {
-    if (DEBUG) debug("Requesting enumeration of calls for callback");
-
-    let promise = Promise.resolve();
-    for (let i = 0; i < this._numClients; ++i) {
-      promise = promise.then(this._enumerateCallsForClient.bind(this, i, aListener));
     }
-    promise.then(function() {
-      aListener.enumerateCallStateComplete();
-    });
+    aListener.enumerateCallStateComplete();
   },
 
   isDialing: false,
   dial: function(aClientId, aNumber, aIsEmergency, aTelephonyCallback) {
     if (DEBUG) debug("Dialing " + (aIsEmergency ? "emergency " : "") + aNumber);
 
     if (this.isDialing) {
       if (DEBUG) debug("Already has a dialing call. Drop.");
@@ -420,33 +434,80 @@ TelephonyProvider.prototype = {
     if (!gPhoneNumberUtils.isPlainPhoneNumber(aNumber)) {
       // Note: isPlainPhoneNumber also accepts USSD and SS numbers
       if (DEBUG) debug("Number '" + aNumber + "' is not viable. Drop.");
       let errorMsg = RIL.RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[RIL.CALL_FAIL_UNOBTAINABLE_NUMBER];
       aTelephonyCallback.notifyDialError(errorMsg);
       return;
     }
 
+    function onCdmaDialSuccess() {
+      let indexes = Object.keys(this._currentCalls[aClientId]);
+      if (indexes.length != 1 ) {
+        aTelephonyCallback.notifyDialSuccess();
+        return;
+      }
+
+      // RIL doesn't hold the 2nd call. We create one by ourselves.
+      let childCall = {
+        callIndex: CDMA_SECOND_CALL_INDEX,
+        state: RIL.CALL_STATE_DIALING,
+        number: aNumber,
+        isOutgoing: true,
+        isEmergency: false,
+        isConference: false,
+        isSwitchable: false,
+        isMergeable: true,
+        parentId: indexes[0]
+      };
+      aTelephonyCallback.notifyDialSuccess();
+
+      // Manual update call state according to the request response.
+      this.notifyCallStateChanged(aClientId, childCall);
+
+      childCall.state = RIL.CALL_STATE_ACTIVE;
+      this.notifyCallStateChanged(aClientId, childCall);
+
+      let parentCall = this._currentCalls[aClientId][childCall.parentId];
+      parentCall.childId = CDMA_SECOND_CALL_INDEX;
+      parentCall.state = RIL.CALL_STATE_HOLDING;
+      parentCall.isSwitchable = false;
+      parentCall.isMergeable = true;
+      this.notifyCallStateChanged(aClientId, parentCall);
+    };
+
     this.isDialing = true;
     this._getClient(aClientId).sendWorkerMessage("dial", {
       number: aNumber,
       isDialEmergency: aIsEmergency
     }, (function(response) {
       this.isDialing = false;
-      if (response.success) {
+      if (!response.success) {
+        aTelephonyCallback.notifyDialError(response.errorMsg);
+        return false;
+      }
+
+      if (response.isCdma) {
+        onCdmaDialSuccess.call(this);
+      } else {
         aTelephonyCallback.notifyDialSuccess();
-      } else {
-        aTelephonyCallback.notifyDialError(response.errorMsg);
       }
       return false;
     }).bind(this));
   },
 
   hangUp: function(aClientId, aCallIndex) {
-    this._getClient(aClientId).sendWorkerMessage("hangUp", { callIndex: aCallIndex });
+    let parentId = this._currentCalls[aClientId][aCallIndex].parentId;
+    if (parentId) {
+      // Should release both, child and parent, together. Since RIL holds only
+      // the parent call, we send 'parentId' to RIL.
+      this.hangUp(aClientId, parentId);
+    } else {
+      this._getClient(aClientId).sendWorkerMessage("hangUp", { callIndex: aCallIndex });
+    }
   },
 
   startTone: function(aClientId, aDtmfChar) {
     this._getClient(aClientId).sendWorkerMessage("startTone", { dtmfChar: aDtmfChar });
   },
 
   stopTone: function(aClientId) {
     this._getClient(aClientId).sendWorkerMessage("stopTone");
@@ -456,29 +517,197 @@ TelephonyProvider.prototype = {
     this._getClient(aClientId).sendWorkerMessage("answerCall", { callIndex: aCallIndex });
   },
 
   rejectCall: function(aClientId, aCallIndex) {
     this._getClient(aClientId).sendWorkerMessage("rejectCall", { callIndex: aCallIndex });
   },
 
   holdCall: function(aClientId, aCallIndex) {
-    this._getClient(aClientId).sendWorkerMessage("holdCall", { callIndex: aCallIndex });
+    let call = this._currentCalls[aClientId][aCallIndex];
+    if (!call || !call.isSwitchable) {
+      // TODO: Bug 975949 - [B2G] Telephony should throw exceptions when some
+      // operations aren't allowed instead of simply ignoring them.
+      return;
+    }
+
+    let parentId = this._currentCalls[aClientId][aCallIndex].parentId;
+    if (parentId) {
+      this.resumeCall(aClientId, parentId);
+      return;
+    }
+
+    function onCdmaHoldCallSuccess() {
+      let call = this._currentCalls[aClientId][aCallIndex];
+      if (!call) {
+        return;
+      }
+
+      call.state = RIL.CALL_STATE_HOLDING;
+      this.notifyCallStateChanged(aClientId, call);
+
+      if (!call.childId) {
+        return;
+      }
+
+      let childCall = this._currentCalls[aClientId][call.childId];
+      childCall.state = RIL.CALL_STATE_ACTIVE;
+      this.notifyCallStateChanged(aClientId, childCall);
+    };
+
+    this._getClient(aClientId).sendWorkerMessage("holdCall", {
+      callIndex: aCallIndex
+    },(function(response) {
+        if (!response.success) {
+          return false;
+        }
+
+        if (response.isCdma) {
+          onCdmaHoldCallSuccess.call(this);
+        }
+        return false;
+    }).bind(this));
   },
 
   resumeCall: function(aClientId, aCallIndex) {
-    this._getClient(aClientId).sendWorkerMessage("resumeCall", { callIndex: aCallIndex });
+    let call = this._currentCalls[aClientId][aCallIndex];
+    if (!call || !call.isSwitchable) {
+      // TODO: Bug 975949 - [B2G] Telephony should throw exceptions when some
+      // operations aren't allowed instead of simply ignoring them.
+      return;
+    }
+
+    let parentId = this._currentCalls[aClientId][aCallIndex].parentId;
+    if (parentId) {
+      this.holdCall(aClientId, parentId);
+      return;
+    }
+
+    function onCdmaResumeCallSuccess() {
+      let call = this._currentCalls[aClientId][aCallIndex];
+      if (!call) {
+        return;
+      }
+
+      call.state = RIL.CALL_STATE_ACTIVE;
+      this.notifyCallStateChanged(aClientId, call);
+
+      let childId = call.childId;
+      if (!childId) {
+        return;
+      }
+
+      let childCall = this._currentCalls[aClientId][childId];
+      childCall.state = RIL.CALL_STATE_HOLDING;
+      this.notifyCallStateChanged(aClientId, childCall);
+    };
+
+    this._getClient(aClientId).sendWorkerMessage("resumeCall", {
+      callIndex: aCallIndex
+    },(function(response) {
+      if (!response.success) {
+        return false;
+      }
+
+      if (response.isCdma) {
+        onCdmaResumeCallSuccess.call(this);
+      }
+      return false;
+    }).bind(this));
   },
 
   conferenceCall: function(aClientId) {
-    this._getClient(aClientId).sendWorkerMessage("conferenceCall");
+    let indexes = Object.keys(this._currentCalls[aClientId]);
+    if (indexes.length < 2) {
+      // TODO: Bug 975949 - [B2G] Telephony should throw exceptions when some
+      // operations aren't allowed instead of simply ignoring them.
+      return;
+    }
+
+    for (let i = 0; i < indexes.length; ++i) {
+      let call = this._currentCalls[aClientId][indexes[i]];
+      if (!call.isMergeable) {
+        return;
+      }
+    }
+
+    function onCdmaConferenceCallSuccess() {
+      let indexes = Object.keys(this._currentCalls[aClientId]);
+      if (indexes.length < 2) {
+        return;
+      }
+
+      for (let i = 0; i < indexes.length; ++i) {
+        let call = this._currentCalls[aClientId][indexes[i]];
+        call.state = RIL.CALL_STATE_ACTIVE;
+        call.isConference = true;
+        this.notifyCallStateChanged(aClientId, call);
+      }
+      this.notifyConferenceCallStateChanged(RIL.CALL_STATE_ACTIVE);
+    };
+
+    this._getClient(aClientId).sendWorkerMessage("conferenceCall", null,
+                                                 (function(response) {
+      if (!response.success) {
+        this._notifyAllListeners("notifyConferenceError", [response.errorName,
+                                                           response.errorMsg]);
+        return false;
+      }
+
+      if (response.isCdma) {
+        onCdmaConferenceCallSuccess.call(this);
+      }
+      return false;
+    }).bind(this));
   },
 
   separateCall: function(aClientId, aCallIndex) {
-    this._getClient(aClientId).sendWorkerMessage("separateCall", { callIndex: aCallIndex });
+    let call = this._currentCalls[aClientId][aCallIndex];
+    if (!call || !call.isConference) {
+      // TODO: Bug 975949 - [B2G] Telephony should throw exceptions when some
+      // operations aren't allowed instead of simply ignoring them.
+      return;
+    }
+
+    let parentId = call.parentId;
+    if (parentId) {
+      this.separateCall(aClientId, parentId);
+      return;
+    }
+
+    function onCdmaSeparateCallSuccess() {
+      // See 3gpp2, S.R0006-522-A v1.0. Table 4, XID 6S.
+      let call = this._currentCalls[aClientId][aCallIndex];
+      if (!call || !call.isConference) {
+        return;
+      }
+
+      let childId = call.childId;
+      if (!childId) {
+        return;
+      }
+
+      let childCall = this._currentCalls[aClientId][childId];
+      this.notifyCallDisconnected(aClientId, childCall);
+    };
+
+    this._getClient(aClientId).sendWorkerMessage("separateCall", {
+      callIndex: aCallIndex
+    }, (function(response) {
+      if (!response.success) {
+        this._notifyAllListeners("notifyConferenceError", [response.errorName,
+                                                           response.errorMsg]);
+        return false;
+      }
+
+      if (response.isCdma) {
+        onCdmaSeparateCallSuccess.call(this);
+      }
+      return false;
+    }).bind(this));
   },
 
   holdConference: function(aClientId) {
     this._getClient(aClientId).sendWorkerMessage("holdConference");
   },
 
   resumeConference: function(aClientId) {
     this._getClient(aClientId).sendWorkerMessage("resumeConference");
@@ -535,30 +764,61 @@ TelephonyProvider.prototype = {
       duration: duration,
       direction: aCall.isOutgoing ? "outgoing" : "incoming"
     };
     gSystemMessenger.broadcastMessage("telephony-call-ended", data);
 
     aCall.clientId = aClientId;
     this._updateCallAudioState(aCall, null);
 
+    let manualConfStateChange = false;
+    let childId = this._currentCalls[aClientId][aCall.callIndex].childId;
+    if (childId) {
+      // Child cannot live without parent.
+      let childCall = this._currentCalls[aClientId][childId];
+      this.notifyCallDisconnected(aClientId, childCall);
+    } else {
+      let parentId = this._currentCalls[aClientId][aCall.callIndex].parentId;
+      if (parentId) {
+        let parentCall = this._currentCalls[aClientId][parentId];
+        // The child is going to be released.
+        delete parentCall.childId;
+        if (parentCall.isConference) {
+          // As the child is going to be gone, the parent should be moved out
+          // of conference accordingly.
+          manualConfStateChange = true;
+          parentCall.isConference = false;
+          parentCall.isSwitchable = true;
+          parentCall.isMergeable = true;
+          aCall.isConference = false;
+          this.notifyCallStateChanged(aClientId, parentCall, true);
+        }
+      }
+    }
+
     if (!aCall.failCause ||
         aCall.failCause === RIL.GECKO_CALL_ERROR_NORMAL_CALL_CLEARING) {
       this._notifyAllListeners("callStateChanged", [aClientId,
                                                     aCall.callIndex,
                                                     aCall.state,
                                                     aCall.number,
                                                     aCall.isActive,
                                                     aCall.isOutgoing,
                                                     aCall.isEmergency,
-                                                    aCall.isConference]);
-      return;
+                                                    aCall.isConference,
+                                                    aCall.isSwitchable,
+                                                    aCall.isMergeable]);
+    } else {
+      this.notifyCallError(aClientId, aCall.callIndex, aCall.failCause);
     }
+    delete this._currentCalls[aClientId][aCall.callIndex];
 
-    this.notifyCallError(aClientId, aCall.callIndex, aCall.failCause);
+    if (manualConfStateChange) {
+      this.notifyConferenceCallStateChanged(RIL.CALL_STATE_UNKNOWN);
+    }
   },
 
   /**
    * Handle call error.
    */
   notifyCallError: function(aClientId, aCallIndex, aErrorMsg) {
     this._notifyAllListeners("notifyError", [aClientId, aCallIndex, aErrorMsg]);
   },
@@ -576,42 +836,72 @@ TelephonyProvider.prototype = {
 
     gSystemMessenger.broadcastMessage("telephony-new-call", {});
   },
 
   /**
    * Handle call state changes by updating our current state and the audio
    * system.
    */
-  notifyCallStateChanged: function(aClientId, aCall) {
+  notifyCallStateChanged: function(aClientId, aCall, aSkipStateConversion) {
     if (DEBUG) debug("handleCallStateChange: " + JSON.stringify(aCall));
 
-    aCall.state = this._convertRILCallState(aCall.state);
+    if (!aSkipStateConversion) {
+      aCall.state = this._convertRILCallState(aCall.state);
+    }
+
     if (aCall.state == nsITelephonyProvider.CALL_STATE_DIALING) {
       gSystemMessenger.broadcastMessage("telephony-new-call", {});
     }
 
     aCall.clientId = aClientId;
     this._updateCallAudioState(aCall, null);
 
+    let call = this._currentCalls[aClientId][aCall.callIndex];
+    if (call) {
+      call.state = aCall.state;
+      call.isConference = aCall.isConference;
+      call.isEmergency = aCall.isEmergency;
+      call.isActive = aCall.isActive;
+      call.isSwitchable = aCall.isSwitchable != null ?
+                          aCall.isSwitchable : call.isSwitchable;
+      call.isMergeable = aCall.isMergeable != null ?
+                         aCall.isMergeable : call.isMergeable;
+    } else {
+      call = aCall;
+      call.isSwitchable = aCall.isSwitchable != null ?
+                          aCall.isSwitchable : true;
+      call.isMergeable = aCall.isMergeable != null ?
+                         aCall.isMergeable : true;
+      this._currentCalls[aClientId][aCall.callIndex] = call;
+    }
+
     this._notifyAllListeners("callStateChanged", [aClientId,
-                                                  aCall.callIndex,
-                                                  aCall.state,
-                                                  aCall.number,
-                                                  aCall.isActive,
-                                                  aCall.isOutgoing,
-                                                  aCall.isEmergency,
-                                                  aCall.isConference]);
+                                                  call.callIndex,
+                                                  call.state,
+                                                  call.number,
+                                                  call.isActive,
+                                                  call.isOutgoing,
+                                                  call.isEmergency,
+                                                  call.isConference,
+                                                  call.isSwitchable,
+                                                  call.isMergeable]);
   },
 
   notifyCdmaCallWaiting: function(aClientId, aNumber) {
     // We need to acquire a CPU wake lock to avoid the system falling into
     // the sleep mode when the RIL handles the incoming call.
     this._acquireCallRingWakeLock();
 
+    let call = this._currentCalls[aClientId][CDMA_SECOND_CALL_INDEX];
+    if (call) {
+      // TODO: Bug 977503 - B2G RIL: [CDMA] update callNumber when a waiting
+      // call comes after a 3way call.
+      this.notifyCallDisconnected(aClientId, call);
+    }
     this._notifyAllListeners("notifyCdmaCallWaiting", [aClientId, aNumber]);
   },
 
   notifySupplementaryService: function(aClientId, aCallIndex, aNotification) {
     let notification = this._convertRILSuppSvcNotification(aNotification);
     this._notifyAllListeners("supplementaryServiceNotification",
                              [aClientId, aCallIndex, notification]);
   },
@@ -619,32 +909,26 @@ TelephonyProvider.prototype = {
   notifyConferenceCallStateChanged: function(aState) {
     if (DEBUG) debug("handleConferenceCallStateChanged: " + aState);
     aState = this._convertRILCallState(aState);
     this._updateCallAudioState(null, aState);
 
     this._notifyAllListeners("conferenceCallStateChanged", [aState]);
   },
 
-  notifyConferenceError: function(aName, aMessage) {
-    if (DEBUG) debug("handleConferenceError: " + aName + "." +
-                     " Error details: " + aMessage);
-    this._notifyAllListeners("notifyConferenceError", [aName, aMessage]);
-  },
-
   /**
    * nsIObserver interface.
    */
 
   observe: function(aSubject, aTopic, aData) {
     switch (aTopic) {
       case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
         if (aData === kPrefRilDebuggingEnabled) {
           this._updateDebugFlag();
-	} else if (aData === kPrefDefaultServiceId) {
+        } else if (aData === kPrefDefaultServiceId) {
           this.defaultServiceId = this._getDefaultServiceId();
         }
         break;
 
       case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
         // Release the CPU wake lock for handling the incoming call.
         this._releaseCallRingWakeLock();
 
--- a/dom/telephony/ipc/TelephonyChild.cpp
+++ b/dom/telephony/ipc/TelephonyChild.cpp
@@ -55,17 +55,19 @@ TelephonyChild::RecvNotifyCallStateChang
 
   mListener->CallStateChanged(aClientId,
                               aData.callIndex(),
                               aData.callState(),
                               aData.number(),
                               aData.isActive(),
                               aData.isOutGoing(),
                               aData.isEmergency(),
-                              aData.isConference());
+                              aData.isConference(),
+                              aData.isSwitchable(),
+                              aData.isMergeable());
   return true;
 }
 
 bool
 TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId,
                                           const nsString& aNumber)
 {
   MOZ_ASSERT(mListener);
@@ -147,17 +149,19 @@ TelephonyRequestChild::RecvNotifyEnumera
 
   mListener->EnumerateCallState(aClientId,
                                 aData.callIndex(),
                                 aData.callState(),
                                 aData.number(),
                                 aData.isActive(),
                                 aData.isOutGoing(),
                                 aData.isEmergency(),
-                                aData.isConference());
+                                aData.isConference(),
+                                aData.isSwitchable(),
+                                aData.isMergeable());
   return true;
 }
 
 bool
 TelephonyRequestChild::RecvNotifyDialError(const nsString& aError)
 {
   MOZ_ASSERT(mCallback);
 
--- a/dom/telephony/ipc/TelephonyIPCProvider.cpp
+++ b/dom/telephony/ipc/TelephonyIPCProvider.cpp
@@ -253,22 +253,24 @@ TelephonyIPCProvider::SetSpeakerEnabled(
 NS_IMETHODIMP
 TelephonyIPCProvider::CallStateChanged(uint32_t aClientId,
                                        uint32_t aCallIndex,
                                        uint16_t aCallState,
                                        const nsAString& aNumber,
                                        bool aIsActive,
                                        bool aIsOutgoing,
                                        bool aIsEmergency,
-                                       bool aIsConference)
+                                       bool aIsConference,
+                                       bool aIsSwitchable,
+                                       bool aIsMergeable)
 {
   for (uint32_t i = 0; i < mListeners.Length(); i++) {
     mListeners[i]->CallStateChanged(aClientId, aCallIndex, aCallState, aNumber,
                                     aIsActive, aIsOutgoing, aIsEmergency,
-                                    aIsConference);
+                                    aIsConference, aIsSwitchable, aIsMergeable);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelephonyIPCProvider::ConferenceCallStateChanged(uint16_t aCallState)
 {
   for (uint32_t i = 0; i < mListeners.Length(); i++) {
@@ -286,17 +288,19 @@ TelephonyIPCProvider::EnumerateCallState
 NS_IMETHODIMP
 TelephonyIPCProvider::EnumerateCallState(uint32_t aClientId,
                                          uint32_t aCallIndex,
                                          uint16_t aCallState,
                                          const nsAString& aNumber,
                                          bool aIsActive,
                                          bool aIsOutgoing,
                                          bool aIsEmergency,
-                                         bool aIsConference)
+                                         bool aIsConference,
+                                         bool aIsSwitchable,
+                                         bool aIsMergeable)
 {
   MOZ_CRASH("Not a EnumerateCalls request!");
 }
 
 NS_IMETHODIMP
 TelephonyIPCProvider::NotifyCdmaCallWaiting(uint32_t aClientId,
                                             const nsAString& aNumber)
 {
--- a/dom/telephony/ipc/TelephonyParent.cpp
+++ b/dom/telephony/ipc/TelephonyParent.cpp
@@ -281,22 +281,25 @@ TelephonyParent::RecvSetSpeakerEnabled(c
 NS_IMETHODIMP
 TelephonyParent::CallStateChanged(uint32_t aClientId,
                                   uint32_t aCallIndex,
                                   uint16_t aCallState,
                                   const nsAString& aNumber,
                                   bool aIsActive,
                                   bool aIsOutgoing,
                                   bool aIsEmergency,
-                                  bool aIsConference)
+                                  bool aIsConference,
+                                  bool aIsSwitchable,
+                                  bool aIsMergeable)
 {
   NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
 
   IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber),
-                        aIsActive, aIsOutgoing, aIsEmergency, aIsConference);
+                        aIsActive, aIsOutgoing, aIsEmergency, aIsConference,
+                        aIsSwitchable, aIsMergeable);
   return SendNotifyCallStateChanged(aClientId, data) ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 TelephonyParent::ConferenceCallStateChanged(uint16_t aCallState)
 {
   NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
 
@@ -313,17 +316,19 @@ TelephonyParent::EnumerateCallStateCompl
 NS_IMETHODIMP
 TelephonyParent::EnumerateCallState(uint32_t aClientId,
                                     uint32_t aCallIndex,
                                     uint16_t aCallState,
                                     const nsAString& aNumber,
                                     bool aIsActive,
                                     bool aIsOutgoing,
                                     bool aIsEmergency,
-                                    bool aIsConference)
+                                    bool aIsConference,
+                                    bool aIsSwitchable,
+                                    bool aIsMergeable)
 {
   MOZ_CRASH("Not a EnumerateCalls request!");
 }
 
 NS_IMETHODIMP
 TelephonyParent::NotifyCdmaCallWaiting(uint32_t aClientId,
                                        const nsAString& aNumber)
 {
@@ -425,17 +430,19 @@ TelephonyRequestParent::DoRequest(const 
 NS_IMETHODIMP
 TelephonyRequestParent::CallStateChanged(uint32_t aClientId,
                                          uint32_t aCallIndex,
                                          uint16_t aCallState,
                                          const nsAString& aNumber,
                                          bool aIsActive,
                                          bool aIsOutgoing,
                                          bool aIsEmergency,
-                                         bool aIsConference)
+                                         bool aIsConference,
+                                         bool aIsSwitchable,
+                                         bool aIsMergeable)
 {
   MOZ_CRASH("Not a TelephonyParent!");
 }
 
 NS_IMETHODIMP
 TelephonyRequestParent::ConferenceCallStateChanged(uint16_t aCallState)
 {
   MOZ_CRASH("Not a TelephonyParent!");
@@ -452,22 +459,25 @@ TelephonyRequestParent::EnumerateCallSta
 NS_IMETHODIMP
 TelephonyRequestParent::EnumerateCallState(uint32_t aClientId,
                                            uint32_t aCallIndex,
                                            uint16_t aCallState,
                                            const nsAString& aNumber,
                                            bool aIsActive,
                                            bool aIsOutgoing,
                                            bool aIsEmergency,
-                                           bool aIsConference)
+                                           bool aIsConference,
+                                           bool aIsSwitchable,
+                                           bool aIsMergeable)
 {
   NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
 
   IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber),
-                        aIsActive, aIsOutgoing, aIsEmergency, aIsConference);
+                        aIsActive, aIsOutgoing, aIsEmergency, aIsConference,
+                        aIsSwitchable, aIsMergeable);
   return SendNotifyEnumerateCallState(aClientId, data) ? NS_OK
                                                        : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 TelephonyRequestParent::NotifyCdmaCallWaiting(uint32_t aClientId,
                                               const nsAString& aNumber)
 {
--- a/dom/telephony/ipc/TelephonyTypes.ipdlh
+++ b/dom/telephony/ipc/TelephonyTypes.ipdlh
@@ -12,13 +12,15 @@ struct IPCCallStateData
 {
   uint32_t callIndex;
   uint16_t callState;
   nsString number;
   bool     isActive;
   bool     isOutGoing;
   bool     isEmergency;
   bool     isConference;
+  bool     isSwitchable;
+  bool     isMergeable;
 };
 
 } /* namespace telephony */
 } /* namespace dom */
 } /* namespace mozilla */
--- a/dom/telephony/nsIGonkTelephonyProvider.idl
+++ b/dom/telephony/nsIGonkTelephonyProvider.idl
@@ -5,30 +5,28 @@
 
 #include "nsITelephonyProvider.idl"
 
 %{C++
 #define GONK_TELEPHONY_PROVIDER_CONTRACTID \
         "@mozilla.org/telephony/gonktelephonyprovider;1"
 %}
 
-[scriptable, uuid(2ff3dcbb-ae63-443e-9c5d-76811f2f9b42)]
+[scriptable, uuid(5fdd720f-fbe8-46f5-b671-3bf3360013dd)]
 interface nsIGonkTelephonyProvider : nsITelephonyProvider
 {
   void notifyCallDisconnected(in unsigned long clientId, in jsval call);
 
   void notifyCallError(in unsigned long clientId, in long callIndex,
                        in AString error);
 
   void notifyCallRing();
 
-  void notifyCallStateChanged(in unsigned long clientId, in jsval call);
+  void notifyCallStateChanged(in unsigned long clientId, in jsval call,
+                              [optional] in boolean skipStateConversion);
 
   void notifyCdmaCallWaiting(in unsigned long clientId, in AString number);
 
   void notifySupplementaryService(in unsigned long clientId, in long callIndex,
                                   in AString notification);
 
   void notifyConferenceCallStateChanged(in short state);
-
-  void notifyConferenceError(in AString errorName,
-                             in AString errorMsg);
 };
--- a/dom/telephony/nsITelephonyProvider.idl
+++ b/dom/telephony/nsITelephonyProvider.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 "nsISupports.idl"
 
-[scriptable, uuid(6385282b-4413-4cd6-b60a-de43e0b5c307)]
+[scriptable, uuid(c25d3993-6481-4e12-acee-55e32f6e1454)]
 interface nsITelephonyListener : nsISupports
 {
   /**
    * Notified when a telephony call changes state.
    *
    * @param clientId
             Indicate the RIL client, 0 ~ (number of client - 1).
    * @param callIndex
@@ -21,25 +21,33 @@ interface nsITelephonyListener : nsISupp
    * @param isActive
    *        Indicates whether this call is the currently active one.
    * @param isOutgoing
    *        Indicates whether this call is outgoing or incoming.
    * @param isEmergency
    *        Indicates whether this call is an emergency call.
    * @param isConference
    *        Indicates whether this call is a conference call.
+   * @param isSwitchable
+   *        Indicates whether this call can be switched between states of
+   *        nsITelephonyProvider::CALL_STATE_CONNECTED and
+   *        nsITelephonyProvider::CALL_STATE_HELD.
+   * @param isMergeable
+   *        Indicates whether this call be be added into a conference.
    */
   void callStateChanged(in unsigned long clientId,
                         in unsigned long callIndex,
                         in unsigned short callState,
                         in AString number,
                         in boolean isActive,
                         in boolean isOutgoing,
                         in boolean isEmergency,
-                        in boolean isConference);
+                        in boolean isConference,
+                        in boolean isSwitchable,
+                        in boolean isMergeable);
 
   /**
    * Called when participants of a conference call have been updated, and the
    * conference call state changes.
    *
    * @param callState
    *        Possible values are: nsITelephonyProvider::CALL_STATE_UNKNOWN,
    *        nsITelephonyProvider::CALL_STATE_HELD,
@@ -67,25 +75,33 @@ interface nsITelephonyListener : nsISupp
    * @param number
    *        Number of the other party.
    * @param isActive
    *        Indicates whether this call is the active one.
    * @param isOutgoing
    *        Indicates whether this call is outgoing or incoming.
    * @param isConference
    *        Indicates whether this call is a conference call.
+   * @param isSwitchable
+   *        Indicates whether this call can be switched between states of
+   *        nsITelephonyProvider::CALL_STATE_CONNECTED and
+   *        nsITelephonyProvider::CALL_STATE_HELD.
+   * @param isMergeable
+   *        Indicates whether this call be be added into a conference.
    */
   void enumerateCallState(in unsigned long clientId,
                           in unsigned long callIndex,
                           in unsigned short callState,
                           in AString number,
                           in boolean isActive,
                           in boolean isOutgoing,
                           in boolean isEmergency,
-                          in boolean isConference);
+                          in boolean isConference,
+                          in boolean isSwitchable,
+                          in boolean isMergeable);
 
   /**
    * Notify when RIL receives supplementary service notification.
    *
    * @param clientId
             Indicate the RIL client, 0 ~ (number of client - 1).
    * @param callIndex
    *        Call identifier assigned by the RIL. -1 if not specified
--- a/dom/webidl/AnalyserNode.webidl
+++ b/dom/webidl/AnalyserNode.webidl
@@ -7,21 +7,22 @@
  * https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 interface AnalyserNode : AudioNode {
 
-    // Real-time frequency-domain data 
+    // Real-time frequency-domain data
     void getFloatFrequencyData(Float32Array array);
     void getByteFrequencyData(Uint8Array array);
 
-    // Real-time waveform data 
+    // Real-time waveform data
+    void getFloatTimeDomainData(Float32Array array);
     void getByteTimeDomainData(Uint8Array array);
 
     [SetterThrows, Pure]
     attribute unsigned long fftSize;
     [Pure]
     readonly attribute unsigned long frequencyBinCount;
 
     [SetterThrows, Pure]
--- a/dom/webidl/Downloads.webidl
+++ b/dom/webidl/Downloads.webidl
@@ -41,20 +41,20 @@ interface DOMDownloadManager : EventTarg
   // Fires when a new download starts.
   attribute EventHandler ondownloadstart;
 };
 
 [JSImplementation="@mozilla.org/downloads/download;1",
  Func="Navigator::HasDownloadsSupport"]
 interface DOMDownload : EventTarget {
   // The full size of the resource.
-  readonly attribute long totalBytes;
+  readonly attribute long long totalBytes;
 
   // The number of bytes that we have currently downloaded.
-  readonly attribute long currentBytes;
+  readonly attribute long long currentBytes;
 
   // The url of the resource.
   readonly attribute DOMString url;
 
   // The path in local storage where the file will end up once the download
   // is complete.
   readonly attribute DOMString path;
 
--- a/dom/webidl/HTMLPropertiesCollection.webidl
+++ b/dom/webidl/HTMLPropertiesCollection.webidl
@@ -5,18 +5,16 @@
  *
  * The origin of this IDL file is
  * http://www.whatwg.org/specs/web-apps/current-work/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-interface DOMStringList;
-
 interface HTMLPropertiesCollection : HTMLCollection {
   // inherits length and item()
   getter PropertyNodeList? namedItem(DOMString name); // overrides inherited namedItem()
   readonly attribute DOMStringList names;
 };
 
 typedef sequence<any> PropertyValueArray;
 
--- a/dom/webidl/NetworkOptions.webidl
+++ b/dom/webidl/NetworkOptions.webidl
@@ -9,17 +9,17 @@ dictionary NetworkCommandOptions
 {
   long id = 0;                        // opaque id.
   DOMString cmd = "";                 // the command name.
   DOMString ifname;                   // for "removeNetworkRoute", "setDNS",
                                       //     "setDefaultRouteAndDNS", "removeDefaultRoute"
                                       //     "addHostRoute", "removeHostRoute"
                                       //     "removeHostRoutes".
   DOMString ip;                       // for "removeNetworkRoute", "setWifiTethering".
-  DOMString netmask;                  // for "removeNetworkRoute".
+  unsigned long prefixLength;         // for "removeNetworkRoute".
   DOMString domain;                   // for "setDNS"
   DOMString dns1_str;                 // for "setDNS", "setDefaultRouteAndDNS".
   DOMString dns2_str;                 // for "setDNS", "setDefaultRouteAndDNS".
   DOMString oldIfname;                // for "setDefaultRouteAndDNS".
   DOMString gateway_str;              // for "setDefaultRouteAndDNS".
   DOMString gateway;                  // for "addHostRoute", "removeHostRoute".
   sequence<DOMString> hostnames;      // for "addHostRoute", "removeHostRoute".
   DOMString mode;                     // for "setWifiOperationMode".
--- a/dom/webidl/TelephonyCall.webidl
+++ b/dom/webidl/TelephonyCall.webidl
@@ -17,16 +17,23 @@ interface TelephonyCall : EventTarget {
 
   readonly attribute DOMString state;
 
   // The property "emergency" indicates whether the call number is an emergency
   // number. Only the outgoing call could have a value with true and it is
   // available after dialing state.
   readonly attribute boolean emergency;
 
+  // Indicate whether the call state can be switched between "connected" and
+  // "held".
+  readonly attribute boolean switchable;
+
+  // Indicate whether the call can be added into TelephonyCallGroup.
+  readonly attribute boolean mergeable;
+
   readonly attribute DOMError? error;
 
   readonly attribute TelephonyCallGroup? group;
 
   [Throws]
   void answer();
   [Throws]
   void hangUp();
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -80,16 +80,17 @@ WEBIDL_FILES = [
     'DOMException.webidl',
     'DOMImplementation.webidl',
     'DOMMMIError.webidl',
     'DOMParser.webidl',
     'DOMRect.webidl',
     'DOMRectList.webidl',
     'DOMRequest.webidl',
     'DOMSettableTokenList.webidl',
+    'DOMStringList.webidl',
     'DOMStringMap.webidl',
     'DOMTokenList.webidl',
     'DOMTransaction.webidl',
     'Downloads.webidl',
     'DragEvent.webidl',
     'DummyBinding.webidl',
     'DynamicsCompressorNode.webidl',
     'Element.webidl',
--- a/dom/wifi/WifiP2pManager.jsm
+++ b/dom/wifi/WifiP2pManager.jsm
@@ -87,18 +87,17 @@ const P2P_INTERFACE_NAME = "p2p0";
 const DEFAULT_GO_INTENT = 15;
 const DEFAULT_P2P_DEVICE_NAME = "FirefoxPhone";
 const P2P_SCAN_TIMEOUT_SEC = 120;
 const DEFAULT_P2P_WPS_METHODS = "virtual_push_button physical_display keypad"; // For wpa_supplicant.
 const DEFAULT_P2P_DEVICE_TYPE = "10-0050F204-5"; // For wpa_supplicant.
 
 const GO_NETWORK_INTERFACE = {
   ip:         "192.168.2.1",
-  netmask:    "255.255.255.0", // Should be consistent with |maskLenth|.
-  maskLength: 24,              // Should be consistent with |netmask|.
+  maskLength: 24,
   broadcast:  "192.168.2.255",
   gateway:    "192.168.2.1",
   dns1:       "0.0.0.0",
   dns2:       "0.0.0.0",
   dhcpServer: "192.168.2.1"
 };
 
 const GO_DHCP_SERVER_IP_RANGE = {
@@ -489,17 +488,17 @@ function P2pStateMachine(aP2pCommand, aN
 
   let _p2pNetworkInterface = {
     QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface]),
 
     state: Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED,
     type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI_P2P,
     name: P2P_INTERFACE_NAME,
     ip: null,
-    netmask: null,
+    prefixLength: 0,
     broadcast: null,
     dns1: null,
     dns2: null,
     gateway: null,
     httpProxyHost: null,
     httpProxyPort: null,
 
     // help
@@ -1375,17 +1374,17 @@ function P2pStateMachine(aP2pCommand, aN
           debug('Failed to start DHCP server');
           onFailure();
           return;
         }
 
         // Update p2p network interface.
         _p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
         _p2pNetworkInterface.ip = GO_NETWORK_INTERFACE.ip;
-        _p2pNetworkInterface.netmask = GO_NETWORK_INTERFACE.netmask;
+        _p2pNetworkInterface.prefixLength = GO_NETWORK_INTERFACE.maskLength;
         _p2pNetworkInterface.gateway = GO_NETWORK_INTERFACE.ip;
         handleP2pNetworkInterfaceStateChanged();
 
         _groupInfo.networkInterface = _p2pNetworkInterface;
 
         debug('Everything is done. Happy p2p GO~');
         onSuccess();
       });
@@ -1403,36 +1402,38 @@ function P2pStateMachine(aP2pCommand, aN
         onFailure();
         return;
       }
 
       // Save network interface.
       debug("DHCP request success: " + JSON.stringify(dhcpData.info));
 
       // Update p2p network interface.
+      let maskLength =
+        netHelpers.getMaskLength(netHelpers.stringToIP(dhcpData.info.mask_str));
       _p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
       _p2pNetworkInterface.ip = dhcpData.info.ipaddr_str;
-      _p2pNetworkInterface.netmask = dhcpData.info.mask_str;
+      _p2pNetworkInterface.prefixLength = maskLength;
       _p2pNetworkInterface.broadcast = dhcpData.info.broadcast_str;
       _p2pNetworkInterface.dns1 = dhcpData.info.dns1_str;
       _p2pNetworkInterface.dns2 = dhcpData.info.dns2_str;
       _p2pNetworkInterface.gateway = dhcpData.info.gateway_str;
       handleP2pNetworkInterfaceStateChanged();
 
       _groupInfo.networkInterface = _p2pNetworkInterface;
 
       debug('Happy p2p client~');
       onSuccess();
     });
   }
 
   function resetP2pNetworkInterface() {
     _p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
     _p2pNetworkInterface.ip = null;
-    _p2pNetworkInterface.netmask = null;
+    _p2pNetworkInterface.prefixLength = 0;
     _p2pNetworkInterface.broadcast = null;
     _p2pNetworkInterface.dns1 = null;
     _p2pNetworkInterface.dns2 = null;
     _p2pNetworkInterface.gateway = null;
   }
 
   function registerP2pNetworkInteface() {
     if (!_p2pNetworkInterface.registered) {
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -1516,17 +1516,17 @@ let WifiNetworkInterface = {
   NETWORK_TYPE_MOBILE_SUPL: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL,
 
   type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
 
   name: null,
 
   ip: null,
 
-  netmask: null,
+  prefixLength: 0,
 
   broadcast: null,
 
   dns1: null,
 
   dns2: null,
 
   httpProxyHost: null,
@@ -1927,17 +1927,17 @@ function WifiWorker() {
             self._reconnectOnDisconnect = false;
             WifiManager.reconnect(function(){});
           }
         });
 
         WifiNetworkInterface.state =
           Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
         WifiNetworkInterface.ip = null;
-        WifiNetworkInterface.netmask = null;
+        WifiNetworkInterface.prefixLength = 0;
         WifiNetworkInterface.broadcast = null;
         WifiNetworkInterface.gateway = null;
         WifiNetworkInterface.dns1 = null;
         WifiNetworkInterface.dns2 = null;
         Services.obs.notifyObservers(WifiNetworkInterface,
                                      kNetworkInterfaceStateChangedTopic,
                                      null);
 
@@ -1961,20 +1961,22 @@ function WifiWorker() {
   };
 
   WifiManager.onnetworkconnected = function() {
     if (!this.info) {
       debug("Network information is invalid.");
       return;
     }
 
+    let maskLength =
+      netHelpers.getMaskLength(netHelpers.stringToIP(this.info.mask_str));
     WifiNetworkInterface.state =
       Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
     WifiNetworkInterface.ip = this.info.ipaddr_str;
-    WifiNetworkInterface.netmask = this.info.mask_str;
+    WifiNetworkInterface.prefixLength = maskLength;
     WifiNetworkInterface.broadcast = this.info.broadcast_str;
     WifiNetworkInterface.gateway = this.info.gateway_str;
     WifiNetworkInterface.dns1 = this.info.dns1_str;
     WifiNetworkInterface.dns2 = this.info.dns2_str;
     Services.obs.notifyObservers(WifiNetworkInterface,
                                  kNetworkInterfaceStateChangedTopic,
                                  null);
 
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -38,26 +38,26 @@
 #include "mozilla/Likely.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/ErrorEvent.h"
 #include "mozilla/dom/ErrorEventBinding.h"
 #include "mozilla/dom/Exceptions.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "mozilla/dom/ImageData.h"
 #include "mozilla/dom/ImageDataBinding.h"
+#include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePortList.h"
 #include "mozilla/dom/WorkerBinding.h"
 #include "mozilla/Preferences.h"
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
 #include "nsError.h"
 #include "nsEventDispatcher.h"
-#include "nsDOMMessageEvent.h"
 #include "nsDOMJSUtils.h"
 #include "nsHostObjectProtocolHandler.h"
 #include "nsJSEnvironment.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 #include "nsProxyRelease.h"
 #include "nsSandboxFlags.h"
@@ -976,18 +976,17 @@ public:
 
     JS::Rooted<JS::Value> messageData(aCx);
     if (!mBuffer.read(aCx, &messageData,
                       workers::WorkerStructuredCloneCallbacks(aIsMainThread))) {
       xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR);
       return false;
     }
 
-    nsRefPtr<nsDOMMessageEvent> event =
-      new nsDOMMessageEvent(aTarget, nullptr, nullptr);
+    nsRefPtr<MessageEvent> event = new MessageEvent(aTarget, nullptr, nullptr);
     nsresult rv =
       event->InitMessageEvent(NS_LITERAL_STRING("message"),
                               false /* non-bubbling */,
                               true /* cancelable */,
                               messageData,
                               EmptyString(),
                               EmptyString(),
                               nullptr);
@@ -2788,19 +2787,17 @@ WorkerPrivateParent<Derived>::DispatchMe
 
   JS::Rooted<JS::Value> data(cx);
   if (!buffer.read(cx, &data, WorkerStructuredCloneCallbacks(true))) {
     return false;
   }
 
   buffer.clear();
 
-  nsRefPtr<nsDOMMessageEvent> event =
-    new nsDOMMessageEvent(port, nullptr, nullptr);
-
+  nsRefPtr<MessageEvent> event = new MessageEvent(port, nullptr, nullptr);
   nsresult rv =
     event->InitMessageEvent(NS_LITERAL_STRING("message"), false, false, data,
                             EmptyString(), EmptyString(), nullptr);
   if (NS_FAILED(rv)) {
     xpc::Throw(cx, rv);
     return false;
   }
 
@@ -5733,19 +5730,19 @@ WorkerPrivate::ConnectMessagePort(JSCont
 
   RootedDictionary<MessageEventInit> init(aCx);
   init.mBubbles = false;
   init.mCancelable = false;
   init.mSource.SetValue().SetAsMessagePort() = port;
 
   ErrorResult rv;
 
-  nsRefPtr<nsDOMMessageEvent> event =
-    nsDOMMessageEvent::Constructor(globalObject, aCx,
-                                   NS_LITERAL_STRING("connect"), init, rv);
+  nsRefPtr<MessageEvent> event =
+    MessageEvent::Constructor(globalObject, aCx,
+                              NS_LITERAL_STRING("connect"), init, rv);
 
   event->SetTrusted(true);
 
   nsTArray<nsRefPtr<MessagePortBase>> ports;
   ports.AppendElement(port);
 
   nsRefPtr<MessagePortList> portList =
     new MessagePortList(static_cast<nsIDOMEventTarget*>(globalScope), ports);
--- a/dom/xslt/base/txDouble.cpp
+++ b/dom/xslt/base/txDouble.cpp
@@ -100,17 +100,17 @@ public:
         }
     }
 
     double
     getDouble()
     {
         if (mState == eIllegal || mBuffer.IsEmpty() ||
             (mBuffer.Length() == 1 && mBuffer[0] == '.')) {
-            return mozilla::UnspecifiedNaN();
+            return mozilla::UnspecifiedNaN<double>();
         }
         return mSign*PR_strtod(mBuffer.get(), 0);
     }
 private:
     nsAutoCString mBuffer;
     enum {
         eWhitestart,
         eDecimal,
--- a/dom/xslt/xpath/txNumberExpr.cpp
+++ b/dom/xslt/xpath/txNumberExpr.cpp
@@ -35,33 +35,33 @@ txNumberExpr::evaluate(txIEvalContext* a
             result = leftDbl - rightDbl;
             break;
 
         case DIVIDE:
             if (rightDbl == 0) {
<