Merge mozilla-central to fx-team
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 30 Jun 2014 15:49:06 +0200
changeset 191553 34762d090431fa7082f69b3a42f3984c7780e9e8
parent 191552 1384e5d7b1f36cb19dd8e808be881e1ca422c9d1 (current diff)
parent 191468 3b46de297f3f5a3beda7df16c4cf8c511b4d99e9 (diff)
child 191554 2b89f72bc855d709fcfc6509966a52e3e16bdace
push id45618
push userkwierso@gmail.com
push dateTue, 01 Jul 2014 01:47:43 +0000
treeherdermozilla-inbound@d0787b1eebc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-central to fx-team
layout/reftests/font-inflation/disable-fontinfl-on-mobile-4.html
--- a/b2g/config/emulator-ics/sources.xml
+++ b/b2g/config/emulator-ics/sources.xml
@@ -14,17 +14,17 @@
   <!--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="2a165bebfa19b11b697837409f9550dd2917c46c">
     <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="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="3326b51017252e09ccdd715dec6c5e12a7d1ecfe"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
--- a/b2g/config/emulator-jb/sources.xml
+++ b/b2g/config/emulator-jb/sources.xml
@@ -12,17 +12,17 @@
   <!--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="cc67f31dc638c0b7edba3cf7e3d87cadf0ed52bf">
     <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="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- 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"/>
--- a/b2g/config/emulator-kk/sources.xml
+++ b/b2g/config/emulator-kk/sources.xml
@@ -10,17 +10,17 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--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="276ce45e78b09c4a4ee643646f691d22804754c1">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
--- a/b2g/config/emulator/sources.xml
+++ b/b2g/config/emulator/sources.xml
@@ -14,17 +14,17 @@
   <!--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="2a165bebfa19b11b697837409f9550dd2917c46c">
     <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="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="3326b51017252e09ccdd715dec6c5e12a7d1ecfe"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
--- a/b2g/config/flame/sources.xml
+++ b/b2g/config/flame/sources.xml
@@ -12,17 +12,17 @@
   <!--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="cc67f31dc638c0b7edba3cf7e3d87cadf0ed52bf">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="e95b4ce22c825da44d14299e1190ea39a5260bde"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="471afab478649078ad7c75ec6b252481a59e19b8"/>
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,9 +1,9 @@
 {
     "git": {
         "git_revision": "", 
         "remote": "", 
         "branch": ""
     }, 
-    "revision": "b6c6dcfdef46399b88637c93a4f76d4425f7c096", 
+    "revision": "2c2f2fa0a101f07cbb206cca2e69ef3a7b18244c", 
     "repo_path": "/integration/gaia-central"
 }
--- a/b2g/config/hamachi/sources.xml
+++ b/b2g/config/hamachi/sources.xml
@@ -12,17 +12,17 @@
   <!--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="2a165bebfa19b11b697837409f9550dd2917c46c">
     <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="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>
--- 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="2a165bebfa19b11b697837409f9550dd2917c46c">
     <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="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <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/nexus-4/sources.xml
+++ b/b2g/config/nexus-4/sources.xml
@@ -12,17 +12,17 @@
   <!--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="cc67f31dc638c0b7edba3cf7e3d87cadf0ed52bf">
     <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="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- 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"/>
--- a/b2g/config/wasabi/sources.xml
+++ b/b2g/config/wasabi/sources.xml
@@ -12,17 +12,17 @@
   <!--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="2a165bebfa19b11b697837409f9550dd2917c46c">
     <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="de14e61098b742251b34f856e48649db8bed552c"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="bc3bbf42d2a606f6b7038881cff5ec3795fdf953"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="bbb7659d8ea2afb396f99b3dc971ab3c42da3778"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="c510babaf88dfa2cfe2c202afb2649ee124569af"/>
   <project name="apitrace" path="external/apitrace" remote="apitrace" revision="7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f"/>
   <project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -2238,41 +2238,20 @@ nsresult MediaDecoderStateMachine::RunSt
   NS_ENSURE_TRUE(resource, NS_ERROR_NULL_POINTER);
 
   switch (mState) {
     case DECODER_STATE_SHUTDOWN: {
       if (IsPlaying()) {
         StopPlayback();
       }
 
-      // Put a task in the decode queue to abort any decoding operations.
-      // The reader is not supposed to put any tasks to deliver samples into
-      // the queue after we call this (unless we request another sample from it).
-      RefPtr<nsIRunnable> task;
-      task = NS_NewRunnableMethod(mReader, &MediaDecoderReader::ResetDecode);
-      mDecodeTaskQueue->Dispatch(task);
-
-      {
-        // Wait for the thread decoding to abort decoding operations and run
-        // any pending callbacks. This is important, as we don't want any
-        // pending tasks posted to the task queue by the reader to deliver
-        // any samples after we've posted the reader Shutdown() task below,
-        // as the sample-delivery tasks will keep video frames alive until
-        // after we've called Reader::Shutdown(), and shutdown on B2G will
-        // fail as there are outstanding video frames alive.
-        ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
-        mDecodeTaskQueue->Flush();
-      }
-
-      // We must reset playback so that all references to frames queued
-      // in the state machine are dropped, else the Shutdown() call below
-      // can fail on B2G.
-      ResetPlayback();
+      FlushDecoding();
 
       // Put a task in the decode queue to shutdown the reader.
+      RefPtr<nsIRunnable> task;
       task = NS_NewRunnableMethod(mReader, &MediaDecoderReader::Shutdown);
       mDecodeTaskQueue->Dispatch(task);
 
       StopAudioThread();
       // If mAudioSink is non-null after StopAudioThread completes, we are
       // running in a nested event loop waiting for Shutdown() on
       // mAudioSink to complete.  Return to the event loop and let it
       // finish processing before continuing with shutdown.
@@ -2320,16 +2299,17 @@ nsresult MediaDecoderStateMachine::RunSt
       mTimer = nullptr;
       return NS_OK;
     }
 
     case DECODER_STATE_DORMANT: {
       if (IsPlaying()) {
         StopPlayback();
       }
+      FlushDecoding();
       StopAudioThread();
       // Now that those threads are stopped, there's no possibility of
       // mPendingWakeDecoder being needed again. Revoke it.
       mPendingWakeDecoder = nullptr;
       {
         ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
         // Wait for the thread decoding, if any, to exit.
         mDecodeTaskQueue->AwaitIdle();
@@ -2462,16 +2442,48 @@ nsresult MediaDecoderStateMachine::RunSt
       }
       return NS_OK;
     }
   }
 
   return NS_OK;
 }
 
+void
+MediaDecoderStateMachine::FlushDecoding()
+{
+  NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
+               "Should be on state machine or decode thread.");
+  mDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn();
+
+  // Put a task in the decode queue to abort any decoding operations.
+  // The reader is not supposed to put any tasks to deliver samples into
+  // the queue after we call this (unless we request another sample from it).
+  RefPtr<nsIRunnable> task;
+  task = NS_NewRunnableMethod(mReader, &MediaDecoderReader::ResetDecode);
+  mDecodeTaskQueue->Dispatch(task);
+
+  {
+    // Wait for the thread decoding to abort decoding operations and run
+    // any pending callbacks. This is important, as we don't want any
+    // pending tasks posted to the task queue by the reader to deliver
+    // any samples after we've posted the reader Shutdown() task below,
+    // as the sample-delivery tasks will keep video frames alive until
+    // after we've called Reader::Shutdown(), and shutdown on B2G will
+    // fail as there are outstanding video frames alive.
+    ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
+    mDecodeTaskQueue->Flush();
+  }
+
+  // We must reset playback so that all references to frames queued
+  // in the state machine are dropped, else subsequent calls to Shutdown()
+  // or ReleaseMediaResources() can fail on B2G.
+  ResetPlayback();
+}
+
 void MediaDecoderStateMachine::RenderVideoFrame(VideoData* aData,
                                                 TimeStamp aTarget)
 {
   NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
                "Should be on state machine or decode thread.");
   mDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn();
 
   if (aData->mDuplicate) {
--- a/content/media/MediaDecoderStateMachine.h
+++ b/content/media/MediaDecoderStateMachine.h
@@ -440,16 +440,21 @@ protected:
   bool JustExitedQuickBuffering();
 
   // Dispatches an asynchronous event to update the media element's ready state.
   void UpdateReadyState();
 
   // Resets playback timing data. Called when we seek, on the decode thread.
   void ResetPlayback();
 
+  // Orders the Reader to stop decoding, and blocks until the Reader
+  // has stopped decoding and finished delivering samples, then calls
+  // ResetPlayback() to discard all enqueued data. 
+  void FlushDecoding();
+
   // Returns the audio clock, if we have audio, or -1 if we don't.
   // Called on the state machine thread.
   int64_t GetAudioClock();
 
   // Get the video stream position, taking the |playbackRate| change into
   // account. This is a position in the media, not the duration of the playback
   // so far.
   int64_t GetVideoStreamPosition();
--- a/content/media/gmp/GMPParent.cpp
+++ b/content/media/gmp/GMPParent.cpp
@@ -415,10 +415,31 @@ GMPParent::ReadGMPMetaData()
 
   if (mCapabilities.IsEmpty()) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
+bool
+GMPParent::CanBeSharedCrossOrigin() const
+{
+  return mOrigin.IsEmpty();
+}
+
+bool
+GMPParent::CanBeUsedFrom(const nsAString& aOrigin) const
+{
+  return (mOrigin.IsEmpty() && State() == GMPStateNotLoaded) ||
+         mOrigin.Equals(aOrigin);
+}
+
+void
+GMPParent::SetOrigin(const nsAString& aOrigin)
+{
+  MOZ_ASSERT(!aOrigin.IsEmpty());
+  MOZ_ASSERT(CanBeUsedFrom(aOrigin));
+  mOrigin = aOrigin;
+}
+
 } // namespace gmp
 } // namespace mozilla
--- a/content/media/gmp/GMPParent.h
+++ b/content/media/gmp/GMPParent.h
@@ -51,16 +51,37 @@ public:
   void VideoDecoderDestroyed(GMPVideoDecoderParent* aDecoder);
   nsresult GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE);
   void VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder);
   GMPState State() const;
 #ifdef DEBUG
   nsIThread* GMPThread();
 #endif
 
+  // A GMP can either be a single instance shared across all origins (like
+  // in the OpenH264 case), or we can require a new plugin instance for every
+  // origin running the plugin (as in the EME plugin case).
+  //
+  // Plugins are associated with an origin by calling SetOrigin() before
+  // loading.
+  //
+  // If a plugin has no origin specified and it is loaded, it is assumed to
+  // be shared across origins.
+
+  // Specifies that a GMP can only work with the specified origin.
+  void SetOrigin(const nsAString& aOrigin);
+
+  // Returns true if a plugin can be or is being used across multiple origins.
+  bool CanBeSharedCrossOrigin() const;
+
+  // A GMP can be used from an origin if it's already been set to work with
+  // that origin, or if it's not been set to work with any origin and has
+  // not yet been loaded (i.e. it's not shared across origins).
+  bool CanBeUsedFrom(const nsAString& aOrigin) const;
+
 private:
   ~GMPParent();
   bool EnsureProcessLoaded();
   nsresult ReadGMPMetaData();
   virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   virtual PGMPVideoDecoderParent* AllocPGMPVideoDecoderParent() MOZ_OVERRIDE;
   virtual bool DeallocPGMPVideoDecoderParent(PGMPVideoDecoderParent* aActor) MOZ_OVERRIDE;
   virtual PGMPVideoEncoderParent* AllocPGMPVideoEncoderParent() MOZ_OVERRIDE;
@@ -75,14 +96,17 @@ private:
   nsTArray<nsAutoPtr<GMPCapability>> mCapabilities;
   GMPProcessParent* mProcess;
 
   nsTArray<nsRefPtr<GMPVideoDecoderParent>> mVideoDecoders;
   nsTArray<nsRefPtr<GMPVideoEncoderParent>> mVideoEncoders;
 #ifdef DEBUG
   nsCOMPtr<nsIThread> mGMPThread;
 #endif
+  // Origin the plugin is assigned to, or empty if the the plugin is not
+  // assigned to an origin.
+  nsAutoString mOrigin;
 };
 
 } // namespace gmp
 } // namespace mozilla
 
 #endif // GMPParent_h_
--- a/content/media/gmp/GMPService.cpp
+++ b/content/media/gmp/GMPService.cpp
@@ -186,26 +186,33 @@ GeckoMediaPluginService::GetThread(nsITh
 
   NS_ADDREF(mGMPThread);
   *aThread = mGMPThread;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-GeckoMediaPluginService::GetGMPVideoDecoderVP8(GMPVideoHost** aOutVideoHost, GMPVideoDecoder** aGMPVD)
+GeckoMediaPluginService::GetGMPVideoDecoder(nsTArray<nsCString>* aTags,
+                                            const nsAString& aOrigin,
+                                            GMPVideoHost** aOutVideoHost,
+                                            GMPVideoDecoder** aGMPVD)
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
+  NS_ENSURE_ARG(aTags && aTags->Length() > 0);
+  NS_ENSURE_ARG(aOutVideoHost);
+  NS_ENSURE_ARG(aGMPVD);
 
   if (mShuttingDownOnGMPThread) {
     return NS_ERROR_FAILURE;
   }
 
-  nsRefPtr<GMPParent> gmp = SelectPluginForAPI(NS_LITERAL_CSTRING("decode-video"),
-                                               NS_LITERAL_CSTRING("vp8"));
+  nsRefPtr<GMPParent> gmp = SelectPluginForAPI(aOrigin,
+                                               NS_LITERAL_CSTRING("decode-video"),
+                                               *aTags);
   if (!gmp) {
     return NS_ERROR_FAILURE;
   }
 
   GMPVideoDecoderParent* gmpVDP;
   nsresult rv = gmp->GetGMPVideoDecoder(&gmpVDP);
   if (NS_FAILED(rv)) {
     return rv;
@@ -213,26 +220,33 @@ GeckoMediaPluginService::GetGMPVideoDeco
 
   *aGMPVD = gmpVDP;
   *aOutVideoHost = &gmpVDP->Host();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-GeckoMediaPluginService::GetGMPVideoEncoderVP8(GMPVideoHost** aOutVideoHost, GMPVideoEncoder** aGMPVE)
+GeckoMediaPluginService::GetGMPVideoEncoder(nsTArray<nsCString>* aTags,
+                                            const nsAString& aOrigin,
+                                            GMPVideoHost** aOutVideoHost,
+                                            GMPVideoEncoder** aGMPVE)
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
+  NS_ENSURE_ARG(aTags && aTags->Length() > 0);
+  NS_ENSURE_ARG(aOutVideoHost);
+  NS_ENSURE_ARG(aGMPVE);
 
   if (mShuttingDownOnGMPThread) {
     return NS_ERROR_FAILURE;
   }
 
-  nsRefPtr<GMPParent> gmp = SelectPluginForAPI(NS_LITERAL_CSTRING("encode-video"),
-                                               NS_LITERAL_CSTRING("vp8"));
+  nsRefPtr<GMPParent> gmp = SelectPluginForAPI(aOrigin,
+                                               NS_LITERAL_CSTRING("encode-video"),
+                                               *aTags);
   if (!gmp) {
     return NS_ERROR_FAILURE;
   }
 
   GMPVideoEncoderParent* gmpVEP;
   nsresult rv = gmp->GetGMPVideoEncoder(&gmpVEP);
   if (NS_FAILED(rv)) {
     return rv;
@@ -254,40 +268,60 @@ GeckoMediaPluginService::UnloadPlugins()
 
   for (uint32_t i = 0; i < mPlugins.Length(); i++) {
     mPlugins[i]->UnloadProcess();
   }
   mPlugins.Clear();
 }
 
 GMPParent*
-GeckoMediaPluginService::SelectPluginForAPI(const nsCString& aAPI,
-                                            const nsCString& aTag)
+GeckoMediaPluginService::SelectPluginForAPI(const nsAString& aOrigin,
+                                            const nsCString& aAPI,
+                                            const nsTArray<nsCString>& aTags)
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
 
-  GMPParent* gmp = SelectPluginFromListForAPI(aAPI, aTag);
+  GMPParent* gmp = SelectPluginFromListForAPI(aOrigin, aAPI, aTags);
   if (gmp) {
     return gmp;
   }
 
   RefreshPluginList();
 
-  return SelectPluginFromListForAPI(aAPI, aTag);
+  return SelectPluginFromListForAPI(aOrigin, aAPI, aTags);
 }
 
 GMPParent*
-GeckoMediaPluginService::SelectPluginFromListForAPI(const nsCString& aAPI,
-                                                    const nsCString& aTag)
+GeckoMediaPluginService::SelectPluginFromListForAPI(const nsAString& aOrigin,
+                                                    const nsCString& aAPI,
+                                                    const nsTArray<nsCString>& aTags)
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
 
   for (uint32_t i = 0; i < mPlugins.Length(); i++) {
     GMPParent* gmp = mPlugins[i];
-    if (gmp->SupportsAPI(aAPI, aTag)) {
+    bool supportsAllTags = true;
+    for (uint32_t t = 0; t < aTags.Length(); t++) {
+      const nsCString& tag = aTags[t];
+      if (!gmp->SupportsAPI(aAPI, tag)) {
+        supportsAllTags = false;
+        break;
+      }
+    }
+    if (!supportsAllTags) {
+      continue;
+    }
+    if (aOrigin.IsEmpty()) {
+      if (gmp->CanBeSharedCrossOrigin()) {
+        return gmp;
+      }
+    } else if (gmp->CanBeUsedFrom(aOrigin)) {
+      if (!aOrigin.IsEmpty()) {
+        gmp->SetOrigin(aOrigin);
+      }
       return gmp;
     }
   }
   return nullptr;
 }
 
 nsresult
 GeckoMediaPluginService::GetDirectoriesToSearch(nsTArray<nsCOMPtr<nsIFile>> &aDirs)
--- a/content/media/gmp/GMPService.h
+++ b/content/media/gmp/GMPService.h
@@ -33,18 +33,22 @@ public:
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_MOZIGECKOMEDIAPLUGINSERVICE
   NS_DECL_NSIOBSERVER
 
 private:
   ~GeckoMediaPluginService();
 
-  GMPParent* SelectPluginFromListForAPI(const nsCString& aAPI, const nsCString& aTag);
-  GMPParent* SelectPluginForAPI(const nsCString& aAPI, const nsCString& aTag);
+  GMPParent* SelectPluginFromListForAPI(const nsAString& aOrigin,
+                                        const nsCString& aAPI,
+                                        const nsTArray<nsCString>& aTags);
+  GMPParent* SelectPluginForAPI(const nsAString& aOrigin,
+                                const nsCString& aAPI,
+                                const nsTArray<nsCString>& aTags);
   void UnloadPlugins();
 
   void RefreshPluginList();
   void ProcessPossiblePlugin(nsIFile* aDir);
   nsresult SearchDirectory(nsIFile* aSearchDir);
   nsresult GetPossiblePlugins(nsTArray<nsCOMPtr<nsIFile>>& aDirs);
   nsresult GetDirectoriesToSearch(nsTArray<nsCOMPtr<nsIFile>>& aDirs);
 
--- a/content/media/gmp/GMPVideoHost.cpp
+++ b/content/media/gmp/GMPVideoHost.cpp
@@ -91,17 +91,17 @@ GMPVideoHostImpl::ActorDestroyed()
   for (uint32_t i = mPlanes.Length(); i > 0; i--) {
     mPlanes[i - 1]->ActorDestroyed();
     mPlanes.RemoveElementAt(i - 1);
   }
   for (uint32_t i = mEncodedFrames.Length(); i > 0; i--) {
     mEncodedFrames[i - 1]->ActorDestroyed();
     mEncodedFrames.RemoveElementAt(i - 1);
   }
-  mSharedMemMgr = nullptr;  
+  mSharedMemMgr = nullptr;
 }
 
 void
 GMPVideoHostImpl::PlaneCreated(GMPPlaneImpl* aPlane)
 {
   mPlanes.AppendElement(aPlane);
 }
 
