Bug 1373858 - make sure all fields are checked in the cancelled pairs. r=drno
MozReview-Commit-ID: 5F3hmCQBIUg
--- 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 => {