Bug 1119593 - Update gUM tests to use promises consistently, r=drno,jib

Conflicts:
	dom/media/tests/mochitest/constraints.js

--HG--
extra : rebase_source : 3c6ff820387fae011cf7df6d6c315665f5a8655c
This commit is contained in:
Martin Thomson 2015-01-27 12:35:58 -08:00
Родитель 7f8f597ec4
Коммит d6ccf981b6
17 изменённых файлов: 260 добавлений и 352 удалений

Просмотреть файл

@ -70,25 +70,18 @@ var common_tests = [
*/
function testConstraints(tests) {
function testgum(p, test) {
return p.then(function() {
return navigator.mediaDevices.getUserMedia(test.constraints);
})
.then(function() {
is(null, test.error, test.message);
}, function(reason) {
is(reason.name, test.error, test.message + ": " + reason.message);
});
function testgum(prev, test) {
return prev.then(() => navigator.mediaDevices.getUserMedia(test.constraints))
.then(() => is(null, test.error, test.message),
reason => is(reason.name, test.error, test.message + ": " + reason.message));
}
var p = new Promise(r => SpecialPowers.pushPrefEnv({
set : [ ['media.getusermedia.browser.enabled', false],
['media.getusermedia.screensharing.enabled', false] ]
}, r));
var p = new Promise(resolve => SpecialPowers.pushPrefEnv({
set : [ ['media.getusermedia.browser.enabled', false],
['media.getusermedia.screensharing.enabled', false] ]
}, resolve));
tests.forEach(function(test) {
p = testgum(p, test);
});
p.catch(reason => ok(false, "Unexpected failure: " + reason.message))
.then(SimpleTest.finish);
tests.reduce(testgum, p)
.catch(reason => ok(false, "Unexpected failure: " + reason.message))
.then(SimpleTest.finish);
}

Просмотреть файл

@ -37,13 +37,9 @@ MediaStreamPlayback.prototype = {
* @param {Function} onError the error callback if the media playback
* start and stop cycle fails
*/
playMedia : function MSP_playMedia(isResume, onSuccess, onError) {
var self = this;
this.startMedia(isResume, function() {
self.stopMediaElement();
onSuccess();
}, onError);
playMedia : function(isResume) {
return this.startMedia(isResume)
.then(() => this.stopMediaElement());
},
/**
@ -51,13 +47,8 @@ MediaStreamPlayback.prototype = {
*
* @param {Boolean} isResume specifies if the media element playback
* is being resumed from a previous run
* @param {Function} onSuccess the success function call back
* if media starts correctly
* @param {Function} onError the error function call back
* if media fails to start
*/
startMedia : function MSP_startMedia(isResume, onSuccess, onError) {
var self = this;
startMedia : function(isResume) {
var canPlayThroughFired = false;
// If we're initially running this media, check that the time is zero
@ -66,89 +57,84 @@ MediaStreamPlayback.prototype = {
"Before starting the media element, currentTime = 0");
}
/**
* Callback fired when the canplaythrough event is fired. We only
* run the logic of this function once, as this event can fire
* multiple times while a HTMLMediaStream is playing content from
* a real-time MediaStream.
*/
var canPlayThroughCallback = function() {
// Disable the canplaythrough event listener to prevent multiple calls
canPlayThroughFired = true;
self.mediaElement.removeEventListener('canplaythrough',
canPlayThroughCallback, false);
return new Promise((resolve, reject) => {
/**
* Callback fired when the canplaythrough event is fired. We only
* run the logic of this function once, as this event can fire
* multiple times while a HTMLMediaStream is playing content from
* a real-time MediaStream.
*/
var canPlayThroughCallback = () => {
// Disable the canplaythrough event listener to prevent multiple calls
canPlayThroughFired = true;
this.mediaElement.removeEventListener('canplaythrough',
canPlayThroughCallback, false);
is(self.mediaElement.paused, false,
"Media element should be playing");
is(self.mediaElement.duration, Number.POSITIVE_INFINITY,
"Duration should be infinity");
is(this.mediaElement.paused, false,
"Media element should be playing");
is(this.mediaElement.duration, Number.POSITIVE_INFINITY,
"Duration should be infinity");
// When the media element is playing with a real-time stream, we
// constantly switch between having data to play vs. queuing up data,
// so we can only check that the ready state is one of those two values
ok(self.mediaElement.readyState === HTMLMediaElement.HAVE_ENOUGH_DATA ||
self.mediaElement.readyState === HTMLMediaElement.HAVE_CURRENT_DATA,
"Ready state shall be HAVE_ENOUGH_DATA or HAVE_CURRENT_DATA");
// When the media element is playing with a real-time stream, we
// constantly switch between having data to play vs. queuing up data,
// so we can only check that the ready state is one of those two values
ok(this.mediaElement.readyState === HTMLMediaElement.HAVE_ENOUGH_DATA ||
this.mediaElement.readyState === HTMLMediaElement.HAVE_CURRENT_DATA,
"Ready state shall be HAVE_ENOUGH_DATA or HAVE_CURRENT_DATA");
is(self.mediaElement.seekable.length, 0,
"Seekable length shall be zero");
is(self.mediaElement.buffered.length, 0,
"Buffered length shall be zero");
is(this.mediaElement.seekable.length, 0,
"Seekable length shall be zero");
is(this.mediaElement.buffered.length, 0,
"Buffered length shall be zero");
is(self.mediaElement.seeking, false,
"MediaElement is not seekable with MediaStream");
ok(isNaN(self.mediaElement.startOffsetTime),
"Start offset time shall not be a number");
is(self.mediaElement.loop, false, "Loop shall be false");
is(self.mediaElement.preload, "", "Preload should not exist");
is(self.mediaElement.src, "", "No src should be defined");
is(self.mediaElement.currentSrc, "",
"Current src should still be an empty string");
is(this.mediaElement.seeking, false,
"MediaElement is not seekable with MediaStream");
ok(isNaN(this.mediaElement.startOffsetTime),
"Start offset time shall not be a number");
is(this.mediaElement.loop, false, "Loop shall be false");
is(this.mediaElement.preload, "", "Preload should not exist");
is(this.mediaElement.src, "", "No src should be defined");
is(this.mediaElement.currentSrc, "",
"Current src should still be an empty string");
var timeUpdateFired = false;
var timeUpdateCallback = () => {
if (this.mediaStream.currentTime > 0 &&
this.mediaElement.currentTime > 0) {
this.mediaElement.removeEventListener('timeupdate',
timeUpdateCallback, false);
resolve();
}
};
var timeUpdateCallback = function() {
if (self.mediaStream.currentTime > 0 &&
self.mediaElement.currentTime > 0) {
timeUpdateFired = true;
self.mediaElement.removeEventListener('timeupdate',
timeUpdateCallback, false);
onSuccess();
}
// When timeupdate fires, we validate time has passed and move
// onto the success condition
this.mediaElement.addEventListener('timeupdate', timeUpdateCallback,
false);
// If timeupdate doesn't fire in enough time, we fail the test
setTimeout(() => {
this.mediaElement.removeEventListener('timeupdate',
timeUpdateCallback, false);
reject(new Error("timeUpdate event never fired"));
}, TIMEUPDATE_TIMEOUT_LENGTH);
};
// When timeupdate fires, we validate time has passed and move
// onto the success condition
self.mediaElement.addEventListener('timeupdate', timeUpdateCallback,
false);
// Adds a listener intended to be fired when playback is available
// without further buffering.
this.mediaElement.addEventListener('canplaythrough', canPlayThroughCallback,
false);
// If timeupdate doesn't fire in enough time, we fail the test
setTimeout(function() {
if (!timeUpdateFired) {
self.mediaElement.removeEventListener('timeupdate',
timeUpdateCallback, false);
onError("timeUpdate event never fired");
}
}, TIMEUPDATE_TIMEOUT_LENGTH);
};
// Hooks up the media stream to the media element and starts playing it
this.mediaElement.mozSrcObject = this.mediaStream;
this.mediaElement.play();
// Adds a listener intended to be fired when playback is available
// without further buffering.
this.mediaElement.addEventListener('canplaythrough', canPlayThroughCallback,
false);
// Hooks up the media stream to the media element and starts playing it
this.mediaElement.mozSrcObject = this.mediaStream;
this.mediaElement.play();
// If canplaythrough doesn't fire in enough time, we fail the test
setTimeout(function() {
if (!canPlayThroughFired) {
self.mediaElement.removeEventListener('canplaythrough',
canPlayThroughCallback, false);
onError("canplaythrough event never fired");
}
}, CANPLAYTHROUGH_TIMEOUT_LENGTH);
// If canplaythrough doesn't fire in enough time, we fail the test
setTimeout(() => {
this.mediaElement.removeEventListener('canplaythrough',
canPlayThroughCallback, false);
reject(new Error("canplaythrough event never fired"));
}, CANPLAYTHROUGH_TIMEOUT_LENGTH);
});
},
/**
@ -157,7 +143,7 @@ MediaStreamPlayback.prototype = {
* Precondition: The media stream and element should both be actively
* being played.
*/
stopMediaElement : function MSP_stopMediaElement() {
stopMediaElement : function() {
this.mediaElement.pause();
this.mediaElement.mozSrcObject = null;
}
@ -186,23 +172,12 @@ LocalMediaStreamPlayback.prototype = Object.create(MediaStreamPlayback.prototype
*
* @param {Boolean} isResume specifies if this media element is being resumed
* from a previous run
* @param {Function} onSuccess the success callback if the media element
* successfully fires ended on a stop() call
* on the stream
* @param {Function} onError the error callback if the media element fails
* to fire an ended callback on a stop() call
* on the stream
*/
playMediaWithStreamStop : {
value: function (isResume, onSuccess, onError) {
var self = this;
this.startMedia(isResume, function() {
self.stopStreamInMediaPlayback(function() {
self.stopMediaElement();
onSuccess();
}, onError);
}, onError);
value: function(isResume) {
return this.startMedia(isResume)
.then(() => this.stopStreamInMediaPlayback())
.then(() => this.stopMediaElement());
}
},
@ -213,37 +188,28 @@ LocalMediaStreamPlayback.prototype = Object.create(MediaStreamPlayback.prototype
* Precondition: The media stream and element should both be actively
* being played.
*
* @param {Function} onSuccess the success callback if the media element
* fires an ended event from stop() being called
* @param {Function} onError the error callback if the media element
* fails to fire an ended event from stop() being
* called
*/
stopStreamInMediaPlayback : {
value: function (onSuccess, onError) {
var endedFired = false;
var self = this;
value: function () {
return new Promise((resolve, reject) => {
/**
* Callback fired when the ended event fires when stop() is called on the
* stream.
*/
var endedCallback = () => {
this.mediaElement.removeEventListener('ended', endedCallback, false);
ok(true, "ended event successfully fired");
resolve();
};
/**
* Callback fired when the ended event fires when stop() is called on the
* stream.
*/
var endedCallback = function() {
endedFired = true;
self.mediaElement.removeEventListener('ended', endedCallback, false);
ok(true, "ended event successfully fired");
onSuccess();
};
this.mediaElement.addEventListener('ended', endedCallback, false);
this.mediaStream.stop();
this.mediaElement.addEventListener('ended', endedCallback, false);
this.mediaStream.stop();
// If ended doesn't fire in enough time, then we fail the test
setTimeout(function() {
if (!endedFired) {
onError("ended event never fired");
}
}, ENDED_TIMEOUT_LENGTH);
// If ended doesn't fire in enough time, then we fail the test
setTimeout(() => {
reject(new Error("ended event never fired"));
}, ENDED_TIMEOUT_LENGTH);
});
}
}
});

Просмотреть файл

@ -5,14 +5,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Basic Audio Test</title>
<title>getUserMedia Basic Audio Test</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">mozGetUserMedia Basic Audio Test</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">getUserMedia Basic Audio Test</a>
<p id="display"></p>
<div id="content" style="display: none">
<audio id="testAudio"></audio>
@ -27,17 +27,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
var testAudio = document.getElementById('testAudio');
var constraints = {audio: true};
getUserMedia(constraints, function (aStream) {
getUserMedia(constraints).then(aStream => {
checkMediaStreamTracks(constraints, aStream);
var playback = new LocalMediaStreamPlayback(testAudio, aStream);
playback.playMedia(false, function () {
aStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
return playback.playMedia(false);
}).then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -5,14 +5,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=983504
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Basic Screenshare Test</title>
<title>getUserMedia Basic Screenshare Test</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=983504">mozGetUserMedia Basic Screenshare Test</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=983504">getUserMedia Basic Screenshare Test</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -39,16 +39,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=983504
fake: false
};
getUserMedia(constraints, function (aStream) {
getUserMedia(constraints).then(aStream => {
checkMediaStreamTracks(constraints, aStream);
var playback = new LocalMediaStreamPlayback(testVideo, aStream);
playback.playMediaWithStreamStop(false, function () {
aStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
return playback.playMediaWithStreamStop(false);
}).then(() => SimpleTest.finish(), generateErrorCallback());
});

Просмотреть файл

@ -5,14 +5,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Basic Video Test</title>
<title>getUserMedia Basic Video Test</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">mozGetUserMedia Basic Video Test</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">getUserMedia Basic Video Test</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -27,17 +27,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
var testVideo = document.getElementById('testVideo');
var constraints = {video: true};
getUserMedia(constraints, function (aStream) {
getUserMedia(constraints).then(aStream => {
checkMediaStreamTracks(constraints, aStream);
var playback = new LocalMediaStreamPlayback(testVideo, aStream);
playback.playMedia(false, function () {
aStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
return playback.playMedia(false);
}).then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -5,20 +5,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Basic Video & Audio Test</title>
<title>getUserMedia Basic Video & Audio Test</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">mozGetUserMedia Basic Video & Audio Test</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">getUserMedia Basic Video & Audio Test</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideoAudio"></video>
</div>
<pre id="test">
<script type="application/javascript">
<script type="application/javascript">
/**
* Run a test to verify that we can complete a start and stop media playback
* cycle for a video and audio LocalMediaStream on a video HTMLMediaElement.
@ -27,16 +27,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
var testVideoAudio = document.getElementById('testVideoAudio');
var constraints = {video: true, audio: true};
getUserMedia(constraints, function (aStream) {
getUserMedia(constraints).then(aStream => {
checkMediaStreamTracks(constraints, aStream);
var playback = new LocalMediaStreamPlayback(testVideoAudio, aStream);
playback.playMedia(false, function () {
aStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
return playback.playMedia(false);
}).then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -5,14 +5,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=983504
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Basic Windowshare Test</title>
<title>getUserMedia Basic Windowshare Test</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1038926">mozGetUserMedia Basic Windowshare Test</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1038926">getUserMedia Basic Windowshare Test</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -39,16 +39,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=983504
fake: false
};
getUserMedia(constraints, function (aStream) {
getUserMedia(constraints).then(aStream => {
checkMediaStreamTracks(constraints, aStream);
var playback = new LocalMediaStreamPlayback(testVideo, aStream);
playback.playMediaWithStreamStop(false, function () {
aStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
return playback.playMediaWithStreamStop(false);
}).then(() => SimpleTest.finish(), generateErrorCallback());
});

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia gum within gum</title>
<title>getUserMedia gum within gum</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia gum within gum</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia gum within gum</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -26,28 +26,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
* the audio gum call happens within the video gum call.
*/
runTest(function () {
getUserMedia({video: true}, function(videoStream) {
var testVideo = document.getElementById('testVideo');
var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo,
videoStream);
getUserMedia({video: true})
.then(videoStream => {
var testVideo = document.getElementById('testVideo');
var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo,
videoStream);
videoStreamPlayback.playMedia(false, function() {
getUserMedia({audio: true}, function(audioStream) {
var testAudio = document.getElementById('testAudio');
var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio,
audioStream);
return videoStreamPlayback.playMedia(false)
.then(() => getUserMedia({audio: true}))
.then(audioStream => {
var testAudio = document.getElementById('testAudio');
var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio,
audioStream);
audioStreamPlayback.playMedia(false, function() {
audioStream.stop();
videoStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
return audioStreamPlayback.playMedia(false)
.then(() => audioStream.stop());
})
.then(() => videoStream.stop());
})
.then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Play Audio Twice</title>
<title>getUserMedia Play Audio Twice</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Play Audio Twice</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Play Audio Twice</a>
<p id="display"></p>
<div id="content" style="display: none">
<audio id="testAudio"></audio>
@ -23,23 +23,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
* Run a test that we can complete an audio playback cycle twice in a row.
*/
runTest(function () {
getUserMedia({audio: true}, function(audioStream) {
getUserMedia({audio: true}).then(audioStream => {
var testAudio = document.getElementById('testAudio');
var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio,
audioStream);
audioStreamPlayback.playMedia(false, function() {
audioStreamPlayback.playMedia(true, function() {
audioStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
return audioStreamPlayback.playMedia(false)
.then(() => audioStreamPlayback.playMedia(true))
.then(() => audioStream.stop());
}).then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>
</pre>
</body>

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Play Video and Audio Twice</title>
<title>getUserMedia Play Video and Audio Twice</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Play Video and Audio Twice</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Play Video and Audio Twice</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -23,20 +23,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
* Run a test that we can complete a video playback cycle twice in a row.
*/
runTest(function () {
getUserMedia({video: true, audio: true}, function(stream) {
getUserMedia({video: true, audio: true}).then(stream => {
var testVideo = document.getElementById('testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
streamPlayback.playMedia(false, function() {
streamPlayback.playMedia(true, function() {
stream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
return streamPlayback.playMedia(false)
.then(() => streamPlayback.playMedia(true))
.then(() => stream.stop());
}).then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Play Video Twice</title>
<title>getUserMedia Play Video Twice</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Play Video Twice</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Play Video Twice</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -23,21 +23,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
* Run a test that we can complete a video playback cycle twice in a row.
*/
runTest(function () {
getUserMedia({video: true}, function(videoStream) {
getUserMedia({video: true}).then(stream => {
var testVideo = document.getElementById('testVideo');
var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo,
videoStream);
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
videoStreamPlayback.playMedia(false, function() {
videoStreamPlayback.playMedia(true, function() {
videoStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
return streamPlayback.playMedia(false)
.then(() => streamPlayback.playMedia(true))
.then(() => stream.stop());
}).then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Stop Audio Stream</title>
<title>getUserMedia Stop Audio Stream</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Audio Stream</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Audio Stream</a>
<p id="display"></p>
<div id="content" style="display: none">
<audio id="testAudio"></video>
@ -24,13 +24,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
* call stop() on the stream, and successfully get an ended event fired.
*/
runTest(function () {
getUserMedia({audio: true}, function(stream) {
var testAudio = document.getElementById('testAudio');
var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio, stream);
getUserMedia({audio: true})
.then(stream => {
var testAudio = document.getElementById('testAudio');
var streamPlayback = new LocalMediaStreamPlayback(testAudio, stream);
audioStreamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
generateErrorCallback());
}, generateErrorCallback());
return streamPlayback.playMediaWithStreamStop(false);
})
.then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Stop Audio Stream With Followup Audio</title>
<title>getUserMedia Stop Audio Stream With Followup Audio</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Audio Stream With Followup Audio</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Audio Stream With Followup Audio</a>
<p id="display"></p>
<div id="content" style="display: none">
<audio id="testAudio"></audio>
@ -25,24 +25,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
* in a media element.
*/
runTest(function () {
getUserMedia({audio: true}, function(firstStream) {
var testAudio = document.getElementById('testAudio');
var streamPlayback = new LocalMediaStreamPlayback(testAudio, firstStream);
getUserMedia({audio: true})
.then(firstStream => {
var testAudio = document.getElementById('testAudio');
var streamPlayback = new LocalMediaStreamPlayback(testAudio, firstStream);
streamPlayback.playMediaWithStreamStop(false, function() {
getUserMedia({audio: true}, function(secondStream) {
streamPlayback.mediaStream = secondStream;
return streamPlayback.playMediaWithStreamStop(false)
.then(() => getUserMedia({audio: true}))
.then(secondStream => {
streamPlayback.mediaStream = secondStream;
streamPlayback.playMedia(false, function() {
secondStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
return streamPlayback.playMedia(false)
.then(() => secondStream.stop());
});
})
.then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -5,14 +5,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Stop Video Audio Stream</title>
<title>getUserMedia Stop Video Audio Stream</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Video Audio Stream</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Video Audio Stream</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -25,13 +25,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
* ended event fired.
*/
runTest(function () {
getUserMedia({video: true, audio: true}, function(stream) {
var testVideo = document.getElementById('testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
getUserMedia({video: true, audio: true})
.then(stream => {
var testVideo = document.getElementById('testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
streamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
generateErrorCallback());
}, generateErrorCallback());
return streamPlayback.playMediaWithStreamStop(false);
})
.then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Stop Video+Audio Stream With Followup Video+Audio</title>
<title>getUserMedia Stop Video+Audio Stream With Followup Video+Audio</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Video+Audio Stream With Followup Video+Audio</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Video+Audio Stream With Followup Video+Audio</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -25,24 +25,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
* playback in a media element.
*/
runTest(function () {
getUserMedia({video: true, audio: true}, function(firstStream) {
var testVideo = document.getElementById('testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo, firstStream);
getUserMedia({video: true, audio: true})
.then(stream => {
var testVideo = document.getElementById('testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
streamPlayback.playMediaWithStreamStop(false, function() {
getUserMedia({video: true, audio: true}, function(secondStream) {
streamPlayback.mediaStream = secondStream;
return streamPlayback.playMediaWithStreamStop(false)
.then(() => getUserMedia({video: true, audio: true}))
.then(secondStream => {
streamPlayback.mediaStream = secondStream;
streamPlayback.playMedia(false, function() {
secondStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
return streamPlayback.playMedia(false)
.then(() => secondStream.stop());
});
})
.then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Stop Video Stream</title>
<title>getUserMedia Stop Video Stream</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Video Stream</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Video Audio Stream</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -20,17 +20,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
<pre id="test">
<script type="application/javascript">
/**
* Run a test to verify that we can start a video stream in a media element,
* call stop() on the stream, and successfully get an ended event fired.
* Run a test to verify that we can start a video stream in a
* media element, call stop() on the stream, and successfully get an
* ended event fired.
*/
runTest(function () {
getUserMedia({video: true}, function(stream) {
var testVideo = document.getElementById('testVideo');
var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
getUserMedia({video: true})
.then(stream => {
var testVideo = document.getElementById('testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
videoStreamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
generateErrorCallback());
}, generateErrorCallback());
return streamPlayback.playMediaWithStreamStop(false);
})
.then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>

Просмотреть файл

@ -1,18 +1,18 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822109
-->
<head>
<meta charset="utf-8">
<title>mozGetUserMedia Stop Video Stream With Followup Video</title>
<title>getUserMedia Stop Video Stream With Followup Video</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Video Stream With Followup Video</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Video Stream With Followup Video</a>
<p id="display"></p>
<div id="content" style="display: none">
<video id="testVideo"></video>
@ -20,30 +20,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
<pre id="test">
<script type="application/javascript">
/**
* Run a test to verify that I can complete an audio gum playback in a media
* element, stop the stream, and then complete another audio gum playback
* in a media element.
* Run a test to verify that I can complete an video gum playback in a
* media element, stop the stream, and then complete another video gum
* playback in a media element.
*/
runTest(function () {
getUserMedia({video: true}, function(firstStream) {
var testVideo = document.getElementById('testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo,
firstStream);
getUserMedia({video: true})
.then(stream => {
var testVideo = document.getElementById('testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
streamPlayback.playMediaWithStreamStop(false, function() {
getUserMedia({video: true}, function(secondStream) {
streamPlayback.mediaStream = secondStream;
return streamPlayback.playMediaWithStreamStop(false)
.then(() => getUserMedia({video: true}))
.then(secondStream => {
streamPlayback.mediaStream = secondStream;
streamPlayback.playMedia(false, function() {
secondStream.stop();
SimpleTest.finish();
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
}, generateErrorCallback());
return streamPlayback.playMedia(false)
.then(() => secondStream.stop());
});
})
.then(() => SimpleTest.finish(), generateErrorCallback());
});
</script>