summaryrefslogtreecommitdiffstats
path: root/dom/media/tests/mochitest/steeplechase_long
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/tests/mochitest/steeplechase_long
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/tests/mochitest/steeplechase_long')
-rw-r--r--dom/media/tests/mochitest/steeplechase_long/long.js217
-rw-r--r--dom/media/tests/mochitest/steeplechase_long/steeplechase_long.ini12
-rw-r--r--dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicAudioVideoCombined_long.html38
-rw-r--r--dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicAudio_long.html38
-rw-r--r--dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicVideo_long.html38
5 files changed, 343 insertions, 0 deletions
diff --git a/dom/media/tests/mochitest/steeplechase_long/long.js b/dom/media/tests/mochitest/steeplechase_long/long.js
new file mode 100644
index 000000000..8e8030946
--- /dev/null
+++ b/dom/media/tests/mochitest/steeplechase_long/long.js
@@ -0,0 +1,217 @@
+/* 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/. */
+
+
+/**
+ * Returns true if res is a local rtp
+ *
+ * @param {Object} statObject
+ * One of the objects comprising the report received from getStats()
+ * @returns {boolean}
+ * True if object is a local rtp
+ */
+function isLocalRtp(statObject) {
+ return (typeof statObject === 'object' &&
+ statObject.isRemote === false);
+}
+
+
+/**
+ * Dumps the local, dynamic parts of the stats object as a formatted block
+ * Used for capturing and monitoring test status during execution
+ *
+ * @param {Object} stats
+ * Stats object to use for output
+ * @param {string} label
+ * Used in the header of the output
+ */
+function outputPcStats(stats, label) {
+ var outputStr = '\n\n';
+ function appendOutput(line) {
+ outputStr += line.toString() + '\n';
+ }
+
+ var firstRtp = true;
+ for (var prop in stats) {
+ if (isLocalRtp(stats[prop])) {
+ var rtp = stats[prop];
+ if (firstRtp) {
+ appendOutput(label.toUpperCase() + ' STATS ' +
+ '(' + new Date(rtp.timestamp).toISOString() + '):');
+ firstRtp = false;
+ }
+ appendOutput(' ' + rtp.id + ':');
+ if (rtp.type === 'inboundrtp') {
+ appendOutput(' bytesReceived: ' + rtp.bytesReceived);
+ appendOutput(' jitter: ' + rtp.jitter);
+ appendOutput(' packetsLost: ' + rtp.packetsLost);
+ appendOutput(' packetsReceived: ' + rtp.packetsReceived);
+ } else {
+ appendOutput(' bytesSent: ' + rtp.bytesSent);
+ appendOutput(' packetsSent: ' + rtp.packetsSent);
+ }
+ }
+ }
+ outputStr += '\n\n';
+ dump(outputStr);
+}
+
+
+var _lastStats = {};
+
+const MAX_ERROR_CYCLES = 5;
+var _errorCount = {};
+
+/**
+ * Verifies the peer connection stats interval over interval
+ *
+ * @param {Object} stats
+ * Stats object to use for verification
+ * @param {string} label
+ * Identifies the peer connection. Differentiates stats for
+ * interval-over-interval verification in cases where more than one set
+ * is being verified
+ */
+function verifyPcStats(stats, label) {
+ const INCREASING_INBOUND_STAT_NAMES = [
+ 'bytesReceived',
+ 'packetsReceived'
+ ];
+
+ const INCREASING_OUTBOUND_STAT_NAMES = [
+ 'bytesSent',
+ 'packetsSent'
+ ];
+
+ if (_lastStats[label] !== undefined) {
+ var errorsInCycle = false;
+
+ function verifyIncrease(rtpName, statNames) {
+ var timestamp = new Date(stats[rtpName].timestamp).toISOString();
+
+ statNames.forEach(function (statName) {
+ var passed = stats[rtpName][statName] >
+ _lastStats[label][rtpName][statName];
+ if (!passed) {
+ errorsInCycle = true;
+ }
+ ok(passed,
+ timestamp + '.' + label + '.' + rtpName + '.' + statName,
+ label + '.' + rtpName + '.' + statName + ' increased (value=' +
+ stats[rtpName][statName] + ')');
+ });
+ }
+
+ for (var prop in stats) {
+ if (isLocalRtp(stats[prop])) {
+ if (stats[prop].type === 'inboundrtp') {
+ verifyIncrease(prop, INCREASING_INBOUND_STAT_NAMES);
+ } else {
+ verifyIncrease(prop, INCREASING_OUTBOUND_STAT_NAMES);
+ }
+ }
+ }
+
+ if (errorsInCycle) {
+ _errorCount[label] += 1;
+ info(label +": increased error counter to " + _errorCount[label]);
+ } else {
+ // looks like we recovered from a temp glitch
+ if (_errorCount[label] > 0) {
+ info(label + ": reseting error counter to zero");
+ }
+ _errorCount[label] = 0;
+ }
+ } else {
+ _errorCount[label] = 0;
+ }
+
+ _lastStats[label] = stats;
+}
+
+
+/**
+ * Retrieves and performs a series of operations on PeerConnection stats
+ *
+ * @param {PeerConnectionWrapper} pc
+ * PeerConnectionWrapper from which to get stats
+ * @param {string} label
+ * Label for the peer connection, passed to each stats callback
+ * @param {Array} operations
+ * Array of stats callbacks, each as function (stats, label)
+ */
+function processPcStats(pc, label, operations) {
+ pc.getStats(null, function (stats) {
+ operations.forEach(function (operation) {
+ operation(stats, label);
+ });
+ });
+}
+
+
+/**
+ * Outputs and verifies the status for local and/or remote PeerConnection as
+ * appropriate
+ *
+ * @param {Object} test
+ * Test containing the peer connection(s) for verification
+ */
+function verifyConnectionStatus(test) {
+ const OPERATIONS = [outputPcStats, verifyPcStats];
+
+ if (test.pcLocal) {
+ processPcStats(test.pcLocal, 'LOCAL', OPERATIONS);
+ }
+
+ if (test.pcRemote) {
+ processPcStats(test.pcRemote, 'REMOTE', OPERATIONS);
+ }
+}
+
+
+/**
+ * Generates a setInterval wrapper command link for use in pc.js command chains
+ *
+ * This function returns a promise that will resolve once the link repeatedly
+ * calls the given callback function every interval ms
+ * until duration ms have passed, then it will continue the test.
+ *
+ * @param {function} callback
+ * Function to be called on each interval
+ * @param {number} [interval=1000]
+ * Frequency in milliseconds with which callback will be called
+ * @param {number} [duration=3 hours]
+ * Length of time in milliseconds for which callback will be called
+
+
+ */
+function generateIntervalCommand(callback, interval, duration) {
+ interval = interval || 1000;
+ duration = duration || 1000 * 3600 * 3;
+
+ return function INTERVAL_COMMAND(test) {
+ return new Promise (resolve=>{
+ var startTime = Date.now();
+ var intervalId = setInterval(function () {
+ if (callback) {
+ callback(test);
+ }
+
+ var failed = false;
+ Object.keys(_errorCount).forEach(function (label) {
+ if (_errorCount[label] > MAX_ERROR_CYCLES) {
+ ok(false, "Encountered more then " + MAX_ERROR_CYCLES + " cycles" +
+ " with errors on " + label);
+ failed = true;
+ }
+ });
+ var timeElapsed = Date.now() - startTime;
+ if ((timeElapsed >= duration) || failed) {
+ clearInterval(intervalId);
+ resolve();
+ }
+ }, interval);
+ });
+ };
+}
diff --git a/dom/media/tests/mochitest/steeplechase_long/steeplechase_long.ini b/dom/media/tests/mochitest/steeplechase_long/steeplechase_long.ini
new file mode 100644
index 000000000..5832c4a24
--- /dev/null
+++ b/dom/media/tests/mochitest/steeplechase_long/steeplechase_long.ini
@@ -0,0 +1,12 @@
+[DEFAULT]
+support-files =
+ long.js
+ ../head.js
+ ../mediaStreamPlayback.js
+ ../pc.js
+ ../templates.js
+ ../turnConfig.js
+ ../network.js
+
+[test_peerConnection_basicAudioVideoCombined_long.html]
+
diff --git a/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicAudioVideoCombined_long.html b/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicAudioVideoCombined_long.html
new file mode 100644
index 000000000..d2f03cd60
--- /dev/null
+++ b/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicAudioVideoCombined_long.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+
+<!-- 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/. -->
+
+<html>
+<head>
+ <script type="application/javascript" src="long.js"></script>
+ <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+ createHTML({
+ bug: "1014328",
+ title: "Basic audio/video (combined) peer connection, long running",
+ visible: true
+ });
+
+ var STEEPLECHASE_TIMEOUT = 1000 * 3600 * 3;
+ var test;
+ runNetworkTest(function (options) {
+ options = options || {};
+ options.commands = makeDefaultCommands();
+ options.commands.push(generateIntervalCommand(verifyConnectionStatus,
+ 1000 * 10,
+ STEEPLECHASE_TIMEOUT));
+
+ test = new PeerConnectionTest(options);
+ test.setMediaConstraints([{audio: true, video: true, fake: false}],
+ [{audio: true, video: true, fake: false}]);
+ test.run();
+ });
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicAudio_long.html b/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicAudio_long.html
new file mode 100644
index 000000000..ef92c0c95
--- /dev/null
+++ b/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicAudio_long.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+
+<!-- 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/. -->
+
+<html>
+<head>
+ <script type="application/javascript" src="long.js"></script>
+ <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+ createHTML({
+ bug: "796892",
+ title: "Basic audio-only peer connection",
+ visible: true
+ });
+
+ var STEEPLECHASE_TIMEOUT = 1000 * 3600 * 3;
+ var test;
+ runNetworkTest(function (options) {
+ options = options || {};
+ options.commands = makeDefaultCommands();
+ options.commands.push(generateIntervalCommand(verifyConnectionStatus,
+ 1000 * 10,
+ STEEPLECHASE_TIMEOUT));
+
+ test = new PeerConnectionTest(options);
+ test.setMediaConstraints([{audio: true, fake: false}],
+ [{audio: true, fake: false}]);
+ test.run();
+ });
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicVideo_long.html b/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicVideo_long.html
new file mode 100644
index 000000000..64e4ef8f6
--- /dev/null
+++ b/dom/media/tests/mochitest/steeplechase_long/test_peerConnection_basicVideo_long.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+
+<!-- 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/. -->
+
+<html>
+<head>
+ <script type="application/javascript" src="long.js"></script>
+ <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+ createHTML({
+ bug: "796888",
+ title: "Basic video-only peer connection",
+ visible: true
+ });
+
+ var STEEPLECHASE_TIMEOUT = 1000 * 3600 * 3;
+ var test;
+ runNetworkTest(function (options) {
+ options = options || {};
+ options.commands = makeDefaultCommands();
+ options.commands.push(generateIntervalCommand(verifyConnectionStatus,
+ 1000 * 10,
+ STEEPLECHASE_TIMEOUT));
+
+ test = new PeerConnectionTest(options);
+ test.setMediaConstraints([{video: true, fake: false}],
+ [{video: true, fake: false}]);
+ test.run();
+ });
+</script>
+</pre>
+</body>
+</html>