Bug 1373858 - make sure all fields are checked in the cancelled pairs. r=drno draft
authorMichael Froman <mfroman@mozilla.com>
Thu, 29 Jun 2017 13:27:41 -0500
changeset 602319 1ed3c2f47ed05438d9ca1768de567c03a07d5ef4
parent 599983 92dc60b522d81862e52bff5cdb1b698eb5608658
child 635549 fd604aaeedaa688a5ab148b47cbea7a6fbe6babe
push id66379
push userbmo:mfroman@nostrum.com
push dateThu, 29 Jun 2017 22:14:34 +0000
reviewersdrno
bugs1373858
milestone56.0a1
Bug 1373858 - make sure all fields are checked in the cancelled pairs. r=drno MozReview-Commit-ID: 5F3hmCQBIUg
dom/media/tests/mochitest/test_peerConnection_stats.html
--- a/dom/media/tests/mochitest/test_peerConnection_stats.html
+++ b/dom/media/tests/mochitest/test_peerConnection_stats.html
@@ -371,16 +371,17 @@ var pedanticChecks = report => {
           + stat.droppedFrames);
 
         // framesEncoded
         ok(stat.framesEncoded >= 0 && stat.framesEncoded < 100000, stat.type
           + ".framesEncoded is a sane number for a short test. value="
           + stat.framesEncoded);
       }
     } else if (stat.type == "candidate-pair") {
+      info("candidate-pair is: " + JSON.stringify(stat));
       //
       // Required fields
       //
 
       // transportId
       ok(stat.transportId,
         stat.type + ".transportId has a value. value="
         + stat.transportId);
@@ -406,17 +407,20 @@ var pedanticChecks = report => {
         + stat.readable);
 
       // writable
       ok(stat.writable,
         stat.type + ".writable is true. value="
         + stat.writable);
 
       // state
-      if (stat.state == "succeeded") {
+      if (stat.state == "succeeded" &&
+          stat.selected !== undefined &&
+          stat.selected) {
+        info("candidate-pair state is succeeded and selected is true");
         // nominated
         ok(stat.nominated,
           stat.type + ".nominated is true. value="
           + stat.nominated);
 
         // bytesSent
         ok(stat.bytesSent > 20000 && stat.bytesSent < 800000,
           stat.type + ".bytesSent is a sane number (20,000<>800,000)for a short test. value="
@@ -433,31 +437,45 @@ var pedanticChecks = report => {
           + stat.lastPacketSentTimestamp);
 
         // lastPacketReceivedTimestamp
         ok(stat.lastPacketReceivedTimestamp,
           stat.type + ".lastPacketReceivedTimestamp has a value. value="
           + stat.lastPacketReceivedTimestamp);
 
       } else {
+        info("candidate-pair is _not_ both state == succeeded and selected");
         // nominated
-        ok(!stat.nominated,
-          stat.type + ".nominated is false. value="
+        ok(stat.nominated !== undefined,
+          stat.type + ".nominated exists. value="
           + stat.nominated);
+        ok(stat.bytesSent !== undefined,
+          stat.type + ".bytesSent exists. value="
+          + stat.bytesSent);
+        ok(stat.bytesReceived !== undefined,
+          stat.type + ".bytesReceived exists. value="
+          + stat.bytesReceived);
+        ok(stat.lastPacketSentTimestamp !== undefined,
+          stat.type + ".lastPacketSentTimestamp exists. value="
+          + stat.lastPacketSentTimestamp);
+        ok(stat.lastPacketReceivedTimestamp !== undefined,
+          stat.type + ".lastPacketReceivedTimestamp exists. value="
+          + stat.lastPacketReceivedTimestamp);
       }
 
 
       //
       // Optional fields
       //
       // selected
       ok(stat.selected === undefined ||
-         ((stat.state == "succeeded" && stat.selected == true) ||
-          (stat.selected == false)),
-        stat.type + ".selected is undefined or true. value="
+         ((stat.state == "succeeded" && stat.selected) ||
+          !stat.selected),
+        stat.type + ".selected is undefined, true when state is succeeded, "
+        + "or false. value="
         + stat.selected);
 
     }
 
     //
     // Ensure everything was tested
     //
     [...expectations.expected, ...expectations.optional].forEach(field => {