Bug 1203425 - [Cellbroadcast] Split test_cellbroadcast_{gsm|umts}.js into smaller tests. r=bevis
authorEdgar Chen <echen@mozilla.com>
Thu, 09 Oct 2014 18:11:16 +0800
changeset 294273 f3ce28ac55cfe371c919eabb485ae7d893d342e2
parent 294272 295432fe36689de5f321914899e21ec3d497ecd4
child 294274 c069293a2e46569d6290c26f58f336119d1faa9b
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbevis
bugs1203425
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203425 - [Cellbroadcast] Split test_cellbroadcast_{gsm|umts}.js into smaller tests. r=bevis
dom/cellbroadcast/tests/marionette/head.js
dom/cellbroadcast/tests/marionette/manifest.ini
dom/cellbroadcast/tests/marionette/test_cellbroadcast_etws.js
dom/cellbroadcast/tests/marionette/test_cellbroadcast_gsm.js
dom/cellbroadcast/tests/marionette/test_cellbroadcast_gsm_language_and_body.js
dom/cellbroadcast/tests/marionette/test_cellbroadcast_multi_sim.js
dom/cellbroadcast/tests/marionette/test_cellbroadcast_umts.js
dom/cellbroadcast/tests/marionette/test_cellbroadcast_umts_language_and_body.js
--- a/dom/cellbroadcast/tests/marionette/head.js
+++ b/dom/cellbroadcast/tests/marionette/head.js
@@ -34,16 +34,19 @@ GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CL
 GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_SIM_SPECIFIC] = "class-2";
 GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_TE_SPECIFIC]  = "class-3";
 GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_USER_1]       = "user-1";
 GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_USER_2]       = "user-2";
 
 const CB_MESSAGE_SIZE_GSM  = 88;
 const CB_MESSAGE_SIZE_ETWS = 56;
 