--- a/content/media/gmp/mozIGeckoMediaPluginService.idl
+++ b/content/media/gmp/mozIGeckoMediaPluginService.idl
@@ -1,34 +1,46 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsIThread.idl"
+#include "nsIPrincipal.idl"
 
 %{C++
+#include "nsTArray.h"
+#include "nsStringGlue.h"
 class GMPVideoDecoder;
 class GMPVideoEncoder;
 class GMPVideoHost;
 %}
 
 [ptr] native GMPVideoDecoder(GMPVideoDecoder);
 [ptr] native GMPVideoEncoder(GMPVideoEncoder);
 [ptr] native GMPVideoHost(GMPVideoHost);
 [ptr] native MessageLoop(MessageLoop);
+[ptr] native TagArray(nsTArray<nsCString>);
 
 [uuid(BF5A9086-70F5-4D38-832D-1609BBF963CD)]
 interface mozIGeckoMediaPluginService : nsISupports
 {
   // Returns the GMP thread.
   // Callable from any thread.
   readonly attribute nsIThread thread;
 
-  // Returns a video decoder API object that should support VP8.
+  // Returns a video decoder that supports the specified tags.
+  // The array of tags should at least contain a codec tag, and optionally
+  // other tags such as for EME keysystem.
   // Callable only on GMP thread.
-  GMPVideoDecoder getGMPVideoDecoderVP8(out GMPVideoHost outVideoHost);
+  GMPVideoDecoder getGMPVideoDecoder(in TagArray tags,
+                                     [optional] in AString origin,
+                                     out GMPVideoHost outVideoHost);
 
-  // Returns a video encoder API object that should support VP8.
+  // Returns a video encoder that supports the specified tags.
+  // The array of tags should at least contain a codec tag, and optionally
+  // other tags.
   // Callable only on GMP thread.
-  GMPVideoEncoder getGMPVideoEncoderVP8(out GMPVideoHost outVideoHost);
+  GMPVideoEncoder getGMPVideoEncoder(in TagArray tags,
+                                     [optional] in AString origin,
+                                     out GMPVideoHost outVideoHost);
 };
