Bug 1169504 - Wait for icc status to finish updating when enabling/disabling radio power. r=hsinyi
authorEdgar Chen <echen@mozilla.com>
Mon, 01 Jun 2015 14:35:16 +0800
changeset 269603 a1c63bd7e0b94f21019fd3134f6885716b182f19
parent 269602 04fd9b897dcd71f0eab37608708134f945a2b579
child 269604 fa0c93ed6885ee3a4b7263f6568392f46480c733
push id2540
push userwcosta@mozilla.com
push dateWed, 03 Jun 2015 20:55:41 +0000
reviewershsinyi
bugs1169504
milestone41.0a1
Bug 1169504 - Wait for icc status to finish updating when enabling/disabling radio power. r=hsinyi
dom/telephony/test/marionette/head.js
--- a/dom/telephony/test/marionette/head.js
+++ b/dom/telephony/test/marionette/head.js
@@ -1102,22 +1102,29 @@ let emulator = (function() {
     log("Set radio: " + desiredRadioState);
 
     if (connection.radioState === desiredRadioState) {
       return Promise.resolve();
     }
 
     let promises = [];
 
-    let promise = gWaitForEvent(connection, "radiostatechange", event => {
+    promises.push(gWaitForEvent(connection, "radiostatechange", event => {
       let state = connection.radioState;
       log("current radioState: " + state);
       return state == desiredRadioState;
-    });
-    promises.push(promise);
+    }));
+
+    // Wait for icc status to finish updating. Please see bug 1169504 for the
+    // reason why we need this.
+    promises.push(gWaitForEvent(connection, "iccchange", event => {
+      let iccId = connection.iccId;
+      log("current iccId: " + iccId);
+      return !!iccId === enabled;
+    }));
 
     promises.push(connection.setRadioEnabled(enabled));
 
     return Promise.all(promises);
   }
 
   function setRadioEnabledAll(enabled) {
     let promises = [];