+const CB_UMTS_MESSAGE_TYPE_CBS = 1;
+const CB_UMTS_MESSAGE_PAGE_SIZE = 82;
+
 const CB_GSM_MESSAGEID_ETWS_BEGIN = 0x1100;
 const CB_GSM_MESSAGEID_ETWS_END   = 0x1107;
 
 const CB_GSM_GEOGRAPHICAL_SCOPE_NAMES = [
   "cell-immediate",
   "plmn",
   "location-area",
   "cell"
@@ -196,28 +199,38 @@ function ensureCellBroadcast() {
   let permissions = [{
     "type": "cellbroadcast",
     "allow": 1,
     "context": document,
   }];
   SpecialPowers.pushPermissions(permissions, function() {
     ok(true, "permissions pushed: " + JSON.stringify(permissions));
 
-    cbManager = window.navigator.mozCellBroadcast;
-    if (cbManager) {
-      log("navigator.mozCellBroadcast is instance of " + cbManager.constructor);
-    } else {
-      log("navigator.mozCellBroadcast is undefined.");
-    }
+    // Permission changes can't change existing Navigator.prototype
+    // objects, so grab our objects from a new Navigator.
+    let workingFrame = document.createElement("iframe");
+    workingFrame.addEventListener("load", function load() {
+      workingFrame.removeEventListener("load", load);
+
+      cbManager = workingFrame.contentWindow.navigator.mozCellBroadcast;
 
-    if (cbManager instanceof window.MozCellBroadcast) {
-      deferred.resolve(cbManager);
-    } else {
-      deferred.reject();
-    }
+      if (cbManager) {
+        log("navigator.mozCellBroadcast is instance of " + cbManager.constructor);
+      } else {
+        log("navigator.mozCellBroadcast is undefined.");
+      }
+
+      if (cbManager instanceof window.MozCellBroadcast) {
+        deferred.resolve(cbManager);
+      } else {
+        deferred.reject();
+      }
+    });
+
+    document.body.appendChild(workingFrame);
   });
 
   return deferred.promise;
 }
 
 /**
  * Send emulator command with safe guard.
  *
--- a/dom/cellbroadcast/tests/marionette/manifest.ini
+++ b/dom/cellbroadcast/tests/marionette/manifest.ini
@@ -1,9 +1,11 @@
 [DEFAULT]
 b2g = true
 browser = false
 qemu = true
 
 [test_cellbroadcast_etws.js]
 [test_cellbroadcast_gsm.js]
+[test_cellbroadcast_gsm_language_and_body.js]
 [test_cellbroadcast_multi_sim.js]
-[test_cellbroadcast_umts.js]
\ No newline at end of file
+[test_cellbroadcast_umts.js]
+[test_cellbroadcast_umts_language_and_body.js]
\ No newline at end of file
--- a/dom/cellbroadcast/tests/marionette/test_cellbroadcast_etws.js
+++ b/dom/cellbroadcast/tests/marionette/test_cellbroadcast_etws.js
@@ -1,12 +1,12 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-MARIONETTE_TIMEOUT = 20000;
+MARIONETTE_TIMEOUT = 60000;
 MARIONETTE_HEAD_JS = 'head.js';
 
 function testReceiving_ETWS_MessageAttributes() {
   log("Test receiving ETWS Primary Notification - Message Attributes");
 
   let verifyCBMessage = (aMessage) => {
     // Attributes other than `language` and `body` should always be assigned.
     ok(aMessage.gsmGeographicalScope != null, "aMessage.gsmGeographicalScope");
--- a/dom/cellbroadcast/tests/marionette/test_cellbroadcast_gsm.js
+++ b/dom/cellbroadcast/tests/marionette/test_cellbroadcast_gsm.js
@@ -105,72 +105,16 @@ function testReceiving_GSM_MessageId() {
     promise = promise
       .then(() => sendMultipleRawCbsToEmulatorAndWait([pdu]))
       .then((aMessage) => verifyCBMessage(aMessage, aMessageId));
   });
 
   return promise;
 }
 
-function testReceiving_GSM_Language_and_Body() {
-  log("Test receiving GSM Cell Broadcast - Language & Body");
-
-  let promise = Promise.resolve();
-
-  let testDcs = [];
-  let dcs = 0;
-  while (dcs <= 0xFF) {
-    try {
-      let dcsInfo = { dcs: dcs };
-      [ dcsInfo.encoding, dcsInfo.language,
-        dcsInfo.indicator, dcsInfo.messageClass ] = decodeGsmDataCodingScheme(dcs);
-      testDcs.push(dcsInfo);
-    } catch (e) {
-      // Unsupported coding group, skip.
-      dcs = (dcs & PDU_DCS_CODING_GROUP_BITS) + 0x10;
-    }
-    dcs++;
-  }
-
-  let verifyCBMessage = (aMessage, aDcsInfo) => {
-    if (aDcsInfo.language) {
-      is(aMessage.language, aDcsInfo.language, "aMessage.language");
-    } else if (aDcsInfo.indicator) {
-      is(aMessage.language, "@@", "aMessage.language");
-    } else {
-      ok(aMessage.language == null, "aMessage.language");
-    }
-
-    switch (aDcsInfo.encoding) {
-      case PDU_DCS_MSG_CODING_7BITS_ALPHABET:
-        is(aMessage.body, aDcsInfo.indicator ? DUMMY_BODY_7BITS_IND : DUMMY_BODY_7BITS, "aMessage.body");
-        break;
-      case PDU_DCS_MSG_CODING_8BITS_ALPHABET:
-        ok(aMessage.body == null, "aMessage.body");
-        break;
-      case PDU_DCS_MSG_CODING_16BITS_ALPHABET:
-        is(aMessage.body, aDcsInfo.indicator ? DUMMY_BODY_UCS2_IND : DUMMY_BODY_UCS2, "aMessage.body");
-        break;
-    }
-
-    is(aMessage.messageClass, aDcsInfo.messageClass, "aMessage.messageClass");
-  };
-
-  testDcs.forEach(function(aDcsInfo) {
-    let pdu = buildHexStr(0, 8)
-            + buildHexStr(aDcsInfo.dcs, 2)
-            + buildHexStr(0, (CB_MESSAGE_SIZE_GSM - 5) * 2);
-    promise = promise
-      .then(() => sendMultipleRawCbsToEmulatorAndWait([pdu]))
-      .then((aMessage) => verifyCBMessage(aMessage, aDcsInfo));
-  });
-
-  return promise;
-}
-
 function testReceiving_GSM_Timestamp() {
   log("Test receiving GSM Cell Broadcast - Timestamp");
 
   let verifyCBMessage = (aMessage) => {
     // Cell Broadcast messages do not contain a timestamp field (however, ETWS
     // does). We only check the timestamp doesn't go too far (60 seconds) here.
     let msMessage = aMessage.timestamp;
     let msNow = Date.now();
@@ -346,16 +290,15 @@ function testReceiving_GSM_PaddingCharac
   return promise;
 }
 
 startTestCommon(function testCaseMain() {
   return testReceiving_GSM_MessageAttributes()
     .then(() => testReceiving_GSM_GeographicalScope())
     .then(() => testReceiving_GSM_MessageCode())
     .then(() => testReceiving_GSM_MessageId())
-    .then(() => testReceiving_GSM_Language_and_Body())
     .then(() => testReceiving_GSM_Timestamp())
     .then(() => testReceiving_GSM_WarningType())
     .then(() => testReceiving_GSM_EmergencyUserAlert())
     .then(() => testReceiving_GSM_Popup())
     .then(() => testReceiving_GSM_Multipart())
     .then(() => testReceiving_GSM_PaddingCharacters());
 });
new file mode 100644
--- /dev/null
+++ b/dom/cellbroadcast/tests/marionette/test_cellbroadcast_gsm_language_and_body.js
@@ -0,0 +1,64 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 90000;
+MARIONETTE_HEAD_JS = 'head.js';
+
+function testReceiving_GSM_Language_and_Body() {
+  log("Test receiving GSM Cell Broadcast - Language & Body");
+
+  let promise = Promise.resolve();
+
+  let testDcs = [];
+  let dcs = 0;
+  while (dcs <= 0xFF) {
+    try {
+      let dcsInfo = { dcs: dcs };
+      [ dcsInfo.encoding, dcsInfo.language,
+        dcsInfo.indicator, dcsInfo.messageClass ] = decodeGsmDataCodingScheme(dcs);
+      testDcs.push(dcsInfo);
+    } catch (e) {
+      // Unsupported coding group, skip.
+      dcs = (dcs & PDU_DCS_CODING_GROUP_BITS) + 0x10;
+    }
+    dcs++;
+  }
+
+  let verifyCBMessage = (aMessage, aDcsInfo) => {
+    if (aDcsInfo.language) {
+      is(aMessage.language, aDcsInfo.language, "aMessage.language");
+    } else if (aDcsInfo.indicator) {
+      is(aMessage.language, "@@", "aMessage.language");
+    } else {
+      ok(aMessage.language == null, "aMessage.language");
+    }
+
+    switch (aDcsInfo.encoding) {
+      case PDU_DCS_MSG_CODING_7BITS_ALPHABET:
+        is(aMessage.body, aDcsInfo.indicator ? DUMMY_BODY_7BITS_IND : DUMMY_BODY_7BITS, "aMessage.body");
+        break;
+      case PDU_DCS_MSG_CODING_8BITS_ALPHABET:
+        ok(aMessage.body == null, "aMessage.body");
+        break;
+      case PDU_DCS_MSG_CODING_16BITS_ALPHABET:
+        is(aMessage.body, aDcsInfo.indicator ? DUMMY_BODY_UCS2_IND : DUMMY_BODY_UCS2, "aMessage.body");
+        break;
+    }
+
+    is(aMessage.messageClass, aDcsInfo.messageClass, "aMessage.messageClass");
+  };
+
+  ok(testDcs.length, "testDcs.length");
+  testDcs.forEach(function(aDcsInfo) {
+    let pdu = buildHexStr(0, 8)
+            + buildHexStr(aDcsInfo.dcs, 2)
+            + buildHexStr(0, (CB_MESSAGE_SIZE_GSM - 5) * 2);
+    promise = promise
+      .then(() => sendMultipleRawCbsToEmulatorAndWait([pdu]))
+      .then((aMessage) => verifyCBMessage(aMessage, aDcsInfo));
+  });
+
+  return promise;
+}
+
+startTestCommon(() => testReceiving_GSM_Language_and_Body());
--- a/dom/cellbroadcast/tests/marionette/test_cellbroadcast_multi_sim.js
+++ b/dom/cellbroadcast/tests/marionette/test_cellbroadcast_multi_sim.js
@@ -1,12 +1,12 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-MARIONETTE_TIMEOUT = 10000;
+MARIONETTE_TIMEOUT = 60000;
 MARIONETTE_HEAD_JS = 'head.js';
 
 function testReceiving_MultiSIM() {
   log("Test receiving GSM Cell Broadcast - Multi-SIM");
 
   let pdu = buildHexStr(0, CB_MESSAGE_SIZE_GSM * 2);
 
   let verifyCBMessage = (aMessage, aServiceId) => {
--- a/dom/cellbroadcast/tests/marionette/test_cellbroadcast_umts.js
+++ b/dom/cellbroadcast/tests/marionette/test_cellbroadcast_umts.js
@@ -1,14 +1,14 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
 MARIONETTE_TIMEOUT = 90000;
 MARIONETTE_HEAD_JS = 'head.js';
 
-const CB_UMTS_MESSAGE_TYPE_CBS = 1;
-const CB_UMTS_MESSAGE_PAGE_SIZE = 82;
-
 function testReceiving_UMTS_MessageAttributes() {
   log("Test receiving UMTS Cell Broadcast - Message Attributes");
 
   let verifyCBMessage = (aMessage) => {
     // Attributes other than `language` , `body` and `data` should always be assigned.
     ok(aMessage.gsmGeographicalScope != null, "aMessage.gsmGeographicalScope");
     ok(aMessage.messageCode != null, "aMessage.messageCode");
     ok(aMessage.messageId != null, "aMessage.messageId");
@@ -121,80 +121,16 @@ function testReceiving_UMTS_MessageId() 
     promise = promise
       .then(() => sendMultipleRawCbsToEmulatorAndWait([pdu]))
       .then((aMessage) => verifyCBMessage(aMessage, aMessageId));
   });
 
   return promise;
 }
 
-function testReceiving_UMTS_Language_and_Body() {
-  log("Test receiving UMTS Cell Broadcast - Language & Body");
-
-  let promise = Promise.resolve();
-
-  let testDcs = [];
-  let dcs = 0;
-  while (dcs <= 0xFF) {
-    try {
-      let dcsInfo = { dcs: dcs };
-      [ dcsInfo.encoding, dcsInfo.language,
-        dcsInfo.indicator, dcsInfo.messageClass ] = decodeGsmDataCodingScheme(dcs);
-      testDcs.push(dcsInfo);
-    } catch (e) {
-      // Unsupported coding group, skip.
-      dcs = (dcs & PDU_DCS_CODING_GROUP_BITS) + 0x10;
-    }
-    dcs++;
-  }
-
-  let verifyCBMessage = (aMessage, aDcsInfo) => {
-    if (aDcsInfo.language) {
-      is(aMessage.language, aDcsInfo.language, "aMessage.language");
-    } else if (aDcsInfo.indicator) {
-      is(aMessage.language, "@@", "aMessage.language");
-    } else {
-      ok(aMessage.language == null, "aMessage.language");
-    }
-
-    switch (aDcsInfo.encoding) {
-      case PDU_DCS_MSG_CODING_7BITS_ALPHABET:
-        is(aMessage.body,
-           aDcsInfo.indicator ? DUMMY_BODY_7BITS_IND : DUMMY_BODY_7BITS,
-           "aMessage.body");
-        break;
-      case PDU_DCS_MSG_CODING_8BITS_ALPHABET:
-        ok(aMessage.body == null, "aMessage.body");
-        break;
-      case PDU_DCS_MSG_CODING_16BITS_ALPHABET:
-        is(aMessage.body,
-           aDcsInfo.indicator ? DUMMY_BODY_UCS2_IND : DUMMY_BODY_UCS2,
-           "aMessage.body");
-        break;
-    }
-
-    is(aMessage.messageClass, aDcsInfo.messageClass, "aMessage.messageClass");
-  };
-
-  testDcs.forEach(function(aDcsInfo) {
-    let pdu = buildHexStr(CB_UMTS_MESSAGE_TYPE_CBS, 2) // msg_type
-            + buildHexStr(0, 4) // skip msg_id
-            + buildHexStr(0, 4) // skip SN
-            + buildHexStr(aDcsInfo.dcs, 2) // set dcs
-            + buildHexStr(1, 2) // set num_of_pages to 1
-            + buildHexStr(0, CB_UMTS_MESSAGE_PAGE_SIZE * 2)
-            + buildHexStr(CB_UMTS_MESSAGE_PAGE_SIZE, 2);  // msg_info_length
-    promise = promise
-      .then(() => sendMultipleRawCbsToEmulatorAndWait([pdu]))
-      .then((aMessage) => verifyCBMessage(aMessage, aDcsInfo));
-  });
-
-  return promise;
-}
-
 function testReceiving_UMTS_Timestamp() {
   log("Test receiving UMTS Cell Broadcast - Timestamp");
 
   let verifyCBMessage = (aMessage) => {
     // Cell Broadcast messages do not contain a timestamp field (however, ETWS
     // does). We only check the timestamp doesn't go too far (60 seconds) here.
     let msMessage = aMessage.timestamp;
     let msNow = Date.now();
@@ -436,17 +372,16 @@ function testReceiving_UMTS_MessageInfor
     .then((aMessage) => verifyCBMessage(aMessage));
 }
 
 startTestCommon(function testCaseMain() {
   return testReceiving_UMTS_MessageAttributes()
   .then(() => testReceiving_UMTS_GeographicalScope())
   .then(() => testReceiving_UMTS_MessageCode())
   .then(() => testReceiving_UMTS_MessageId())
-  .then(() => testReceiving_UMTS_Language_and_Body())
   .then(() => testReceiving_UMTS_Timestamp())
   .then(() => testReceiving_UMTS_WarningType())
   .then(() => testReceiving_UMTS_EmergencyUserAlert())
   .then(() => testReceiving_UMTS_Popup())
   .then(() => testReceiving_UMTS_Multipart())
   .then(() => testReceiving_UMTS_PaddingCharacters())
   .then(() => testReceiving_UMTS_MessageInformationLength());
 });
new file mode 100644
--- /dev/null
+++ b/dom/cellbroadcast/tests/marionette/test_cellbroadcast_umts_language_and_body.js
@@ -0,0 +1,71 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 90000;
+MARIONETTE_HEAD_JS = 'head.js';
+
+function testReceiving_UMTS_Language_and_Body() {
+  log("Test receiving UMTS Cell Broadcast - Language & Body");
+
+  let promise = Promise.resolve();
+
+  let testDcs = [];
+  let dcs = 0;
+  while (dcs <= 0xFF) {
+    try {
+      let dcsInfo = { dcs: dcs };
+      [ dcsInfo.encoding, dcsInfo.language,
+        dcsInfo.indicator, dcsInfo.messageClass ] = decodeGsmDataCodingScheme(dcs);
+      testDcs.push(dcsInfo);
+    } catch (e) {
+      // Unsupported coding group, skip.
+      dcs = (dcs & PDU_DCS_CODING_GROUP_BITS) + 0x10;
+    }
+    dcs++;
+  }
+
+  let verifyCBMessage = (aMessage, aDcsInfo) => {
+    if (aDcsInfo.language) {
+      is(aMessage.language, aDcsInfo.language, "aMessage.language");
+    } else if (aDcsInfo.indicator) {
+      is(aMessage.language, "@@", "aMessage.language");
+    } else {
+      ok(aMessage.language == null, "aMessage.language");
+    }
+
+    switch (aDcsInfo.encoding) {
+      case PDU_DCS_MSG_CODING_7BITS_ALPHABET:
+        is(aMessage.body,
+           aDcsInfo.indicator ? DUMMY_BODY_7BITS_IND : DUMMY_BODY_7BITS,
+           "aMessage.body");
+        break;
+      case PDU_DCS_MSG_CODING_8BITS_ALPHABET:
+        ok(aMessage.body == null, "aMessage.body");
+        break;
+      case PDU_DCS_MSG_CODING_16BITS_ALPHABET:
+        is(aMessage.body,
+           aDcsInfo.indicator ? DUMMY_BODY_UCS2_IND : DUMMY_BODY_UCS2,
+           "aMessage.body");
+        break;
+    }
+
+    is(aMessage.messageClass, aDcsInfo.messageClass, "aMessage.messageClass");
+  };
+
+  testDcs.forEach(function(aDcsInfo) {
+    let pdu = buildHexStr(CB_UMTS_MESSAGE_TYPE_CBS, 2) // msg_type
+            + buildHexStr(0, 4) // skip msg_id
+            + buildHexStr(0, 4) // skip SN
+            + buildHexStr(aDcsInfo.dcs, 2) // set dcs
+            + buildHexStr(1, 2) // set num_of_pages to 1
+            + buildHexStr(0, CB_UMTS_MESSAGE_PAGE_SIZE * 2)
+            + buildHexStr(CB_UMTS_MESSAGE_PAGE_SIZE, 2);  // msg_info_length
+    promise = promise
+      .then(() => sendMultipleRawCbsToEmulatorAndWait([pdu]))
+      .then((aMessage) => verifyCBMessage(aMessage, aDcsInfo));
+  });
+
+  return promise;
+}
+
+startTestCommon(() => testReceiving_UMTS_Language_and_Body());