--- a/content/xul/templates/tests/chrome/test_bug476634.xul
+++ b/content/xul/templates/tests/chrome/test_bug476634.xul
@@ -34,33 +34,33 @@ https://bugzilla.mozilla.org/show_bug.cg
 <![CDATA[
 function startup() {
   var ss = Components.classes["@mozilla.org/storage/service;1"]
                      .getService(Components.interfaces.mozIStorageService);
   var db = ss.openSpecialDatabase("memory");
   
   db.createTable("test", "id TEXT, value INTEGER");
   var stmt = db.createStatement("INSERT INTO test (id, value) VALUES (?,?)");
-  stmt.bindStringParameter(0, "test1");
-  stmt.bindInt32Parameter(1, 0);
+  stmt.bindByIndex(0, "test1");
+  stmt.bindByIndex(1, 0);
   stmt.execute();
-  stmt.bindStringParameter(0, "test2");
-  stmt.bindInt32Parameter(1, 2147483647);
+  stmt.bindByIndex(0, "test2");
+  stmt.bindByIndex(1, 2147483647);
   stmt.execute();
-  stmt.bindStringParameter(0, "test3");
-  stmt.bindInt32Parameter(1, -2147483648);
+  stmt.bindByIndex(0, "test3");
+  stmt.bindByIndex(1, -2147483648);
   stmt.execute();
-  stmt.bindStringParameter(0, "test4");
-  stmt.bindInt64Parameter(1, 0);
+  stmt.bindByIndex(0, "test4");
+  stmt.bindByIndex(1, 0);
   stmt.execute();
-  stmt.bindStringParameter(0, "test5");
-  stmt.bindInt64Parameter(1, 3147483647);
+  stmt.bindByIndex(0, "test5");
+  stmt.bindByIndex(1, 3147483647);
   stmt.execute();
-  stmt.bindStringParameter(0, "test6");
-  stmt.bindInt64Parameter(1, -3147483648);
+  stmt.bindByIndex(0, "test6");
+  stmt.bindByIndex(1, -3147483648);
   stmt.execute();
   stmt.finalize();
 
   var list = document.getElementById("results-list");
   list.builder.datasource = db;
 
   is(list.childNodes.length, 6, "Should be 6 generated elements");
   is(list.childNodes[0].value, "0", "Should have seen the correct value");
--- a/dom/apps/src/AppsUtils.jsm
+++ b/dom/apps/src/AppsUtils.jsm
@@ -6,17 +6,16 @@
 
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 
 Cu.import("resource://gre/modules/osfile.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
   "resource://gre/modules/FileUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "WebappOSUtils",
   "resource://gre/modules/WebappOSUtils.jsm");
--- a/dom/browser-element/mochitest/browserElement_SetInputMethodActive.js
+++ b/dom/browser-element/mochitest/browserElement_SetInputMethodActive.js
@@ -140,89 +140,144 @@ function startTest() {
 
   req0.onerror = function() {
     ok(false, 'setInputMethodActive failed (0): ' + this.error.name);
   };
 }
 
 var gCount = 0;
 
+var gFrameMsgCounts = {
+  'input': 0,
+  'im0': 0,
+  'im1': 0
+};
+
 function next(msg) {
   let wrappedMsg = SpecialPowers.wrap(msg);
   let from = wrappedMsg.data.from;
   let value = wrappedMsg.data.value;
 
   if (wrappedMsg.data.error) {
     ok(false, wrappedMsg.data.value);
 
     return;
   }
 
-  gCount++;
+  let fromId = from;
+  if (from === 'im') {
+    fromId += value[1];
+  }
+  gFrameMsgCounts[fromId]++;
 
   // The texts sent from the first and the second input method are '#0' and
   // '#1' respectively.
   switch (gCount) {
-    case 1:
-      is(from, 'im', 'Message sequence unexpected (1).');
-      is(value, '#0true', 'First frame should get the context first.');
-      // Do nothing and wait for the input to show up in input frame.
-      break;
+    case 0:
+      switch (fromId) {
+        case 'im0':
+          if (gFrameMsgCounts.im0 === 1) {
+            is(value, '#0true', 'First frame should get the context first.');
+          } else {
+            ok(false, 'Unexpected multiple messages from im0.')
+          }
+
+          break;
+
+        case 'im1':
+          is(false, 'Shouldn\'t be hearing anything from second frame.');
+
+          break;
 
-    case 2:
-      is(from, 'input', 'Message sequence unexpected (2).');
-      is(value, '#0hello',
-         'Failed to get correct input from the first iframe.');
+        case 'input':
+          if (gFrameMsgCounts.input === 1) {
+            is(value, '#0hello',
+              'Failed to get correct input from the first iframe.');
+          } else {
+            ok(false, 'Unexpected multiple messages from input.')
+          }
+
+          break;
+      }
+
+      if (gFrameMsgCounts.input !== 1 ||
+          gFrameMsgCounts.im0 !== 1 ||
+          gFrameMsgCounts.im1 !== 0) {
+        return;
+      }
+
+      gCount++;
 
       let req0 = gFrames[0].setInputMethodActive(false);
       req0.onsuccess = function() {
         ok(true, 'setInputMethodActive succeeded (0).');
       };
       req0.onerror = function() {
         ok(false, 'setInputMethodActive failed (0): ' + this.error.name);
       };
       let req1 = gFrames[1].setInputMethodActive(true);
       req1.onsuccess = function() {
-       ok(true, 'setInputMethodActive succeeded (1).');
+        ok(true, 'setInputMethodActive succeeded (1).');
       };
       req1.onerror = function() {
-       ok(false, 'setInputMethodActive failed (1): ' + this.error.name);
+        ok(false, 'setInputMethodActive failed (1): ' + this.error.name);
       };
+
       break;
 
-    case 3:
-      is(from, 'im', 'Message sequence unexpected (3).');
-      is(value, '#0false', 'First frame should have the context removed.');
-      // Do nothing and wait for the second frame to get the context;
-      break;
+    case 1:
+      switch (fromId) {
+        case 'im0':
+          if (gFrameMsgCounts.im0 === 2) {
+            is(value, '#0false', 'First frame should have the context removed.');
+          } else {
+            ok(false, 'Unexpected multiple messages from im0.')
+          }
+          break;
+
+        case 'im1':
+          if (gFrameMsgCounts.im1 === 1) {
+            is(value, '#1true', 'Second frame should get the context.');
+          } else {
+            ok(false, 'Unexpected multiple messages from im0.')
+          }
 
-    case 4:
-      is(from, 'im', 'Message sequence unexpected (4).');
-      is(value, '#1true', 'Second frame should get the context.');
-      // Do nothing and wait for the input to show up in input frame.
-      break;
+          break;
 
-    case 5:
-      is(from, 'input', 'Message sequence unexpected (5).');
-      is(value, '#0#1hello',
-         'Failed to get correct input from the second iframe.');
+        case 'input':
+          if (gFrameMsgCounts.input === 2) {
+            is(value, '#0#1hello',
+               'Failed to get correct input from the second iframe.');
+          } else {
+            ok(false, 'Unexpected multiple messages from input.')
+          }
+          break;
+      }
+
+      if (gFrameMsgCounts.input !== 2 ||
+          gFrameMsgCounts.im0 !== 2 ||
+          gFrameMsgCounts.im1 !== 1) {
+        return;
+      }
+
+      gCount++;
 
       // Receive the second input from the second iframe.
       // Deactive the second iframe.
       let req3 = gFrames[1].setInputMethodActive(false);
       req3.onsuccess = function() {
-        ok(true, 'setInputMethodActive(false) succeeded (3).');
+        ok(true, 'setInputMethodActive(false) succeeded (2).');
       };
       req3.onerror = function() {
-        ok(false, 'setInputMethodActive(false) failed (3): ' + this.error.name);
+        ok(false, 'setInputMethodActive(false) failed (2): ' + this.error.name);
       };
       break;
 
-    case 6:
-      is(from, 'im', 'Message sequence unexpected (6).');
+    case 2:
+      is(fromId, 'im1', 'Message sequence unexpected (3).');
       is(value, '#1false', 'Second frame should have the context removed.');
 
       tearDown();
       break;
   }
 }
 
 setup();
--- a/dom/contacts/fallback/ContactDB.jsm
+++ b/dom/contacts/fallback/ContactDB.jsm
@@ -10,19 +10,21 @@ this.EXPORTED_SYMBOLS = ["ContactDB", "D
 
 const DEBUG = false;
 function debug(s) { dump("-*- ContactDB component: " + s + "\n"); }
 
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
-Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberUtils",
+                                  "resource://gre/modules/PhoneNumberUtils.jsm");
 Cu.importGlobalProperties(["indexedDB"]);
 
 /* all exported symbols need to be bound to this on B2G - Bug 961777 */
 this.DB_NAME = "contacts";
 this.DB_VERSION = 20;
 this.STORE_NAME = "contacts";
 this.SAVED_GETALL_STORE_NAME = "getallcache";
 const CHUNK_SIZE = 20;
--- a/dom/contacts/fallback/ContactService.jsm
+++ b/dom/contacts/fallback/ContactService.jsm
@@ -10,18 +10,21 @@ function debug(s) { dump("-*- Fallback C
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 this.EXPORTED_SYMBOLS = ["ContactService"];
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/ContactDB.jsm");
-Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "ContactDB",
+                                  "resource://gre/modules/ContactDB.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberUtils",
+                                  "resource://gre/modules/PhoneNumberUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                    "@mozilla.org/parentprocessmessagemanager;1",
                                    "nsIMessageListenerManager");
 
 
 /* all exported symbols need to be bound to this on B2G - Bug 961777 */
 let ContactService = this.ContactService = {
--- a/dom/indexedDB/OpenDatabaseHelper.cpp
+++ b/dom/indexedDB/OpenDatabaseHelper.cpp
@@ -366,23 +366,23 @@ UpgradeSchemaFrom4To5(mozIStorageConnect
     "INSERT INTO database (name, version, dataVersion) "
     "VALUES (:name, :version, :dataVersion)"
   ), getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   {
     mozStorageStatementScoper scoper(stmt);
 
-    rv = stmt->BindStringParameter(0, name);
+    rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), name);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = stmt->BindInt32Parameter(1, intVersion);
+    rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("version"), intVersion);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = stmt->BindInt64Parameter(2, dataVersion);
+    rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("dataVersion"), dataVersion);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = stmt->Execute();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   rv = aConnection->SetSchemaVersion(5);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/mobilemessage/src/gonk/MobileMessageDB.jsm
+++ b/dom/mobilemessage/src/gonk/MobileMessageDB.jsm
@@ -6,18 +6,21 @@
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
 Cu.importGlobalProperties(["indexedDB"]);
 
-var RIL = {};
-Cu.import("resource://gre/modules/ril_consts.js", RIL);
+XPCOMUtils.defineLazyGetter(this, "RIL", function () {
+  let obj = {};
+  Cu.import("resource://gre/modules/ril_consts.js", obj);
+  return obj;
+});
 
 const RIL_GETMESSAGESCURSOR_CID =
   Components.ID("{484d1ad8-840e-4782-9dc4-9ebc4d914937}");
 const RIL_GETTHREADSCURSOR_CID =
   Components.ID("{95ee7c3e-d6f2-4ec4-ade5-0c453c036d35}");
 
 const DEBUG = false;
 const DISABLE_MMS_GROUPING_FOR_RECEIVING = true;
--- a/dom/phonenumberutils/PhoneNumber.jsm
+++ b/dom/phonenumberutils/PhoneNumber.jsm
@@ -3,19 +3,23 @@
 
 // Don't modify this code. Please use:
 // https://github.com/andreasgal/PhoneNumber.js
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["PhoneNumber"];
 
-Components.utils.import("resource://gre/modules/PhoneNumberMetaData.jsm");
-Components.utils.import("resource://gre/modules/PhoneNumberNormalizer.jsm");
+const Cu = Components.utils;
 
+Cu.import('resource://gre/modules/XPCOMUtils.jsm');
+XPCOMUtils.defineLazyModuleGetter(this, "PHONE_NUMBER_META_DATA",
+                                  "resource://gre/modules/PhoneNumberMetaData.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberNormalizer",
+                                  "resource://gre/modules/PhoneNumberNormalizer.jsm");
 this.PhoneNumber = (function (dataBase) {
   // Use strict in our context only - users might not want it
   'use strict';
 
   const MAX_PHONE_NUMBER_LENGTH = 50;
   const NON_ALPHA_CHARS = /[^a-zA-Z]/g;
   const NON_DIALABLE_CHARS = /[^,#+\*\d]/g;
   const NON_DIALABLE_CHARS_ONCE = new RegExp(NON_DIALABLE_CHARS.source);
--- a/dom/phonenumberutils/PhoneNumberUtils.jsm
+++ b/dom/phonenumberutils/PhoneNumberUtils.jsm
@@ -9,18 +9,20 @@ const DEBUG = false;
 function debug(s) { if(DEBUG) dump("-*- PhoneNumberutils: " + s + "\n"); }
 
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-Cu.import("resource://gre/modules/PhoneNumberNormalizer.jsm");
-Cu.import("resource://gre/modules/mcc_iso3166_table.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberNormalizer",
+                                  "resource://gre/modules/PhoneNumberNormalizer.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "MCC_ISO3166_TABLE",
+                                  "resource://gre/modules/mcc_iso3166_table.jsm");
 
 #ifdef MOZ_B2G_RIL
 XPCOMUtils.defineLazyServiceGetter(this, "mobileConnection",
                                    "@mozilla.org/ril/content-helper;1",
                                    "nsIMobileConnectionProvider");
 XPCOMUtils.defineLazyServiceGetter(this, "icc",
                                    "@mozilla.org/ril/content-helper;1",
                                    "nsIIccProvider");
@@ -191,15 +193,16 @@ this.PhoneNumberUtils = {
         if (DEBUG) debug("WRONG MESSAGE NAME: " + aMessage.name);
     }
   }
 };
 
 let inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
                  .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 if (inParent) {
-  Cu.import("resource://gre/modules/PhoneNumber.jsm");
+  XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumber",
+                                    "resource://gre/modules/PhoneNumber.jsm");
   XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                      "@mozilla.org/parentprocessmessagemanager;1",
                                      "nsIMessageListenerManager");
   PhoneNumberUtils.init();
 }
 
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -3194,22 +3194,26 @@ PluginInstanceChild::PaintRectToSurface(
     }
     if (mHelperSurface) {
         // On X11 we can paint to non Xlib surface only with HelperSurface
         renderSurface = mHelperSurface;
     }
 #endif
 
     if (mIsTransparent && !CanPaintOnBackground()) {
-        // Clear surface content for transparent rendering
-        nsRefPtr<gfxContext> ctx = new gfxContext(renderSurface);
-        ctx->SetDeviceColor(aColor);
-        ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
-        ctx->Rectangle(GfxFromNsRect(plPaintRect));
-        ctx->Fill();
+        RefPtr<DrawTarget> dt = CreateDrawTargetForSurface(renderSurface);
+        gfx::Rect rect(plPaintRect.x, plPaintRect.y,
+                       plPaintRect.width, plPaintRect.height);
+        // Moz2D treats OP_SOURCE operations as unbounded, so we need to
+        // clip to the rect that we want to fill:
+        dt->PushClipRect(rect);
+        dt->FillRect(rect, ColorPattern(ToColor(aColor)),
+                     DrawOptions(1.f, CompositionOp::OP_SOURCE));
+        dt->PopClip();
+        dt->Flush();
     }
 
     PaintRectToPlatformSurface(plPaintRect, renderSurface);
 
     if (renderSurface != aSurface) {
         // Copy helper surface content to target
         RefPtr<DrawTarget> dt = CreateDrawTargetForSurface(aSurface);
         RefPtr<SourceSurface> surface =
--- a/dom/system/gonk/Nfc.js
+++ b/dom/system/gonk/Nfc.js
@@ -17,18 +17,21 @@
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
-let NFC = {};
-Cu.import("resource://gre/modules/nfc_consts.js", NFC);
+XPCOMUtils.defineLazyGetter(this, "NFC", function () {
+  let obj = {};
+  Cu.import("resource://gre/modules/nfc_consts.js", obj);
+  return obj;
+});
 
 Cu.import("resource://gre/modules/systemlibs.js");
 const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true";
 
 // set to true in nfc_consts.js to see debug messages
 let DEBUG = NFC.DEBUG_NFC;
 
 let debug;
--- a/dom/system/gonk/NfcContentHelper.js
+++ b/dom/system/gonk/NfcContentHelper.js
@@ -18,18 +18,21 @@
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
 
-let NFC = {};
-Cu.import("resource://gre/modules/nfc_consts.js", NFC);
+XPCOMUtils.defineLazyGetter(this, "NFC", function () {
+  let obj = {};
+  Cu.import("resource://gre/modules/nfc_consts.js", obj);
+  return obj;
+});
 
 Cu.import("resource://gre/modules/systemlibs.js");
 const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true";
 
 // set to true to in nfc_consts.js to see debug messages
 let DEBUG = NFC.DEBUG_CONTENT_HELPER;
 
 let debug;
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -16,18 +16,21 @@
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-var RIL = {};
-Cu.import("resource://gre/modules/ril_consts.js", RIL);
+XPCOMUtils.defineLazyGetter(this, "RIL", function () {
+  let obj = {};
+  Cu.import("resource://gre/modules/ril_consts.js", obj);
+  return obj;
+});
 
 const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
 
 const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
 
 const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
 const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
 const kPrefVoicemailDefaultServiceId = "dom.voicemail.defaultServiceId";
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -19,18 +19,21 @@ const {classes: Cc, interfaces: Ci, util
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Sntp.jsm");
 Cu.import("resource://gre/modules/systemlibs.js");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 
-var RIL = {};
-Cu.import("resource://gre/modules/ril_consts.js", RIL);
+XPCOMUtils.defineLazyGetter(this, "RIL", function () {
+  let obj = {};
+  Cu.import("resource://gre/modules/ril_consts.js", obj);
+  return obj;
+});
 
 // Ril quirk to attach data registration on demand.
 let RILQUIRKS_DATA_REGISTRATION_ON_DEMAND =
   libcutils.property_get("ro.moz.ril.data_reg_on_demand", "false") == "true";
 
 // Ril quirk to control the uicc/data subscription.
 let RILQUIRKS_SUBSCRIPTION_CONTROL =
   libcutils.property_get("ro.moz.ril.subscription_control", "false") == "true";
@@ -1624,19 +1627,17 @@ WorkerMessenger.prototype = {
         extraUint2ndCall:
           libcutils.property_get("ro.moz.ril.extra_int_2nd_call", "false") == "true",
         haveQueryIccLockRetryCount:
           libcutils.property_get("ro.moz.ril.query_icc_count", "false") == "true",
         sendStkProfileDownload:
           libcutils.property_get("ro.moz.ril.send_stk_profile_dl", "false") == "true",
         dataRegistrationOnDemand: RILQUIRKS_DATA_REGISTRATION_ON_DEMAND,
         subscriptionControl: RILQUIRKS_SUBSCRIPTION_CONTROL
-      },
-      rilEmergencyNumbers: libcutils.property_get("ril.ecclist") ||
-                           libcutils.property_get("ro.ril.ecclist")
+      }
     };
 
     this.send(null, "setInitialOptions", options);
   },
 
   setDebugFlag: function(aDebug) {
     let options = { debug: aDebug };
     this.send(null, "setDebugFlag", options);
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -47,19 +47,16 @@ let GLOBAL = this;
 
 if (!this.debug) {
   // Debugging stub that goes nowhere.
   this.debug = function debug(message) {
     dump("RIL Worker: " + message + "\n");
   };
 }
 
-let RIL_EMERGENCY_NUMBERS;
-const DEFAULT_EMERGENCY_NUMBERS = ["112", "911"];
-
 // Timeout value for emergency callback mode.
 const EMERGENCY_CB_MODE_TIMEOUT_MS = 300000;  // 5 mins = 300000 ms.
 
 const ICC_MAX_LINEAR_FIXED_RECORDS = 0xfe;
 
 // MMI match groups
 const MMI_MATCH_GROUP_FULL_MMI = 1;
 const MMI_MATCH_GROUP_MMI_PROCEDURE = 2;
@@ -1550,53 +1547,32 @@ RilObject.prototype = {
    * Cache the request for making an emergency call when radio is off. The
    * request shall include two types of callback functions. 'callback' is
    * called when radio is ready, and 'onerror' is called when turning radio
    * on fails.
    */
   cachedDialRequest : null,
 
   /**
-   * Dial the phone.
+   * Dial a non-emergency number.
    *
    * @param number
    *        String containing the number to dial.
    * @param clirMode
    *        Integer for showing/hidding the caller Id to the called party.
    * @param uusInfo
    *        Integer doing something XXX TODO
    */
-  dial: function(options) {
+  dialNonEmergencyNumber: function(options) {
     let onerror = (function onerror(options, errorMsg) {
       options.success = false;
       options.errorMsg = errorMsg;
       this.sendChromeMessage(options);
     }).bind(this, options);
 
-    if (this._isEmergencyNumber(options.number)) {
-      this.dialEmergencyNumber(options, onerror);
-    } else {
-      if (!this._isCdma) {
-        // TODO: Both dial() and sendMMI() functions should be unified at some
-        // point in the future. In the mean time we handle temporary CLIR MMI
-        // commands through the dial() function. Please see bug 889737.
-        let mmi = this._parseMMI(options.number);
-        if (mmi && this._isTemporaryModeCLIR(mmi)) {
-          options.number = mmi.dialNumber;
-          // In temporary mode, MMI_PROCEDURE_ACTIVATION means allowing CLI
-          // presentation, i.e. CLIR_SUPPRESSION. See TS 22.030, Annex B.
-          options.clirMode = mmi.procedure == MMI_PROCEDURE_ACTIVATION ?
-                             CLIR_SUPPRESSION : CLIR_INVOCATION;
-        }
-      }
-      this.dialNonEmergencyNumber(options, onerror);
-    }
-  },
-
-  dialNonEmergencyNumber: function(options, onerror) {
     if (this.radioState == GECKO_RADIOSTATE_OFF) {
       // Notify error in establishing the call without radio.
       onerror(GECKO_ERROR_RADIO_NOT_AVAILABLE);
       return;
     }
 
     if (this.voiceRegistrationState.emergencyCallsOnly ||
         options.isDialEmergency) {
@@ -1604,55 +1580,79 @@ RilObject.prototype = {
       return;
     }
 
     // Exit emergency callback mode when user dial a non-emergency call.
     if (this._isInEmergencyCbMode) {
       this.exitEmergencyCbMode();
     }
 
-    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) {
+    if (!this._isCdma) {
+      // TODO: Both dial() and sendMMI() functions should be unified at some
+      // point in the future. In the mean time we handle temporary CLIR MMI
+      // commands through the dial() function. Please see bug 889737.
+      let mmi = this._parseMMI(options.number);
+      if (mmi && this._isTemporaryModeCLIR(mmi)) {
+        options.number = mmi.dialNumber;
+        // In temporary mode, MMI_PROCEDURE_ACTIVATION means allowing CLI
+        // presentation, i.e. CLIR_SUPPRESSION. See TS 22.030, Annex B.
+        options.clirMode = mmi.procedure == MMI_PROCEDURE_ACTIVATION ?
+          CLIR_SUPPRESSION : CLIR_INVOCATION;
+      }
+    }
+
+    options.request = REQUEST_DIAL;
+    this.sendDialRequest(options);
+  },
+
+  /**
+   * Dial an emergency number.
+   *
+   * @param number
+   *        String containing the number to dial.
+   * @param clirMode
+   *        Integer for showing/hidding the caller Id to the called party.
+   * @param uusInfo
+   *        Integer doing something XXX TODO
+   */
+  dialEmergencyNumber: function(options) {
+    let onerror = (function onerror(options, errorMsg) {
+      options.success = false;
+      options.errorMsg = errorMsg;
+      this.sendChromeMessage(options);
+    }).bind(this, options);
+
     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);
+  },
+
+  sendDialRequest: function(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) {
-    this.telephonyRequestQueue.push(options.request, this.sendRilRequestDial,
-                                    options);
+      this.telephonyRequestQueue.push(options.request, this.sendRilRequestDial,
+                                      options);
+    }
   },
 
   sendRilRequestDial: 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);
@@ -2412,19 +2412,18 @@ RilObject.prototype = {
   /**
    * Helper to parse short string. TS.22.030 Figure 3.5.3.2.
    */
   _isMMIShortString: function(mmiString) {
     if (mmiString.length > 2) {
       return false;
     }
 
-    if (this._isEmergencyNumber(mmiString)) {
-      return false;
-    }
+    // TODO: Should take care of checking if the string is an emergency number
+    // in Bug 889737. See Bug 1023141 for more background.
 
     // In a call case.
     if (Object.getOwnPropertyNames(this.currentCalls).length > 0) {
       return true;
     }
 
     if ((mmiString.length != 2) || (mmiString.charAt(0) !== '1')) {
       return true;
@@ -3304,48 +3303,28 @@ RilObject.prototype = {
     // Calculate and write Parcel size to 1st mark
     Buf.stopCalOutgoingSize();
 
     Buf.writeInt32(0);
     Buf.sendParcel();
   },
 
   /**
-   * Check a given number against the list of emergency numbers provided by the RIL.
-   *
-   * @param number
-   *        The number to look up.
-   */
-   _isEmergencyNumber: function(number) {
-     // Check ril provided numbers first.
-     let numbers = RIL_EMERGENCY_NUMBERS;
-
-     if (numbers) {
-       numbers = numbers.split(",");
-     } else {
-       // No ecclist system property, so use our own list.
-       numbers = DEFAULT_EMERGENCY_NUMBERS;
-     }
-
-     return numbers.indexOf(number) != -1;
-   },
-
-   /**
-    * Checks whether to temporarily suppress caller id for the call.
-    *
-    * @param mmi
-    *        MMI full object.
-    */
-   _isTemporaryModeCLIR: function(mmi) {
-     return (mmi &&
-             mmi.serviceCode == MMI_SC_CLIR &&
-             mmi.dialNumber &&
-             (mmi.procedure == MMI_PROCEDURE_ACTIVATION ||
-              mmi.procedure == MMI_PROCEDURE_DEACTIVATION));
-   },
+   * Checks whether to temporarily suppress caller id for the call.
+   *
+   * @param mmi
+   *        MMI full object.
+   */
+  _isTemporaryModeCLIR: function(mmi) {
+    return (mmi &&
+            mmi.serviceCode == MMI_SC_CLIR &&
+            mmi.dialNumber &&
+            (mmi.procedure == MMI_PROCEDURE_ACTIVATION ||
+             mmi.procedure == MMI_PROCEDURE_DEACTIVATION));
+  },
 
   /**
    * Report STK Service is running.
    */
   reportStkServiceIsRunning: function() {
     this.context.Buf.simpleRequest(REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
   },
 
@@ -4050,16 +4029,17 @@ RilObject.prototype = {
       let options = this.pendingMO.options;
       this.pendingMO = null;
 
       // Find the callIndex of the new outgoing call.
       let callIndex = -1;
       for (let i in newCalls) {
         if (newCalls[i].state !== CALL_STATE_INCOMING) {
           callIndex = newCalls[i].callIndex;
+          newCalls[i].isEmergency = options.isEmergency;
           break;
         }
       }
 
       if (callIndex === -1) {
         // The call doesn't exist.
         options.success = false;
         options.errorMsg = GECKO_CALL_ERROR_UNSPECIFIED;
@@ -4100,19 +4080,19 @@ RilObject.prototype = {
     }
 
     if (newCall.state == CALL_STATE_INCOMING) {
       newCall.isOutgoing = false;
     } else if (newCall.state == CALL_STATE_DIALING) {
       newCall.isOutgoing = true;
     }
 
-    // Set flag for outgoing emergency call.
-    newCall.isEmergency = newCall.isOutgoing &&
-      this._isEmergencyNumber(newCall.number);
+    if (newCall.isEmergency === undefined) {
+      newCall.isEmergency = false;
+    }
 
     // Set flag for conference.
     newCall.isConference = newCall.isMpty ? true : false;
 
     // Add to our map.
     if (newCall.isMpty) {
       this.currentConference.participants[newCall.callIndex] = newCall;
     }
--- a/dom/system/gonk/tests/test_ril_worker_ecm.js
+++ b/dom/system/gonk/tests/test_ril_worker_ecm.js
@@ -117,18 +117,19 @@ add_test(function test_request_exit_emer
   do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, TIMER_ID);
 
   let parcelTypes = [];
   context.Buf.newParcel = function(type, options) {
     parcelTypes.push(type);
   };
 
   // Dial non-emergency call.
-  context.RIL.dial({number: "0912345678",
-                  isDialEmergency: false});
+  context.RIL.dialNonEmergencyNumber({number: "0912345678",
+                                      isEmergency: false,
+                                      isDialEmergency: false});
 
   // Should clear timeout event.
   do_check_eq(context.RIL._exitEmergencyCbModeTimeoutID, null);
 
   // Check indeed sent out REQUEST_EXIT_EMERGENCY_CALLBACK_MODE.
   do_check_neq(parcelTypes.indexOf(REQUEST_EXIT_EMERGENCY_CALLBACK_MODE), -1);
 
   run_next_test();
--- a/dom/telephony/gonk/TelephonyService.js
+++ b/dom/telephony/gonk/TelephonyService.js
@@ -5,19 +5,23 @@
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
+Cu.import("resource://gre/modules/systemlibs.js");
 
-var RIL = {};
-Cu.import("resource://gre/modules/ril_consts.js", RIL);
+XPCOMUtils.defineLazyGetter(this, "RIL", function () {
+  let obj = {};
+  Cu.import("resource://gre/modules/ril_consts.js", obj);
+  return obj;
+});
 
 const GONK_TELEPHONYSERVICE_CONTRACTID =
   "@mozilla.org/telephony/gonktelephonyservice;1";
 const GONK_TELEPHONYSERVICE_CID =
   Components.ID("{67d26434-d063-4d28-9f48-5b3189788155}");
 
 const NS_XPCOM_SHUTDOWN_OBSERVER_ID   = "xpcom-shutdown";
 
@@ -42,16 +46,18 @@ const AUDIO_STATE_NO_CALL  = 0;
 const AUDIO_STATE_INCOMING = 1;
 const AUDIO_STATE_IN_CALL  = 2;
 const AUDIO_STATE_NAME = [
   "PHONE_STATE_NORMAL",
   "PHONE_STATE_RINGTONE",
   "PHONE_STATE_IN_CALL"
 ];
 
+const DEFAULT_EMERGENCY_NUMBERS = ["112", "911"];
+
 let DEBUG;
 function debug(s) {
   dump("TelephonyService: " + s + "\n");
 }
 
 XPCOMUtils.defineLazyGetter(this, "gAudioManager", function getAudioManager() {
   try {
     return Cc["@mozilla.org/telephony/audiomanager;1"]
@@ -323,16 +329,36 @@ TelephonyService.prototype = {
         this._currentCalls[aClientId][call.callIndex] = call;
       }
 
       return false;
     }).bind(this));
   },
 
   /**
+   * Check a given number against the list of emergency numbers provided by the
+   * RIL.
+   *
+   * @param aNumber
+   *        The number to look up.
+   */
+  _isEmergencyNumber: function(aNumber) {
+    // Check ril provided numbers first.
+    let numbers = libcutils.property_get("ril.ecclist") ||
+                  libcutils.property_get("ro.ril.ecclist");
+    if (numbers) {
+      numbers = numbers.split(",");
+    } else {
+      // No ecclist system property, so use our own list.
+      numbers = DEFAULT_EMERGENCY_NUMBERS;
+    }
+    return numbers.indexOf(aNumber) != -1;
+  },
+
+  /**
    * nsITelephonyService interface.
    */
 
   defaultServiceId: 0,
 
   registerListener: function(aListener) {
     if (this._listeners.indexOf(aListener) >= 0) {
       throw Cr.NS_ERROR_UNEXPECTED;
@@ -469,19 +495,24 @@ TelephonyService.prototype = {
       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);
     };
 
+    let isEmergencyNumber = this._isEmergencyNumber(aNumber);
+    let msg = isEmergencyNumber ?
+              "dialEmergencyNumber" :
+              "dialNonEmergencyNumber";
     this.isDialing = true;
-    this._getClient(aClientId).sendWorkerMessage("dial", {
+    this._getClient(aClientId).sendWorkerMessage(msg, {
       number: aNumber,
+      isEmergency: isEmergencyNumber,
       isDialEmergency: aIsEmergency
     }, (function(response) {
       this.isDialing = false;
       if (!response.success) {
         aTelephonyCallback.notifyDialError(response.errorMsg);
         return false;
       }
 
--- a/dom/telephony/test/marionette/head.js
+++ b/dom/telephony/test/marionette/head.js
@@ -9,64 +9,88 @@ const kPrefRilDebuggingEnabled = "ril.de
 
 /**
  * Emulator helper.
  */
 let emulator = (function() {
   let pendingCmdCount = 0;
   let originalRunEmulatorCmd = runEmulatorCmd;
 
+  let pendingShellCount = 0;
+  let originalRunEmulatorShell = runEmulatorShell;
+
   // Overwritten it so people could not call this function directly.
   runEmulatorCmd = function() {
-    throw "Use emulator.runWithCallback(cmd, callback) instead of runEmulatorCmd";
+    throw "Use emulator.runCmdWithCallback(cmd, callback) instead of runEmulatorCmd";
   };
 
-  function run(cmd) {
+  // Overwritten it so people could not call this function directly.
+  runEmulatorShell = function() {
+    throw "Use emulator.runShellCmd(cmd, callback) instead of runEmulatorShell";
+  };
+
+  function runCmd(cmd) {
     let deferred = Promise.defer();
 
     pendingCmdCount++;
     originalRunEmulatorCmd(cmd, function(result) {
       pendingCmdCount--;
       if (result[result.length - 1] === "OK") {
         deferred.resolve(result);
       } else {
         is(result[result.length - 1], "OK", "emulator command result.");
         deferred.reject();
       }
     });
 
     return deferred.promise;
   }
 
-  function runWithCallback(cmd, callback) {
-    run(cmd).then(result => {
+  function runCmdWithCallback(cmd, callback) {
+    runCmd(cmd).then(result => {
       if (callback && typeof callback === "function") {
         callback(result);
       }
     });
   }
 
   /**
    * @return Promise
    */
+  function runShellCmd(aCommands) {
+    let deferred = Promise.defer();
+
+    ++pendingShellCount;
+    originalRunEmulatorShell(aCommands, function(aResult) {
+      --pendingShellCount;
+      deferred.resolve(aResult);
+    });
+
+    return deferred.promise;
+  }
+
+  /**
+   * @return Promise
+   */
   function waitFinish() {
     let deferred = Promise.defer();
 
     waitFor(function() {
       deferred.resolve();
     }, function() {
-      return pendingCmdCount === 0;
+      return pendingCmdCount === 0 && pendingShellCount === 0;
     });
 
     return deferred.promise;
   }
 
   return {
-    run: run,
-    runWithCallback: runWithCallback,
+    runCmd: runCmd,
+    runCmdWithCallback: runCmdWithCallback,
+    runShellCmd: runShellCmd,
     waitFinish: waitFinish
   };
 }());
 
 /**
  * Telephony related helper functions.
  */
 (function() {
@@ -118,17 +142,17 @@ let emulator = (function() {
 
     for (let call of conference.calls) {
       log(".. hangUp " + call.id.number);
       hangUpPromises.push(hangUp(call));
     }
 
     return Promise.all(hangUpPromises)
       .then(() => {
-        return emulator.run("gsm clear");
+        return emulator.runCmd("gsm clear").then(waitForNoCall);
       })
       .then(waitForNoCall);
   }
 
   /**
    * Provide a string with format of the emulator call list result.
    *
    * @param prefix
@@ -356,17 +380,17 @@ let emulator = (function() {
   /**
    * Convenient helper to check the call list existing in the emulator.
    *
    * @param expectedCallList
    *        An array of call info with the format of "callStrPool()[state]".
    * @return A deferred promise.
    */
   function checkEmulatorCallList(expectedCallList) {
-    return emulator.run("gsm list").then(result => {
+    return emulator.runCmd("gsm list").then(result => {
       log("Call list is now: " + result);
       for (let i = 0; i < expectedCallList.length; ++i) {
         is(result[i], expectedCallList[i], "emulator calllist");
       }
     });
   }
 
   /**
@@ -606,17 +630,17 @@ let emulator = (function() {
       checkCallId(number, numberPresentation, name, namePresentation,
                   call.id.number, call.id.name);
       deferred.resolve(call);
     };
 
     numberPresentation = numberPresentation || "";
     name = name || "";
     namePresentation = namePresentation || "";
-    emulator.run("gsm call " + number + "," + numberPresentation + "," + name +
+    emulator.runCmd("gsm call " + number + "," + numberPresentation + "," + name +
                  "," + namePresentation);
     return deferred.promise;
   }
 
   /**
    * Remote party answers the call.
    *
    * @param call
@@ -629,17 +653,17 @@ let emulator = (function() {
     let deferred = Promise.defer();
 
     call.onconnected = function onconnected(event) {
       log("Received 'connected' call event.");
       call.onconnected = null;
       checkEventCallState(event, call, "connected");
       deferred.resolve(call);
     };
-    emulator.run("gsm accept " + call.id.number);
+    emulator.runCmd("gsm accept " + call.id.number);
 
     return deferred.promise;
   }
 
   /**
    * Remote party hangs up the call.
    *
    * @param call
@@ -652,17 +676,17 @@ let emulator = (function() {
     let deferred = Promise.defer();
 
     call.ondisconnected = function ondisconnected(event) {
       log("Received 'disconnected' call event.");
       call.ondisconnected = null;
       checkEventCallState(event, call, "disconnected");
       deferred.resolve(call);
     };
-    emulator.run("gsm cancel " + call.id.number);
+    emulator.runCmd("gsm cancel " + call.id.number);
 
     return deferred.promise;
   }
 
   /**
    * Remote party hangs up all the calls.
    *
    * @param calls
--- a/dom/telephony/test/marionette/test_crash_emulator.js
+++ b/dom/telephony/test/marionette/test_crash_emulator.js
@@ -26,17 +26,17 @@ function answer() {
     // just some code to keep call active for awhile
     callStartTime = Date.now();
     waitFor(cleanUp,function() {
       callDuration = Date.now() - callStartTime;
       log("Waiting while call is active, call duration (ms): " + callDuration);
       return(callDuration >= 2000);
     });
   };
-  emulator.runWithCallback("gsm accept " + outNumber);
+  emulator.runCmdWithCallback("gsm accept " + outNumber);
 }
 
 function cleanUp(){
   outgoingCall.hangUp();
   ok("passed");
   finish();
 }
 
--- a/dom/telephony/test/marionette/test_dsds_connection_conflict.js
+++ b/dom/telephony/test/marionette/test_dsds_connection_conflict.js
@@ -2,17 +2,17 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 60000;
 MARIONETTE_HEAD_JS = 'head.js';
 
 function muxModem(id) {
   let deferred = Promise.defer();
 
-  emulator.runWithCallback("mux modem " + id, function() {
+  emulator.runCmdWithCallback("mux modem " + id, function() {
     deferred.resolve();
   });
 
   return deferred.promise;
 }
 
 function testNewCallWhenOtherConnectionInUse(firstServiceId, secondServiceId) {
   log("= testNewCallWhenOtherConnectionInUse =");
--- a/dom/telephony/test/marionette/test_dsds_normal_call.js
+++ b/dom/telephony/test/marionette/test_dsds_normal_call.js
@@ -2,17 +2,17 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 60000;
 MARIONETTE_HEAD_JS = 'head.js';
 
 function muxModem(id) {
   let deferred = Promise.defer();
 
-  emulator.runWithCallback("mux modem " + id, function() {
+  emulator.runCmdWithCallback("mux modem " + id, function() {
     deferred.resolve();
   });
 
   return deferred.promise;
 }
 
 function testOutgoingCallForServiceId(number, serviceId) {
   let outCall;
--- a/dom/telephony/test/marionette/test_emergency.js
+++ b/dom/telephony/test/marionette/test_emergency.js
@@ -23,17 +23,17 @@ function dial() {
     is(telephony.calls[0], outgoing);
 
     outgoing.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoing, event.call);
       is(outgoing.state, "alerting");
       is(outgoing.emergency, true);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + number + "        : ringing");
         answer();
       });
     };
   });
 }
 
@@ -44,44 +44,44 @@ function answer() {
 
   outgoing.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "connected");
 
     is(outgoing, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + number + "        : active");
       hangUp();
     });
   };
-  emulator.runWithCallback("gsm accept " + number);
+  emulator.runCmdWithCallback("gsm accept " + number);
 }
 
 function hangUp() {
   log("Hanging up the emergency call.");
 
   // We get no "disconnecting" event when the remote party terminates the call.
 
   outgoing.ondisconnected = function ondisconnected(event) {
     log("Received 'disconnected' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "disconnected");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
-  emulator.runWithCallback("gsm cancel " + number);
+  emulator.runCmdWithCallback("gsm cancel " + number);
 }
 
 function cleanUp() {
   finish();
 }
 
 startTest(function() {
   dial();
--- a/dom/telephony/test/marionette/test_emergency_badNumber.js
+++ b/dom/telephony/test/marionette/test_emergency_badNumber.js
@@ -11,17 +11,17 @@ function dial() {
 
   telephony.dialEmergency(number).then(null, cause => {
     log("Received promise 'reject'");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
     is(cause, "BadNumberError");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Initial call list: " + result);
       cleanUp();
     });
   });
 }
 
 function cleanUp() {
   finish();
--- a/dom/telephony/test/marionette/test_emergency_label.js
+++ b/dom/telephony/test/marionette/test_emergency_label.js
@@ -1,15 +1,51 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 MARIONETTE_TIMEOUT = 60000;
 MARIONETTE_HEAD_JS = 'head.js';
 
-function testEmergencyLabel(number, emergency) {
+const DEFAULT_ECC_LIST = "112,911";
+
+function setEccListProperty(list) {
+  log("Set property ril.ecclist: " + list);
+
+  let deferred = Promise.defer();
+  try {
+    emulator.runShellCmd(["setprop","ril.ecclist", list]).then(function() {
+      deferred.resolve(list);
+    });
+  } catch (e) {
+    deferred.reject(e);
+  }
+  return deferred.promise;
+}
+
+function getEccListProperty() {
+  log("Get property ril.ecclist.");
+
+  let deferred = Promise.defer();
+  try {
+    emulator.runShellCmd(["getprop","ril.ecclist"]).then(function(aResult) {
+      let list = !aResult.length ? "" : aResult[0];
+      deferred.resolve(list);
+    });
+  } catch (e) {
+    deferred.reject(e);
+  }
+  return deferred.promise;
+}
+
+function testEmergencyLabel(number, list) {
+  if (!list) {
+    list = DEFAULT_ECC_LIST;
+  }
+  let index = list.split(",").indexOf(number);
+  let emergency = index != -1;
   log("= testEmergencyLabel = " + number + " should be " +
       (emergency ? "emergency" : "normal") + " call");
 
   let outCall;
 
   return gDial(number)
     .then(call => { outCall = call; })
     .then(() => {
@@ -18,17 +54,32 @@ function testEmergencyLabel(number, emer
     .then(() => gRemoteAnswer(outCall))
     .then(() => {
       is(outCall.emergency, emergency, "emergency result should be correct");
     })
     .then(() => gRemoteHangUp(outCall));
 }
 
 startTest(function() {
-  testEmergencyLabel("112", true)
-    .then(() => testEmergencyLabel("911", true))
-    .then(() => testEmergencyLabel("0912345678", false))
-    .then(() => testEmergencyLabel("777", false))
-    .then(null, () => {
-      ok(false, 'promise rejects during test.');
+  let origEccList;
+  let eccList;
+
+  getEccListProperty()
+    .then(list => {
+      origEccList = eccList = list;
+    })
+    .then(() => testEmergencyLabel("112", eccList))
+    .then(() => testEmergencyLabel("911", eccList))
+    .then(() => testEmergencyLabel("0912345678", eccList))
+    .then(() => testEmergencyLabel("777", eccList))
+    .then(() => {
+      eccList = "777,119";
+      return setEccListProperty(eccList);
+    })
+    .then(() => testEmergencyLabel("777", eccList))
+    .then(() => testEmergencyLabel("119", eccList))
+    .then(() => testEmergencyLabel("112", eccList))
+    .then(() => setEccListProperty(origEccList))
+    .then(null, error => {
+      ok(false, 'promise rejects during test: ' + error);
     })
     .then(finish);
 });
--- a/dom/telephony/test/marionette/test_incoming_already_connected.js
+++ b/dom/telephony/test/marionette/test_incoming_already_connected.js
@@ -22,17 +22,17 @@ function dial() {
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
     outgoingCall.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoingCall, event.call);
       is(outgoingCall.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + outNumber + " : ringing");
         answer();
       });
     };
   });
 }
 
@@ -42,31 +42,31 @@ function answer() {
   // We get no "connecting" event when the remote party answers the call.
   outgoingCall.onconnected = function onconnectedOut(event) {
     log("Received 'connected' call event for the original outgoing call.");
 
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
     is(outgoingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : active");
 
       if(!gotOriginalConnected){
         gotOriginalConnected = true;
         simulateIncoming();
       } else {
         // Received connected event for original call multiple times (fail)
         ok(false,
            "Received 'connected' event for original call multiple times");
       }
     });
   };
-  emulator.runWithCallback("gsm accept " + outNumber);
+  emulator.runCmdWithCallback("gsm accept " + outNumber);
 }
 
 // With one connected call already, simulate an incoming call
 function simulateIncoming() {
   log("Simulating an incoming call (with one call already connected).");
 
   telephony.onincoming = function onincoming(event) {
     log("Received 'incoming' call event.");
@@ -75,24 +75,24 @@ function simulateIncoming() {
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     // Should be two calls now
     is(telephony.calls.length, 2);
     is(telephony.calls[0], outgoingCall);
     is(telephony.calls[1], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : active");
       is(result[1], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 // Answer incoming call; original outgoing call should be held
 function answerIncoming() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnectingIn(event) {
@@ -106,17 +106,17 @@ function answerIncoming() {
     log("Received 'connected' call event for incoming/2nd call.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
     is(outgoingCall.state, "held");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       is(result[1], "inbound from " + inNumber + " : active");
       hangUpOutgoing();
     });
   };
   incomingCall.answer();
 }
@@ -138,17 +138,17 @@ function hangUpOutgoing() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Back to one call now
     is(telephony.calls.length, 1);
     is(incomingCall.state, "connected");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       hangUpIncoming();
     });
   };
   outgoingCall.hangUp();
 }
 
@@ -169,17 +169,17 @@ function hangUpIncoming() {
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Zero calls left
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   incomingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_incoming_already_held.js
+++ b/dom/telephony/test/marionette/test_incoming_already_held.js
@@ -22,17 +22,17 @@ function dial() {
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
     outgoingCall.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoingCall, event.call);
       is(outgoingCall.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + outNumber + " : ringing");
         answer();
       });
     };
   });
 }
 
@@ -42,31 +42,31 @@ function answer() {
   // We get no "connecting" event when the remote party answers the call.
   outgoingCall.onconnected = function onconnectedOut(event) {
     log("Received 'connected' call event for the original outgoing call.");
 
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
     is(outgoingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : active");
 
       if(!gotOriginalConnected){
         gotOriginalConnected = true;
         holdCall();
       } else {
         // Received connected event for original call multiple times (fail)
         ok(false,
            "Received 'connected' event for original call multiple times");
       }
     });
   };
-  emulator.runWithCallback("gsm accept " + outNumber);
+  emulator.runCmdWithCallback("gsm accept " + outNumber);
 }
 
 function holdCall() {
   log("Putting the original (outgoing) call on hold.");
 
   let gotHolding = false;
   outgoingCall.onholding = function onholding(event) {
     log("Received 'holding' call event");
@@ -80,17 +80,17 @@ function holdCall() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       simulateIncoming();
     });
   };
   outgoingCall.hold();
 }
 
@@ -105,24 +105,24 @@ function simulateIncoming() {
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     // Should be two calls now
     is(telephony.calls.length, 2);
     is(telephony.calls[0], outgoingCall);
     is(telephony.calls[1], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       is(result[1], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 // Answer incoming call; original outgoing call should be held
 function answerIncoming() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnectingIn(event) {
@@ -136,17 +136,17 @@ function answerIncoming() {
     log("Received 'connected' call event for incoming/2nd call.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
     is(outgoingCall.state, "held");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       is(result[1], "inbound from " + inNumber + " : active");
       hangUpOutgoing();
     });
   };
   incomingCall.answer();
 }
@@ -168,17 +168,17 @@ function hangUpOutgoing() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Back to one call now
     is(telephony.calls.length, 1);
     is(incomingCall.state, "connected");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       hangUpIncoming();
     });
   };
   outgoingCall.hangUp();
 }
 
@@ -199,17 +199,17 @@ function hangUpIncoming() {
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Zero calls left
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   incomingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_incoming_answer_hangup.js
+++ b/dom/telephony/test/marionette/test_incoming_answer_hangup.js
@@ -17,23 +17,23 @@ function simulateIncoming() {
     ok(incoming);
     is(incoming.id.number, number);
     is(incoming.state, "incoming");
 
     //ok(telephony.calls === calls); // bug 717414
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incoming);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : incoming");
       answer();
     });
   };
-  emulator.runWithCallback("gsm call " + number);
+  emulator.runCmdWithCallback("gsm call " + number);
 }
 
 function answer() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incoming.onconnecting = function onconnecting(event) {
     log("Received 'connecting' call event.");
@@ -45,17 +45,17 @@ function answer() {
   incoming.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(incoming, event.call);
     is(incoming.state, "connected");
     ok(gotConnecting);
 
     is(incoming, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : active");
       hangUp();
     });
   };
   incoming.answer();
 }
 
@@ -74,17 +74,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(incoming, event.call);
     is(incoming.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   incoming.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_incoming_answer_hangup_oncallschanged.js
+++ b/dom/telephony/test/marionette/test_incoming_answer_hangup_oncallschanged.js
@@ -23,24 +23,24 @@ function simulateIncoming() {
     incoming = event.call;
     ok(incoming);
     is(incoming.id.number, number);
     is(incoming.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incoming);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : incoming");
       answer();
     });
   };
 
-  emulator.runWithCallback("gsm call " + number);
+  emulator.runCmdWithCallback("gsm call " + number);
 }
 
 function answer() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incoming.onconnecting = function onconnecting(event) {
     log("Received 'connecting' call event.");
@@ -55,17 +55,17 @@ function answer() {
   incoming.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(incoming, event.call);
     is(incoming.state, "connected");
     ok(gotConnecting);
 
     is(incoming, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : active");
       hangUp();
     });
   };
   incoming.answer();
 }
 
@@ -104,17 +104,17 @@ function hangUp() {
     is(incoming, event.call);
     is(incoming.state, "disconnected");
     ok(gotDisconnecting);
     ok(gotCallschanged);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
 
   incoming.hangUp();
 }
 
--- a/dom/telephony/test/marionette/test_incoming_answer_remote_hangup.js
+++ b/dom/telephony/test/marionette/test_incoming_answer_remote_hangup.js
@@ -15,23 +15,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnectingIn(event) {
     log("Received 'connecting' call event for incoming call.");
@@ -43,17 +43,17 @@ function answerIncoming() {
   incomingCall.onconnected = function onconnectedIn(event) {
     log("Received 'connected' call event for incoming call.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       remoteHangUp();
     });
   };
   incomingCall.answer();
 }
 
@@ -65,22 +65,22 @@ function remoteHangUp() {
   incomingCall.ondisconnected = function ondisconnected(event) {
     log("Received 'disconnected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
-  emulator.runWithCallback("gsm cancel " + inNumber);
+  emulator.runCmdWithCallback("gsm cancel " + inNumber);
 }
 
 function cleanUp() {
   telephony.onincoming = null;
   finish();
 }
 
 startTest(function() {
--- a/dom/telephony/test/marionette/test_incoming_connecting_hangup.js
+++ b/dom/telephony/test/marionette/test_incoming_connecting_hangup.js
@@ -15,23 +15,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
 
   incomingCall.onconnecting = function onconnecting(event) {
     log("Received 'connecting' call event.");
     is(incomingCall, event.call);
@@ -72,17 +72,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   incomingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_incoming_connecting_remote_hangup.js
+++ b/dom/telephony/test/marionette/test_incoming_connecting_remote_hangup.js
@@ -15,23 +15,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
 
   incomingCall.onconnecting = function onconnecting(event) {
     log("Received 'connecting' call event.");
     is(incomingCall, event.call);
@@ -54,22 +54,22 @@ function remoteHangUp() {
   incomingCall.ondisconnected = function ondisconnected(event) {
     log("Received 'disconnected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
-  emulator.runWithCallback("gsm cancel " + inNumber);
+  emulator.runCmdWithCallback("gsm cancel " + inNumber);
 }
 
 function cleanUp() {
   telephony.onincoming = null;
   finish();
 }
 
 startTest(function() {
--- a/dom/telephony/test/marionette/test_incoming_hangup_held.js
+++ b/dom/telephony/test/marionette/test_incoming_hangup_held.js
@@ -15,23 +15,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnectingIn(event) {
     log("Received 'connecting' call event for incoming call.");
@@ -43,17 +43,17 @@ function answerIncoming() {
   incomingCall.onconnected = function onconnectedIn(event) {
     log("Received 'connected' call event for incoming call.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       hold();
     });
   };
   incomingCall.answer();
 }
 
@@ -73,17 +73,17 @@ function hold() {
     is(incomingCall, event.call);
     is(incomingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : held");
       hangUp();
     });
   };
   incomingCall.hold();
 }
 
@@ -102,17 +102,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   incomingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_incoming_hold_resume.js
+++ b/dom/telephony/test/marionette/test_incoming_hold_resume.js
@@ -16,23 +16,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, number);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : incoming");
       answer();
     });
   };
-  emulator.runWithCallback("gsm call " + number);
+  emulator.runCmdWithCallback("gsm call " + number);
 }
 
 function answer() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnecting(event) {
     log("Received 'connecting' call event.");
@@ -44,17 +44,17 @@ function answer() {
   incomingCall.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : active");
       hold();
     });
   };
   incomingCall.answer();
 }
 
@@ -74,17 +74,17 @@ function hold() {
     is(incomingCall, event.call);
     is(incomingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : held");
       // Wait on hold for a couple of seconds
       log("Pausing 2 seconds while on hold");
       setTimeout(resume, 2000);
     });
   };
   incomingCall.hold();
@@ -106,17 +106,17 @@ function resume() {
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotResuming);
 
     is(incomingCall, telephony.active);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : active");
       hangUp();
     });
   };
   incomingCall.resume();
 }
 
@@ -135,17 +135,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   incomingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_incoming_onstatechange.js
+++ b/dom/telephony/test/marionette/test_incoming_onstatechange.js
@@ -15,23 +15,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
 
   gotConnecting = false;
   incomingCall.onstatechange = function statechangeconnect(event) {
     log("Received 'onstatechange' call event.");
@@ -40,17 +40,17 @@ function answerIncoming() {
       is(incomingCall.state, "connecting");
       gotConnecting = true;
     } else {
       is(incomingCall.state, "connected");
       is(telephony.active, incomingCall);
       is(telephony.calls.length, 1);
       is(telephony.calls[0], incomingCall);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "inbound from " + inNumber + " : active");
         hold();
       });
     }
   };
   incomingCall.answer();
 }
@@ -66,17 +66,17 @@ function hold() {
       is(incomingCall.state, "holding");
       gotHolding = true;
     } else {
       is(incomingCall.state, "held");
       is(telephony.active, null);
       is(telephony.calls.length, 1);
       is(telephony.calls[0], incomingCall);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "inbound from " + inNumber + " : held");
         resume();
       });
     }
   };
   incomingCall.hold();
 }
@@ -92,17 +92,17 @@ function resume() {
       is(incomingCall.state, "resuming");
       gotResuming = true;
     } else {
       is(incomingCall.state, "connected");
       is(telephony.active, incomingCall);
       is(telephony.calls.length, 1);
       is(telephony.calls[0], incomingCall);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "inbound from " + inNumber + " : active");
         hangUp();
       });
     }
   };
   incomingCall.resume();
 }
@@ -117,17 +117,17 @@ function hangUp() {
     if(!gotDisconnecting){
       is(incomingCall.state, "disconnecting");
       gotDisconnecting = true;
     } else {
       is(incomingCall.state, "disconnected");
       is(telephony.active, null);
       is(telephony.calls.length, 0);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         cleanUp();
       });
     }
   };
   incomingCall.hangUp();
 }
 
--- a/dom/telephony/test/marionette/test_incoming_reject.js
+++ b/dom/telephony/test/marionette/test_incoming_reject.js
@@ -17,23 +17,23 @@ function simulateIncoming() {
     ok(incoming);
     is(incoming.id.number, number);
     is(incoming.state, "incoming");
 
     //ok(telephony.calls === calls); // bug 717414
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incoming);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + number + " : incoming");
       reject();
     });
   };
-  emulator.runWithCallback("gsm call " + number);
+  emulator.runCmdWithCallback("gsm call " + number);
 }
 
 function reject() {
   log("Reject the incoming call.");
 
   let gotDisconnecting = false;
   incoming.ondisconnecting = function ondisconnecting(event) {
     log("Received 'disconnecting' call event.");
@@ -46,17 +46,17 @@ function reject() {
     log("Received 'disconnected' call event.");
     is(incoming, event.call);
     is(incoming.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   incoming.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_incoming_remote_cancel.js
+++ b/dom/telephony/test/marionette/test_incoming_remote_cancel.js
@@ -15,44 +15,44 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       cancelIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function cancelIncoming(){
   log("Remote party cancelling call before it is answered.");
 
   // We get no 'disconnecting' event when remote party cancels/hangs-up call
 
   incomingCall.ondisconnected = function ondisconnected(event) {
     log("Received 'disconnected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
-  emulator.runWithCallback("gsm cancel " + inNumber);
+  emulator.runCmdWithCallback("gsm cancel " + inNumber);
 }
 
 function cleanUp() {
   telephony.onincoming = null;
   finish();
 }
 
 startTest(function() {
--- a/dom/telephony/test/marionette/test_incoming_remote_hangup_held.js
+++ b/dom/telephony/test/marionette/test_incoming_remote_hangup_held.js
@@ -15,23 +15,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnectingIn(event) {
     log("Received 'connecting' call event for incoming call.");
@@ -43,17 +43,17 @@ function answerIncoming() {
   incomingCall.onconnected = function onconnectedIn(event) {
     log("Received 'connected' call event for incoming call.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       hold();
     });
   };
   incomingCall.answer();
 }
 
@@ -73,17 +73,17 @@ function hold() {
     is(incomingCall, event.call);
     is(incomingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : held");
       hangUp();
     });
   };
   incomingCall.hold();
 }
 
@@ -95,22 +95,22 @@ function hangUp() {
   incomingCall.ondisconnected = function ondisconnected(event) {
     log("Received 'disconnected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
-  emulator.runWithCallback("gsm cancel " + inNumber);
+  emulator.runCmdWithCallback("gsm cancel " + inNumber);
 }
 
 function cleanUp() {
   telephony.onincoming = null;
   finish();
 }
 
 startTest(function() {
--- a/dom/telephony/test/marionette/test_multiple_hold.js
+++ b/dom/telephony/test/marionette/test_multiple_hold.js
@@ -17,23 +17,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnectingIn(event) {
     log("Received 'connecting' call event for original (incoming) call.");
@@ -44,17 +44,17 @@ function answerIncoming() {
 
   incomingCall.onconnected = function onconnectedIn(event) {
     log("Received 'connected' call event for original (incoming) call.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
     is(incomingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       holdCall();
     });
   };
   incomingCall.answer();
 }
 
@@ -75,17 +75,17 @@ function holdCall() {
     is(incomingCall, event.call);
     is(incomingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : held");
       dial();
     });
   };
   incomingCall.hold();
 }
 
@@ -103,17 +103,17 @@ function dial() {
     is(telephony.calls[0], incomingCall);
     is(telephony.calls[1], outgoingCall);
 
     outgoingCall.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoingCall, event.call);
       is(outgoingCall.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "inbound from " + inNumber + " : held");
         is(result[1], "outbound to  " + outNumber + " : ringing");
         answerOutgoing();
       });
     };
   });
 }
@@ -124,24 +124,24 @@ function answerOutgoing() {
 
   // We get no "connecting" event when the remote party answers the call.
   outgoingCall.onconnected = function onconnectedOut(event) {
     log("Received 'connected' call event for outgoing/2nd call.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
     is(outgoingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : held");
       is(result[1], "outbound to  " + outNumber + " : active");
       holdSecondCall();
     });
   };
-  emulator.runWithCallback("gsm accept " + outNumber);
+  emulator.runCmdWithCallback("gsm accept " + outNumber);
 }
 
 // With one held call and one active, hold the active one; expect the first
 // (held) call to automatically become active, and the 2nd call to go on hold
 function holdSecondCall() {
   let firstCallReconnected = false;
   let secondCallHeld = false;
 
@@ -182,17 +182,17 @@ function holdSecondCall() {
 }
 
 function verifyCalls() {
   is(telephony.active, incomingCall);
   is(telephony.calls.length, 2);
   is(telephony.calls[0], incomingCall);
   is(telephony.calls[1], outgoingCall);
 
-  emulator.runWithCallback("gsm list", function(result) {
+  emulator.runCmdWithCallback("gsm list", function(result) {
     log("Call list is now: " + result);
     is(result[0], "inbound from " + inNumber + " : active");
     is(result[1], "outbound to  " + outNumber + " : held");
     hangUpIncoming();
   });
 }
 
 // Hang-up the original incoming call, which is now active
@@ -213,17 +213,17 @@ function hangUpIncoming() {
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Now back to one call
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       hangUpOutgoing();
     });
   };
   incomingCall.hangUp();
 }
 
@@ -244,17 +244,17 @@ function hangUpOutgoing() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Now no calls
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   outgoingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_outgoing_already_held.js
+++ b/dom/telephony/test/marionette/test_outgoing_already_held.js
@@ -24,23 +24,23 @@ function simulateIncoming() {
 
     // Wait for emulator to catch up before continuing
     waitFor(verifyCallList,function() {
       return(rcvdEmulatorCallback);
     });
   };
 
   let rcvdEmulatorCallback = false;
-  emulator.runWithCallback("gsm call " + inNumber, function(result) {
+  emulator.runCmdWithCallback("gsm call " + inNumber, function(result) {
     rcvdEmulatorCallback = true;
   });
 }
 
 function verifyCallList(){
-  emulator.runWithCallback("gsm list", function(result) {
+  emulator.runCmdWithCallback("gsm list", function(result) {
     log("Call list is now: " + result);
     is(result[0], "inbound from " + inNumber + " : incoming");
     answerIncoming();
   });
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
@@ -56,17 +56,17 @@ function answerIncoming() {
   incomingCall.onconnected = function onconnectedIn(event) {
     log("Received 'connected' call event for original (incoming) call.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       holdCall();
     });
   };
   incomingCall.answer();
 }
 
@@ -87,17 +87,17 @@ function holdCall(){
     is(incomingCall, event.call);
     is(incomingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : held");
       dial();
     });
   };
   incomingCall.hold();
 }
 
@@ -116,17 +116,17 @@ function dial() {
     is(telephony.calls[0], incomingCall);
     is(telephony.calls[1], outgoingCall);
 
     outgoingCall.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoingCall, event.call);
       is(outgoingCall.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "inbound from " + inNumber + " : held");
         is(result[1], "outbound to  " + outNumber + " : ringing");
         answerOutgoing();
       });
     };
   });
 }
@@ -145,23 +145,23 @@ function answerOutgoing() {
 
     // Wait for emulator to catch up before continuing
     waitFor(checkCallList,function() {
       return(rcvdEmulatorCallback);
     });
   };
 
   let rcvdEmulatorCallback = false;
-  emulator.runWithCallback("gsm accept " + outNumber, function(result) {
+  emulator.runCmdWithCallback("gsm accept " + outNumber, function(result) {
     rcvdEmulatorCallback = true;
   });
 }
 
 function checkCallList(){
-  emulator.runWithCallback("gsm list", function(result) {
+  emulator.runCmdWithCallback("gsm list", function(result) {
     log("Call list is now: " + result);
     is(result[0], "inbound from " + inNumber + " : held");
     is(result[1], "outbound to  " + outNumber + " : active");
     hangUpIncoming();
   });
 }
 
 // Hang-up the original incoming call, which is now held
@@ -182,17 +182,17 @@ function hangUpIncoming() {
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Now back to one call
     is(telephony.active, outgoingCall);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : active");
       hangUpOutgoing();
     });
   };
   incomingCall.hangUp();
 }
 
@@ -213,17 +213,17 @@ function hangUpOutgoing() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Now no calls
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   outgoingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_outgoing_answer_hangup.js
+++ b/dom/telephony/test/marionette/test_outgoing_answer_hangup.js
@@ -22,17 +22,17 @@ function dial() {
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoing);
 
     outgoing.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoing, event.call);
       is(outgoing.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + number + " : ringing");
         answer();
       });
     };
   });
 }
 
@@ -43,44 +43,44 @@ function answer() {
 
   outgoing.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "connected");
 
     is(outgoing, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + number + " : active");
       hangUp();
     });
   };
-  emulator.runWithCallback("gsm accept " + number);
+  emulator.runCmdWithCallback("gsm accept " + number);
 }
 
 function hangUp() {
   log("Hanging up the outgoing call.");
 
   // We get no "disconnecting" event when the remote party terminates the call.
 
   outgoing.ondisconnected = function ondisconnected(event) {
     log("Received 'disconnected' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "disconnected");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
-  emulator.runWithCallback("gsm cancel " + number);
+  emulator.runCmdWithCallback("gsm cancel " + number);
 }
 
 function cleanUp() {
   finish();
 }
 
 startTest(function() {
   dial();
--- a/dom/telephony/test/marionette/test_outgoing_answer_hangup_oncallschanged.js
+++ b/dom/telephony/test/marionette/test_outgoing_answer_hangup_oncallschanged.js
@@ -41,17 +41,17 @@ function dial() {
       cleanUp();
     }
   };
 
   telephony.dial(number);
 }
 
 function checkCallList() {
-  emulator.runWithCallback("gsm list", function(result) {
+  emulator.runCmdWithCallback("gsm list", function(result) {
     log("Call list is now: " + result);
     if (((result[0] == "outbound to  " + number + " : unknown") ||
          (result[0] == "outbound to  " + number + " : dialing"))) {
       answer();
     } else {
       window.setTimeout(checkCallList, 100);
     }
   });
@@ -64,29 +64,29 @@ function answer() {
 
   outgoing.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "connected");
 
     is(outgoing, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list (after 'connected' event) is now: " + result);
       is(result[0], "outbound to  " + number + " : active");
       hangUp();
     });
   };
-  emulator.runWithCallback("gsm accept " + number);
+  emulator.runCmdWithCallback("gsm accept " + number);
 }
 
 function hangUp() {
   log("Hanging up the outgoing call.");
 
-  emulator.runWithCallback("gsm cancel " + number);
+  emulator.runCmdWithCallback("gsm cancel " + number);
 }
 
 function cleanUp() {
   telephony.oncallschanged = null;
   finish();
 }
 
 startTest(function() {
--- a/dom/telephony/test/marionette/test_outgoing_answer_local_hangup.js
+++ b/dom/telephony/test/marionette/test_outgoing_answer_local_hangup.js
@@ -21,17 +21,17 @@ function dial() {
     is(telephony.calls[0], outgoingCall);
 
     outgoingCall.onalerting = function onalerting(event) {
       log("Received 'alerting' call event.");
 
       is(outgoingCall, event.call);
       is(outgoingCall.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + outNumber + " : ringing");
         answer();
       });
     };
   });
 }
 
@@ -42,23 +42,23 @@ function answer() {
 
   outgoingCall.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
 
     is(outgoingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : active");
       hangUp();
     });
   };
-  emulator.runWithCallback("gsm accept " + outNumber);
+  emulator.runCmdWithCallback("gsm accept " + outNumber);
 }
 
 function hangUp() {
   log("Hanging up the outgoing call (local hang-up).");
 
   let gotDisconnecting = false;
   outgoingCall.ondisconnecting = function ondisconnectingOut(event) {
     log("Received 'disconnecting' call event.");
@@ -71,17 +71,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   outgoingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_outgoing_answer_radio_off.js
+++ b/dom/telephony/test/marionette/test_outgoing_answer_radio_off.js
@@ -54,17 +54,17 @@ function remoteAnswer(call) {
 
   call.onconnected = function(event) {
     log("Received 'connected' call event.");
     call.onconnected = null;
     is(call, event.call);
     is(call.state, "connected");
     deferred.resolve(call);
   };
-  emulator.runWithCallback("gsm accept " + call.id.number);
+  emulator.runCmdWithCallback("gsm accept " + call.id.number);
 
   return deferred.promise;
 }
 
 function disableRadioAndWaitForCallEvent(call) {
   log("Disable radio and wait for call event.");
 
   let deferred = Promise.defer();
--- a/dom/telephony/test/marionette/test_outgoing_badNumber.js
+++ b/dom/telephony/test/marionette/test_outgoing_badNumber.js
@@ -25,17 +25,17 @@ function dial() {
     is(telephony.calls[0], outgoing);
 
     outgoing.onerror = function onerror(event) {
       log("Received 'error' event.");
       is(event.call, outgoing);
       ok(event.call.error);
       is(event.call.error.name, "BadNumberError");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Initial call list: " + result);
         cleanUp();
       });
     };
   });
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_outgoing_busy.js
+++ b/dom/telephony/test/marionette/test_outgoing_busy.js
@@ -20,40 +20,40 @@ function dial() {
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoing);
 
     outgoing.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoing, event.call);
       is(outgoing.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + number + " : ringing");
         busy();
       });
     };
   });
 }
 
 function busy() {
   log("The receiver is busy.");
 
   outgoing.onerror = function onerror(event) {
     log("Received 'error' call event.");
     is(outgoing, event.call);
     is(event.call.error.name, "BusyError");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
 
-  emulator.runWithCallback("gsm busy " + number);
+  emulator.runCmdWithCallback("gsm busy " + number);
 }
 
 function cleanUp() {
   finish();
 }
 
 startTest(function() {
   dial();
--- a/dom/telephony/test/marionette/test_outgoing_hangup_alerting.js
+++ b/dom/telephony/test/marionette/test_outgoing_hangup_alerting.js
@@ -19,17 +19,17 @@ function dial() {
 
     is(outgoing, telephony.active);
     //ok(telephony.calls === calls); // bug 717414
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoing);
 
     outgoing.onalerting = function onalerting(event) {
       log("Received 'alerting' call event.");
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + number + " : ringing");
         hangUp();
       });
     };
   });
 }
 
@@ -49,17 +49,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
 
   outgoing.hangUp();
 }
 
--- a/dom/telephony/test/marionette/test_outgoing_hangup_held.js
+++ b/dom/telephony/test/marionette/test_outgoing_hangup_held.js
@@ -21,17 +21,17 @@ function dial() {
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoing);
 
     outgoing.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoing, event.call);
       is(outgoing.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + number + " : ringing");
         answer();
       });
     };
   });
 }
 
@@ -42,23 +42,23 @@ function answer() {
 
   outgoing.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "connected");
 
     is(outgoing, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + number + " : active");
       hold();
     });
   };
-  emulator.runWithCallback("gsm accept " + number);
+  emulator.runCmdWithCallback("gsm accept " + number);
 }
 
 function hold() {
   log("Holding the outgoing call.");
 
   outgoing.onholding = function onholding(event) {
     log("Received 'holding' call event.");
     is(outgoing, event.call);
@@ -70,17 +70,17 @@ function hold() {
   outgoing.onheld = function onheld(event) {
     log("Received 'held' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "held");
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + number + " : held");
       hangUp();
     });
   };
   outgoing.hold();
 }
 
@@ -99,17 +99,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(outgoing, event.call);
     is(outgoing.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
 
   outgoing.hangUp();
 }
 
--- a/dom/telephony/test/marionette/test_outgoing_hold_resume.js
+++ b/dom/telephony/test/marionette/test_outgoing_hold_resume.js
@@ -21,17 +21,17 @@ function dial() {
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
     outgoingCall.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoingCall, event.call);
       is(outgoingCall.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + number + " : ringing");
         answer();
       });
     };
   });
 }
 
@@ -42,23 +42,23 @@ function answer() {
 
   outgoingCall.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
 
     is(outgoingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + number + " : active");
       hold();
     });
   };
-  emulator.runWithCallback("gsm accept " + number);
+  emulator.runCmdWithCallback("gsm accept " + number);
 }
 
 function hold() {
   log("Putting the call on hold.");
 
   let gotHolding = false;
   outgoingCall.onholding = function onholding(event) {
     log("Received 'holding' call event");
@@ -72,17 +72,17 @@ function hold() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + number + " : held");
       // Bug 781604: emulator assertion if outgoing call kept on hold
       // Wait on hold for a couple of seconds
       //log("Pausing 2 seconds while on hold");
       //setTimeout(resume, 2000);
       resume();
     });
@@ -106,17 +106,17 @@ function resume() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
     ok(gotResuming);
 
     is(outgoingCall, telephony.active);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + number + " : active");
       hangUp();
     });
   };
   outgoingCall.resume();
 }
 
@@ -135,17 +135,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   outgoingCall.hangUp();
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_outgoing_onstatechange.js
+++ b/dom/telephony/test/marionette/test_outgoing_onstatechange.js
@@ -23,17 +23,17 @@ function dial() {
     outgoingCall.onstatechange = function statechangering(event) {
       log("Received 'onstatechange' call event.");
 
       is(outgoingCall, event.call);
       let expectedStates = ["dialing", "alerting"];
       ok(expectedStates.indexOf(event.call.state) != -1);
 
       if (event.call.state == "alerting") {
-        emulator.runWithCallback("gsm list", function(result) {
+        emulator.runCmdWithCallback("gsm list", function(result) {
           log("Call list is now: " + result);
           is(result[0], "outbound to  " + outNumber + " : ringing");
           answer();
         });
       }
     };
   });
 }
@@ -44,23 +44,23 @@ function answer() {
   // We get no "connecting" event when the remote party answers the call.
 
   outgoingCall.onstatechange = function onstatechangeanswer(event) {
     log("Received 'onstatechange' call event.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
     is(outgoingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : active");
       hold();
     });
   };
-  emulator.runWithCallback("gsm accept " + outNumber);
+  emulator.runCmdWithCallback("gsm accept " + outNumber);
 }
 
 function hold() {
   log("Putting the call on hold.");
 
   let gotHolding = false;
   outgoingCall.onstatechange = function onstatechangehold(event) {
     log("Received 'onstatechange' call event.");
@@ -69,17 +69,17 @@ function hold() {
       is(outgoingCall.state, "holding");
       gotHolding = true;
     } else {
       is(outgoingCall.state, "held");
       is(telephony.active, null);
       is(telephony.calls.length, 1);
       is(telephony.calls[0], outgoingCall);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + outNumber + " : held");
         resume();
       });
     }
   };
   outgoingCall.hold();
 }
@@ -95,17 +95,17 @@ function resume() {
       is(outgoingCall.state, "resuming");
       gotResuming = true;
     } else {
       is(outgoingCall.state, "connected");
       is(telephony.active, outgoingCall);
       is(telephony.calls.length, 1);
       is(telephony.calls[0], outgoingCall);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + outNumber + " : active");
         hangUp();
       });
     }
   };
   outgoingCall.resume();
 }
@@ -120,17 +120,17 @@ function hangUp() {
     if(!gotDisconnecting){
       is(outgoingCall.state, "disconnecting");
       gotDisconnecting = true;
     } else {
       is(outgoingCall.state, "disconnected");
       is(telephony.active, null);
       is(telephony.calls.length, 0);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         cleanUp();
       });
     }
   };
   outgoingCall.hangUp();
 }
 
--- a/dom/telephony/test/marionette/test_outgoing_radio_off.js
+++ b/dom/telephony/test/marionette/test_outgoing_radio_off.js
@@ -42,17 +42,17 @@ function dial(number) {
 
   telephony.dial(number).then(null, cause => {
     log("Received promise 'reject'");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
     is(cause, "RadioNotAvailable");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Initial call list: " + result);
 
       setRadioEnabled(true, cleanUp);
     });
   });
 }
 
 function cleanUp() {
--- a/dom/telephony/test/marionette/test_outgoing_reject.js
+++ b/dom/telephony/test/marionette/test_outgoing_reject.js
@@ -20,17 +20,17 @@ function dial() {
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoing);
 
     outgoing.onalerting = function onalerting(event) {
       log("Received 'onalerting' call event.");
       is(outgoing, event.call);
       is(outgoing.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + number + " : ringing");
         reject();
       });
     };
   });
 }
 
@@ -48,23 +48,23 @@ function reject() {
 
     // Wait for emulator to catch up before continuing
     waitFor(verifyCallList,function() {
       return(rcvdEmulatorCallback);
     });
   };
 
   let rcvdEmulatorCallback = false;
-  emulator.runWithCallback("gsm cancel " + number, function(result) {
+  emulator.runCmdWithCallback("gsm cancel " + number, function(result) {
     rcvdEmulatorCallback = true;
   });
 }
 
 function verifyCallList(){
-  emulator.runWithCallback("gsm list", function(result) {
+  emulator.runCmdWithCallback("gsm list", function(result) {
     log("Call list is now: " + result);
     cleanUp();
   });
 }
 
 function cleanUp() {
   finish();
 }
--- a/dom/telephony/test/marionette/test_outgoing_remote_hangup_held.js
+++ b/dom/telephony/test/marionette/test_outgoing_remote_hangup_held.js
@@ -20,17 +20,17 @@ function dial() {
     is(telephony.calls[0], outgoingCall);
 
     outgoingCall.onalerting = function onalerting(event) {
       log("Received 'alerting' call event.");
 
       is(outgoingCall, event.call);
       is(outgoingCall.state, "alerting");
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + outNumber + " : ringing");
         answer();
       });
     };
   });
 }
 
@@ -41,23 +41,23 @@ function answer() {
 
   outgoingCall.onconnected = function onconnected(event) {
     log("Received 'connected' call event.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
 
     is(outgoingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : active");
       hold();
     });
   };
-  emulator.runWithCallback("gsm accept " + outNumber);
+  emulator.runCmdWithCallback("gsm accept " + outNumber);
 }
 
 function hold() {
   log("Holding the outgoing call.");
 
   outgoingCall.onholding = function onholding(event) {
     log("Received 'holding' call event.");
     is(outgoingCall, event.call);
@@ -70,17 +70,17 @@ function hold() {
     log("Received 'held' call event.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "held");
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       hangUp();
     });
   };
   outgoingCall.hold();
 }
 
@@ -92,22 +92,22 @@ function hangUp() {
   outgoingCall.ondisconnected = function ondisconnected(event) {
     log("Received 'disconnected' call event.");
     is(outgoingCall, event.call);
     is(outgoingCall.state, "disconnected");
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
-  emulator.runWithCallback("gsm cancel " + outNumber);
+  emulator.runCmdWithCallback("gsm cancel " + outNumber);
 }
 
 function cleanUp() {
   finish();
 }
 
 startTest(function() {
   dial();
--- a/dom/telephony/test/marionette/test_redundant_operations.js
+++ b/dom/telephony/test/marionette/test_redundant_operations.js
@@ -15,23 +15,23 @@ function simulateIncoming() {
     incomingCall = event.call;
     ok(incomingCall);
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 function answerIncoming() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnectingIn(event) {
     log("Received 'connecting' call event for incoming call.");
@@ -43,17 +43,17 @@ function answerIncoming() {
   incomingCall.onconnected = function onconnectedIn(event) {
     log("Received 'connected' call event for incoming call.");
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       answerAlreadyConnected();
     });
   };
   incomingCall.answer();
 }
 
@@ -95,17 +95,17 @@ function hold() {
     is(incomingCall, event.call);
     is(incomingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : held");
       holdAlreadyHeld();
     });
   };
   incomingCall.hold();
 }
 
@@ -171,17 +171,17 @@ function resume() {
     is(incomingCall, event.call);
     is(incomingCall.state, "connected");
     ok(gotResuming);
 
     is(incomingCall, telephony.active);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : active");
       resumeNonHeld();
     });
   };
   incomingCall.resume();
 }
 
@@ -222,17 +222,17 @@ function hangUp() {
     log("Received 'disconnected' call event.");
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       answerDisconnected();
     });
   };
   incomingCall.hangUp();
 }
 
 function answerDisconnected() {
--- a/dom/telephony/test/marionette/test_swap_held_and_active.js
+++ b/dom/telephony/test/marionette/test_swap_held_and_active.js
@@ -24,17 +24,17 @@ function dial() {
       log("Received 'alerting' call event.");
 
       is(outgoingCall, event.call);
       is(outgoingCall.state, "alerting");
       is(outgoingCall, telephony.active);
       is(telephony.calls.length, 1);
       is(telephony.calls[0], outgoingCall);
 
-      emulator.runWithCallback("gsm list", function(result) {
+      emulator.runCmdWithCallback("gsm list", function(result) {
         log("Call list is now: " + result);
         is(result[0], "outbound to  " + outNumber + " : ringing");
         answer();
       });
     };
   });
 }
 
@@ -44,31 +44,31 @@ function answer() {
   // We get no "connecting" event when the remote party answers the call.
   outgoingCall.onconnected = function onconnectedOut(event) {
     log("Received 'connected' call event for the original outgoing call.");
 
     is(outgoingCall, event.call);
     is(outgoingCall.state, "connected");
     is(outgoingCall, telephony.active);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : active");
 
       if(!gotOriginalConnected){
         gotOriginalConnected = true;
         holdCall();
       } else {
         // Received connected event for original call multiple times (fail)
         ok(false,
            "Received 'connected' event for original call multiple times.");
       }
     });
   };
-  emulator.runWithCallback("gsm accept " + outNumber);
+  emulator.runCmdWithCallback("gsm accept " + outNumber);
 }
 
 function holdCall() {
   log("Putting the original (outgoing) call on hold.");
 
   let gotHolding = false;
   outgoingCall.onholding = function onholding(event) {
     log("Received 'holding' call event");
@@ -82,17 +82,17 @@ function holdCall() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "held");
     ok(gotHolding);
 
     is(telephony.active, null);
     is(telephony.calls.length, 1);
     is(telephony.calls[0], outgoingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       simulateIncoming();
     });
   };
   outgoingCall.hold();
 }
 
@@ -107,24 +107,24 @@ function simulateIncoming() {
     is(incomingCall.id.number, inNumber);
     is(incomingCall.state, "incoming");
 
     // Should be two calls now
     is(telephony.calls.length, 2);
     is(telephony.calls[0], outgoingCall);
     is(telephony.calls[1], incomingCall);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       is(result[1], "inbound from " + inNumber + " : incoming");
       answerIncoming();
     });
   };
-  emulator.runWithCallback("gsm call " + inNumber);
+  emulator.runCmdWithCallback("gsm call " + inNumber);
 }
 
 // Answer incoming call; original outgoing call should be held
 function answerIncoming() {
   log("Answering the incoming call.");
 
   let gotConnecting = false;
   incomingCall.onconnecting = function onconnectingIn(event) {
@@ -140,17 +140,17 @@ function answerIncoming() {
     ok(gotConnecting);
 
     is(incomingCall, telephony.active);
 
     // Original outbound call now held, incoming call active
     is(outgoingCall.state, "held");
     is(incomingCall.state, "connected");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "outbound to  " + outNumber + " : held");
       is(result[1], "inbound from " + inNumber + " : active");
       swapCalls();
     });
   };
   incomingCall.answer();
 }
@@ -193,17 +193,17 @@ function swapCalls() {
   outgoingCall.resume();
 }
 
 function verifySwap() {
   // Call status reflects swap
   is(outgoingCall.state, "connected");
   is(incomingCall.state, "held");
 
-  emulator.runWithCallback("gsm list", function(result) {
+  emulator.runCmdWithCallback("gsm list", function(result) {
     log("Call list is now: " + result);
     is(result[0], "outbound to  " + outNumber + " : active");
     is(result[1], "inbound from " + inNumber + " : held");
 
     // Begin hang-up
     hangUpOutgoing();
   });
 }
@@ -225,17 +225,17 @@ function hangUpOutgoing() {
     is(outgoingCall, event.call);
     is(outgoingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Back to one call now
     is(telephony.calls.length, 1);
     is(incomingCall.state, "held");
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       is(result[0], "inbound from " + inNumber + " : held");
       hangUpIncoming();
     });
   };
   outgoingCall.hangUp();
 }
 
@@ -256,17 +256,17 @@ function hangUpIncoming() {
     is(incomingCall, event.call);
     is(incomingCall.state, "disconnected");
     ok(gotDisconnecting);
 
     // Zero calls left
     is(telephony.active, null);
     is(telephony.calls.length, 0);
 
-    emulator.runWithCallback("gsm list", function(result) {
+    emulator.runCmdWithCallback("gsm list", function(result) {
       log("Call list is now: " + result);
       cleanUp();
     });
   };
   incomingCall.hangUp();
 }
 
 function cleanUp() {
--- a/gfx/layers/LayerScope.cpp
+++ b/gfx/layers/LayerScope.cpp
@@ -506,16 +506,17 @@ protected:
     GLuint mName;
     RefPtr<DataSourceSurface> mImage;
 };
 
 class DebugGLColorData : public DebugGLData {
 public:
     DebugGLColorData(void* layerRef, const gfxRGBA& color, int width, int height)
         : DebugGLData(DebugGLData::ColorData),
+          mLayerRef(layerRef),
           mColor(color.Packed()),
           mSize(width, height)
     { }
 
     void *GetLayerRef() const { return mLayerRef; }
     uint32_t GetColor() const { return mColor; }
     const nsIntSize& GetSize() const { return mSize; }
 
--- a/gfx/layers/basic/BasicThebesLayer.cpp
+++ b/gfx/layers/basic/BasicThebesLayer.cpp
@@ -114,17 +114,17 @@ BasicThebesLayer::PaintThebes(gfxContext
   gfxRect clipExtents;
   clipExtents = aContext->GetClipExtents();
 
   // Pull out the mask surface and transform here, because the mask
   // is internal to basic layers
   AutoMoz2DMaskData mask;
   SourceSurface* maskSurface = nullptr;
   Matrix maskTransform;
-  if (GetMaskData(aMaskLayer, Point(), &mask)) {
+  if (GetMaskData(aMaskLayer, aContext->GetDeviceOffset(), &mask)) {
     maskSurface = mask.GetSurface();
     maskTransform = mask.GetTransform();
   }
 
   if (!IsHidden() && !clipExtents.IsEmpty()) {
     mContentClient->DrawTo(this, aContext->GetDrawTarget(), opacity,
                            effectiveOperator,
                            maskSurface, &maskTransform);
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -121,72 +121,69 @@ gfxUserFontSet::~gfxUserFontSet()
 
 gfxFontEntry*
 gfxUserFontSet::AddFontFace(const nsAString& aFamilyName,
                             const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
                             uint32_t aWeight,
                             int32_t aStretch,
                             uint32_t aItalicStyle,
                             const nsTArray<gfxFontFeature>& aFeatureSettings,
-                            const nsString& aLanguageOverride,
+                            uint32_t aLanguageOverride,
                             gfxSparseBitSet *aUnicodeRanges)
 {
+    MOZ_ASSERT(aWeight != 0,
+               "aWeight must not be 0; use NS_FONT_WEIGHT_NORMAL instead");
+
     nsAutoString key(aFamilyName);
     ToLowerCase(key);
 
     bool found;
 
-    if (aWeight == 0)
-        aWeight = NS_FONT_WEIGHT_NORMAL;
-
     // stretch, italic/oblique ==> zero implies normal
 
     gfxMixedFontFamily *family = mFontFamilies.GetWeak(key, &found);
     if (!family) {
         family = new gfxMixedFontFamily(aFamilyName);
         mFontFamilies.Put(key, family);
     }
 
-    uint32_t languageOverride =
-        gfxFontStyle::ParseFontLanguageOverride(aLanguageOverride);
-
     // If there's already a proxy in the family whose descriptors all match,
     // we can just move it to the end of the list instead of adding a new
     // face that will always "shadow" the old one.
     // Note that we can't do this for "real" (non-proxy) entries, even if the
     // style descriptors match, as they might have had a different source list,
     // but we no longer have the old source list available to check.
     nsTArray<nsRefPtr<gfxFontEntry> >& fontList = family->GetFontList();
     for (uint32_t i = 0, count = fontList.Length(); i < count; i++) {
         if (!fontList[i]->mIsProxy) {
             continue;
         }
 
         gfxProxyFontEntry *existingProxyEntry =
             static_cast<gfxProxyFontEntry*>(fontList[i].get());
         if (!existingProxyEntry->Matches(aFontFaceSrcList,
                                          aWeight, aStretch, aItalicStyle,
-                                         aFeatureSettings, languageOverride,
+                                         aFeatureSettings, aLanguageOverride,
                                          aUnicodeRanges)) {
             continue;
         }
 
         // We've found an entry that matches the new face exactly, so just add
         // it to the end of the list. gfxMixedFontFamily::AddFontEntry() will
         // automatically remove any earlier occurrence of the same proxy.
         family->AddFontEntry(existingProxyEntry);
         return existingProxyEntry;
     }
 
     // construct a new face and add it into the family
     gfxProxyFontEntry *proxyEntry =
         new gfxProxyFontEntry(aFontFaceSrcList, aWeight, aStretch,
                               aItalicStyle,
                               aFeatureSettings,
-                              languageOverride,
+                              aLanguageOverride,
                               aUnicodeRanges);
     family->AddFontEntry(proxyEntry);
 #ifdef PR_LOGGING
     if (LOG_ENABLED()) {
         LOG(("userfonts (%p) added (%s) with style: %s weight: %d stretch: %d",
              this, NS_ConvertUTF16toUTF8(aFamilyName).get(),
              (aItalicStyle & NS_FONT_STYLE_ITALIC ? "italic" :
                  (aItalicStyle & NS_FONT_STYLE_OBLIQUE ? "oblique" : "normal")),
--- a/gfx/thebes/gfxUserFontSet.h
+++ b/gfx/thebes/gfxUserFontSet.h
@@ -162,27 +162,28 @@ public:
         STATUS_LOADED,
         STATUS_FORMAT_NOT_SUPPORTED,
         STATUS_ERROR,
         STATUS_END_OF_LIST
     };
 
 
     // add in a font face
-    // weight - 0 == unknown, [100, 900] otherwise (multiples of 100)
+    // weight - [100, 900] (multiples of 100)
     // stretch = [NS_FONT_STRETCH_ULTRA_CONDENSED, NS_FONT_STRETCH_ULTRA_EXPANDED]
     // italic style = constants in gfxFontConstants.h, e.g. NS_FONT_STYLE_NORMAL
+    // language override = result of calling gfxFontStyle::ParseFontLanguageOverride
     // TODO: support for unicode ranges not yet implemented
     gfxFontEntry *AddFontFace(const nsAString& aFamilyName,
                               const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
                               uint32_t aWeight,
                               int32_t aStretch,
                               uint32_t aItalicStyle,
                               const nsTArray<gfxFontFeature>& aFeatureSettings,
-                              const nsString& aLanguageOverride,
+                              uint32_t aLanguageOverride,
                               gfxSparseBitSet *aUnicodeRanges = nullptr);
 
     // add in a font face for which we have the gfxFontEntry already
     void AddFontFace(const nsAString& aFamilyName, gfxFontEntry* aFontEntry);
 
     // Whether there is a face with this family name
     bool HasFamily(const nsAString& aFamilyName) const
     {
--- a/layout/base/nsBidi.cpp
+++ b/layout/base/nsBidi.cpp
@@ -1447,30 +1447,29 @@ nsresult nsBidi::GetVisualRun(int32_t aR
  */
 bool nsBidi::GetRuns()
 {
   if(mDirection!=NSBIDI_MIXED) {
     /* simple, single-run case - this covers length==0 */
     GetSingleRun(mParaLevel);
   } else /* NSBIDI_MIXED, length>0 */ {
     /* mixed directionality */
-    int32_t length=mLength, limit=length;
+    int32_t length=mLength, limit=mTrailingWSStart;
 
     /*
      * If there are WS characters at the end of the line
      * and the run preceding them has a level different from
      * paraLevel, then they will form their own run at paraLevel (L1).
      * Count them separately.
      * We need some special treatment for this in order to not
      * modify the levels array which a line nsBidi object shares
      * with its paragraph parent and its other line siblings.
      * In other words, for the trailing WS, it may be
      * levels[]!=paraLevel but we have to treat it like it were so.
      */
-    limit=mTrailingWSStart;
     if(limit==0) {
       /* there is only WS on this line */
       GetSingleRun(mParaLevel);
     } else {
       nsBidiLevel *levels=mLevels;
       int32_t i, runCount;
       nsBidiLevel level=NSBIDI_DEFAULT_LTR;   /* initialize with no valid level */
 
deleted file mode 100644
--- a/layout/reftests/font-inflation/disable-fontinfl-on-mobile-4.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!--
-Without the patch for bug 706198, this website should not show up as inflated. That means
-that with a 450px container, the minimum font size with 15em per line should be 30px.
-So, we map 0px-45px into 30px-45px, and thus 12px gets mapped to 34px.
-
-With the patch, the text should be uninflated, which means that 12px should still be
-12px.
--->
-<!DOCTYPE html>
-<html>
-  <head>
-    <meta name="viewport" content="width=320"/>
-    <style>
-      p { font-size: 12px; line-height: 1.0;}
-    </style>
-    <body>
-      <p>Some uninflated text.</p>
-    </body>
-  </head>
-</html>
--- a/layout/reftests/font-inflation/reftest.list
+++ b/layout/reftests/font-inflation/reftest.list
@@ -50,17 +50,16 @@ test-pref(font.size.inflation.emPerLine,
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == select-combobox-2.html select-combobox-2-ref.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) != select-combobox-2.html select-combobox-2.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == select-combobox-3.html select-combobox-3-ref.html
 asserts-if(gtk2Widget,0-4) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) != input-checkbox.html input-checkbox.html
 asserts-if(gtk2Widget,0-4) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) != input-radio.html input-radio.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == disable-fontinfl-on-mobile.html disable-fontinfl-on-mobile-ref.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == disable-fontinfl-on-mobile-2.html disable-fontinfl-on-mobile-ref.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == disable-fontinfl-on-mobile-3.html disable-fontinfl-on-mobile-ref.html
-test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == disable-fontinfl-on-mobile-4.html disable-fontinfl-on-mobile-ref.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) != disable-fontinfl-on-mobile-5.html disable-fontinfl-on-mobile-ref.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == preformatted-text.html preformatted-text-ref.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == fixed-height-body.html fixed-height-body-ref.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == fixed-height-body-child.html fixed-height-body-child-ref.html
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == consecutive-inline.html consecutive-inline-ref.html
 
 # The tests below use nonzero values of the lineThreshold preference.
 test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,100) == text-1.html text-1.html
--- a/layout/style/nsFontFaceLoader.cpp
+++ b/layout/style/nsFontFaceLoader.cpp
@@ -566,23 +566,26 @@ nsUserFontSet::InsertRule(nsCSSFontFaceR
     }
   }
 
   // this is a new rule:
 
   uint32_t weight = NS_STYLE_FONT_WEIGHT_NORMAL;
   int32_t stretch = NS_STYLE_FONT_STRETCH_NORMAL;
   uint32_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL;
-  nsString languageOverride;
+  uint32_t languageOverride = NO_FONT_LANGUAGE_OVERRIDE;
 
   // set up weight
   aRule->GetDesc(eCSSFontDesc_Weight, val);
   unit = val.GetUnit();
   if (unit == eCSSUnit_Integer || unit == eCSSUnit_Enumerated) {
     weight = val.GetIntValue();
+    if (weight == 0) {
+      weight = NS_STYLE_FONT_STYLE_NORMAL;
+    }
   } else if (unit == eCSSUnit_Normal) {
     weight = NS_STYLE_FONT_WEIGHT_NORMAL;
   } else {
     NS_ASSERTION(unit == eCSSUnit_Null,
                  "@font-face weight has unexpected unit");
   }
 
   // set up stretch
@@ -623,17 +626,19 @@ nsUserFontSet::InsertRule(nsCSSFontFaceR
   }
 
   // set up font language override
   aRule->GetDesc(eCSSFontDesc_FontLanguageOverride, val);
   unit = val.GetUnit();
   if (unit == eCSSUnit_Normal) {
     // empty feature string
   } else if (unit == eCSSUnit_String) {
-    val.GetStringValue(languageOverride);
+    nsString stringValue;
+    val.GetStringValue(stringValue);
+    languageOverride = gfxFontStyle::ParseFontLanguageOverride(stringValue);
   } else {
     NS_ASSERTION(unit == eCSSUnit_Null,
                  "@font-face font-language-override has unexpected unit");
   }
 
   // set up src array
   nsTArray<gfxFontFaceSrc> srcArray;
 
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
@@ -118,17 +118,22 @@ WebrtcGmpVideoEncoder::InitEncode(const 
 int32_t
 WebrtcGmpVideoEncoder::InitEncode_g(const webrtc::VideoCodec* aCodecSettings,
                                     int32_t aNumberOfCores,
                                     uint32_t aMaxPayloadSize)
 {
   GMPVideoHost* host = nullptr;
   GMPVideoEncoder* gmp = nullptr;
 
-  nsresult rv = mMPS->GetGMPVideoEncoderVP8(&host, &gmp);
+  nsTArray<nsCString> tags;
+  tags.AppendElement(NS_LITERAL_CSTRING("vp8"));
+  nsresult rv = mMPS->GetGMPVideoEncoder(&tags,
+                                         NS_LITERAL_STRING(""),
+                                         &host,
+                                         &gmp);
   if (NS_FAILED(rv)) {
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
 
   mGMP = gmp;
   mHost = host;
 
   if (!gmp || !host) {
@@ -453,18 +458,22 @@ WebrtcGmpVideoDecoder::InitDecode(const 
 
 int32_t
 WebrtcGmpVideoDecoder::InitDecode_g(const webrtc::VideoCodec* aCodecSettings,
                                     int32_t aNumberOfCores)
 {
   GMPVideoHost* host = nullptr;
   GMPVideoDecoder* gmp = nullptr;
 
-  if (NS_WARN_IF(NS_FAILED(mMPS->GetGMPVideoDecoderVP8(&host, &gmp))))
-  {
+  nsTArray<nsCString> tags;
+  tags.AppendElement(NS_LITERAL_CSTRING("vp8"));
+  if (NS_WARN_IF(NS_FAILED(mMPS->GetGMPVideoDecoder(&tags,
+                                                    NS_LITERAL_STRING(""),
+                                                    &host,
+                                                    &gmp)))) {
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
 
   mGMP = gmp;
   mHost = host;
   if (!gmp || !host) {
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
--- a/mobile/android/chrome/content/aboutDownloads.js
+++ b/mobile/android/chrome/content/aboutDownloads.js
@@ -413,21 +413,21 @@ let Downloads = {
     }
   },
 
   getDownloads: function dl_getDownloads(aParams) {
     aParams = aParams || {};
     let stmt = this._initStatement(aParams.isPrivate);
 
     stmt.reset();
-    stmt.bindInt32Parameter(0, Ci.nsIDownloadManager.DOWNLOAD_NOTSTARTED);
-    stmt.bindInt32Parameter(1, Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING);
-    stmt.bindInt32Parameter(2, Ci.nsIDownloadManager.DOWNLOAD_PAUSED);
-    stmt.bindInt32Parameter(3, Ci.nsIDownloadManager.DOWNLOAD_QUEUED);
-    stmt.bindInt32Parameter(4, Ci.nsIDownloadManager.DOWNLOAD_SCANNING);
+    stmt.bindByIndex(0, Ci.nsIDownloadManager.DOWNLOAD_NOTSTARTED);
+    stmt.bindByIndex(1, Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING);
+    stmt.bindByIndex(2, Ci.nsIDownloadManager.DOWNLOAD_PAUSED);
+    stmt.bindByIndex(3, Ci.nsIDownloadManager.DOWNLOAD_QUEUED);
+    stmt.bindByIndex(4, Ci.nsIDownloadManager.DOWNLOAD_SCANNING);
 
     let entries = [];
     while (entry = this._getEntry(stmt)) {
       entries.push(entry);
     }
 
     stmt.finalize();
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -7037,17 +7037,17 @@ var SearchEngines = {
     if (!Services.prompt.prompt(null, promptTitle, null, title, null, {}))
       return;
 
     // fetch the favicon for this page
     let dbFile = FileUtils.getFile("ProfD", ["browser.db"]);
     let mDBConn = Services.storage.openDatabase(dbFile);
     let stmts = [];
     stmts[0] = mDBConn.createStatement("SELECT favicon FROM history_with_favicons WHERE url = ?");
-    stmts[0].bindStringParameter(0, docURI.spec);
+    stmts[0].bindByIndex(0, docURI.spec);
     let favicon = null;
     Services.search.init(function addEngine_cb(rv) {
       if (!Components.isSuccessCode(rv)) {
         Cu.reportError("Could not initialize search service, bailing out.");
         return;
       }
       mDBConn.executeAsync(stmts, stmts.length, {
         handleResult: function (results) {
--- a/mobile/android/modules/Sanitizer.jsm
+++ b/mobile/android/modules/Sanitizer.jsm
@@ -22,22 +22,22 @@ this.EXPORTED_SYMBOLS = ["Sanitizer"];
 let downloads = {
   dlmgr: Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager),
 
   iterate: function (aCallback) {
     let dlmgr = downloads.dlmgr;
     let dbConn = dlmgr.DBConnection;
     let stmt = dbConn.createStatement("SELECT id FROM moz_downloads WHERE " +
         "state = ? OR state = ? OR state = ? OR state = ? OR state = ? OR state = ?");
-    stmt.bindInt32Parameter(0, Ci.nsIDownloadManager.DOWNLOAD_FINISHED);
-    stmt.bindInt32Parameter(1, Ci.nsIDownloadManager.DOWNLOAD_FAILED);
-    stmt.bindInt32Parameter(2, Ci.nsIDownloadManager.DOWNLOAD_CANCELED);
-    stmt.bindInt32Parameter(3, Ci.nsIDownloadManager.DOWNLOAD_BLOCKED_PARENTAL);
-    stmt.bindInt32Parameter(4, Ci.nsIDownloadManager.DOWNLOAD_BLOCKED_POLICY);
-    stmt.bindInt32Parameter(5, Ci.nsIDownloadManager.DOWNLOAD_DIRTY);
+    stmt.bindByIndex(0, Ci.nsIDownloadManager.DOWNLOAD_FINISHED);
+    stmt.bindByIndex(1, Ci.nsIDownloadManager.DOWNLOAD_FAILED);
+    stmt.bindByIndex(2, Ci.nsIDownloadManager.DOWNLOAD_CANCELED);
+    stmt.bindByIndex(3, Ci.nsIDownloadManager.DOWNLOAD_BLOCKED_PARENTAL);
+    stmt.bindByIndex(4, Ci.nsIDownloadManager.DOWNLOAD_BLOCKED_POLICY);
+    stmt.bindByIndex(5, Ci.nsIDownloadManager.DOWNLOAD_DIRTY);
     while (stmt.executeStep()) {
       aCallback(dlmgr.getDownload(stmt.row.id));
     }
     stmt.finalize();
   },
 
   get canClear() {
     return this.dlmgr.canCleanUp;
--- a/security/build/nss.def
+++ b/security/build/nss.def
@@ -184,16 +184,17 @@ NSS_CMSDecoder_Update
 NSS_CMSEncoder_Cancel
 NSS_CMSEncoder_Finish
 NSS_CMSEncoder_Start
 NSS_CMSEncoder_Update
 NSS_CMSEnvelopedData_AddRecipient
 NSS_CMSEnvelopedData_Create
 NSS_CMSEnvelopedData_GetContentInfo
 NSS_CMSMessage_ContentLevel
+NSS_CMSMessage_ContentLevelCount
 NSS_CMSMessage_Create
 NSS_CMSMessage_CreateFromDER
 NSS_CMSMessage_Destroy
 NSS_CMSMessage_GetContent
 NSS_CMSMessage_GetContentInfo
 NSS_CMSMessage_IsEncrypted
 NSS_CMSMessage_IsSigned
 NSS_CMSRecipientInfo_Create
--- a/toolkit/mozapps/downloads/tests/chrome/test_bug_412360.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_bug_412360.xul
@@ -81,30 +81,30 @@ function test()
   db.executeSimpleSQL("DELETE FROM moz_downloads");
 
   let stmt = db.createStatement(
     "INSERT INTO moz_downloads (source, target, state, endTime) " +
     "VALUES (?1, ?2, ?3, ?4)");
 
   try {
     // Saving javascript URIs doesn't work
-    stmt.bindStringParameter(0, "javascript:5");
+    stmt.bindByIndex(0, "javascript:5");
 
     // Download to a temp local file
     file = Cc["@mozilla.org/file/directory_service;1"].
            getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
     file.append("javascriptURI");
     file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
-    stmt.bindStringParameter(1, Cc["@mozilla.org/network/io-service;1"].
+    stmt.bindByIndex(1, Cc["@mozilla.org/network/io-service;1"].
       getService(Ci.nsIIOService).newFileURI(file).spec);
 
     // Start it as canceled
-    stmt.bindInt32Parameter(2, dm.DOWNLOAD_CANCELED);
+    stmt.bindByIndex(2, dm.DOWNLOAD_CANCELED);
 
-    stmt.bindInt32Parameter(3, Date.now() * 1000);
+    stmt.bindByIndex(3, Date.now() * 1000);
 
     // Add it!
     stmt.execute();
   }
   finally {
     stmt.finalize();
   }
 
--- a/toolkit/mozapps/downloads/tests/chrome/test_cleanup_search.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_cleanup_search.xul
@@ -45,20 +45,20 @@ function test()
                  getService(Ci.nsIIOService).newFileURI(file).spec;
 
   let stmt = db.createStatement(
     "INSERT INTO moz_downloads (name, target, source, state) " +
     "VALUES (?1, ?2, ?3, ?4)");
 
   try {
     for each (let site in ["delete.me", "i.live"]) {
-      stmt.bindStringParameter(0, "Super Pimped Download");
-      stmt.bindStringParameter(1, filePath);
-      stmt.bindStringParameter(2, "http://" + site + "/file");
-      stmt.bindInt32Parameter(3, dm.DOWNLOAD_FINISHED);
+      stmt.bindByIndex(0, "Super Pimped Download");
+      stmt.bindByIndex(1, filePath);
+      stmt.bindByIndex(2, "http://" + site + "/file");
+      stmt.bindByIndex(3, dm.DOWNLOAD_FINISHED);
 
       // Add it!
       stmt.execute();
     }
   }
   finally {
     stmt.reset();
     stmt.finalize();
--- a/toolkit/mozapps/downloads/tests/chrome/test_multi_select.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_multi_select.xul
@@ -44,20 +44,20 @@ function test()
   try {
     for each (let site in ["ed.agadak.net", "mozilla.org", "mozilla.com", "mozilla.net"]) {
       let file = Cc["@mozilla.org/file/directory_service;1"].
         getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
       file.append(site);
       let fileSpec = Cc["@mozilla.org/network/io-service;1"].
         getService(Ci.nsIIOService).newFileURI(file).spec;
 
-      stmt.bindStringParameter(0, "http://" + site + "/file");
-      stmt.bindInt32Parameter(1, dm.DOWNLOAD_FINISHED);
-      stmt.bindStringParameter(2, fileSpec);
-      stmt.bindStringParameter(3, "http://referrer/");
+      stmt.bindByIndex(0, "http://" + site + "/file");
+      stmt.bindByIndex(1, dm.DOWNLOAD_FINISHED);
+      stmt.bindByIndex(2, fileSpec);
+      stmt.bindByIndex(3, "http://referrer/");
 
       // Add it!
       stmt.execute();
     }
   }
   finally {
     stmt.reset();
     stmt.finalize();
--- a/toolkit/mozapps/downloads/tests/chrome/test_multiword_search.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_multiword_search.xul
@@ -43,22 +43,22 @@ function test()
                  getService(Ci.nsIIOService).newFileURI(file).spec;
 
   let stmt = db.createStatement(
     "INSERT INTO moz_downloads (name, target, source, state, endTime, maxBytes) " +
     "VALUES (?1, ?2, ?3, ?4, ?5, ?6)");
 
   try {
     for each (let site in ["ed.agadak.net", "mozilla.org"]) {
-      stmt.bindStringParameter(0, "Super Pimped Download");
-      stmt.bindStringParameter(1, filePath);
-      stmt.bindStringParameter(2, "http://" + site + "/file");
-      stmt.bindInt32Parameter(3, dm.DOWNLOAD_FINISHED);
-      stmt.bindInt64Parameter(4, new Date(1985, 7, 2) * 1000);
-      stmt.bindInt64Parameter(5, 111222333444);
+      stmt.bindByIndex(0, "Super Pimped Download");
+      stmt.bindByIndex(1, filePath);
+      stmt.bindByIndex(2, "http://" + site + "/file");
+      stmt.bindByIndex(3, dm.DOWNLOAD_FINISHED);
+      stmt.bindByIndex(4, new Date(1985, 7, 2) * 1000);
+      stmt.bindByIndex(5, 111222333444);
 
       // Add it!
       stmt.execute();
     }
   } finally {
     stmt.reset();
     stmt.finalize();
   }
--- a/toolkit/mozapps/downloads/tests/chrome/test_search_clearlist.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_search_clearlist.xul
@@ -51,21 +51,21 @@ function test()
     sites.push("i-hate.clear-list-" + i);
 
   // Add one download that matches the search
   let searchTerm = "one-download.match-search";
   sites.push(searchTerm);
 
   try {
     for each (let site in sites) {
-      stmt.bindStringParameter(0, filePath);
-      stmt.bindStringParameter(1, "http://" + site + "/file");
-      stmt.bindInt32Parameter(2, dm.DOWNLOAD_FINISHED);
+      stmt.bindByIndex(0, filePath);
+      stmt.bindByIndex(1, "http://" + site + "/file");
+      stmt.bindByIndex(2, dm.DOWNLOAD_FINISHED);
       // Make the one that matches slightly older so it appears last
-      stmt.bindInt64Parameter(3, 1112223334445556 - (site == searchTerm));
+      stmt.bindByIndex(3, 1112223334445556 - (site == searchTerm));
 
       // Add it!
       stmt.execute();
     }
   }
   finally {
     stmt.reset();
     stmt.finalize();
--- a/toolkit/mozapps/downloads/tests/chrome/test_select_all.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_select_all.xul
@@ -45,19 +45,19 @@ function test()
 
   let stmt = db.createStatement(
     "INSERT INTO moz_downloads (target, source, state) " +
     "VALUES (?1, ?2, ?3)");
 
   let sites = ["mozilla.org", "mozilla.com", "select.all"];
   try {
     for each (let site in sites) {
-      stmt.bindStringParameter(0, filePath);
-      stmt.bindStringParameter(1, "http://" + site + "/file");
-      stmt.bindInt32Parameter(2, dm.DOWNLOAD_FINISHED);
+      stmt.bindByIndex(0, filePath);
+      stmt.bindByIndex(1, "http://" + site + "/file");
+      stmt.bindByIndex(2, dm.DOWNLOAD_FINISHED);
 
       // Add it!
       stmt.execute();
     }
   }
   finally {
     stmt.reset();
     stmt.finalize();