Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: LayoutTests/fast/mediastream/MediaStream-stop.html

Issue 827673002: Add MediaStream.active attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/mediastream/MediaStream-stop.html
diff --git a/LayoutTests/fast/mediastream/MediaStream-stop.html b/LayoutTests/fast/mediastream/MediaStream-stop.html
index d8afe6ffa17e008a6f55f191f0d468c4838b295f..90fbf07781ff0343f96e371fac768d413f0e9b5b 100644
--- a/LayoutTests/fast/mediastream/MediaStream-stop.html
+++ b/LayoutTests/fast/mediastream/MediaStream-stop.html
@@ -5,28 +5,55 @@
</head>
<body>
<script>
-description("Test cloning mediastreams onended.");
+description("Test cloning mediastreams onactive/oninactive callbacks.");
var cloned_stream;
-function onStreamEnded() {
- testPassed('Stream ended.');
+function error() {
+ testFailed('Stream generation failed.');
finishJSTest();
}
-function onTrackAdded() {
- testPassed('Mock test track added.');
- shouldBe('cloned_stream.getVideoTracks().length', '1');
- cloned_stream.getVideoTracks()[0].stop();
+function getUserMedia(dictionary, callback) {
+ try {
+ navigator.webkitGetUserMedia(dictionary, callback, error);
+ } catch (e) {
+ testFailed('webkitGetUserMedia threw exception :' + e);
+ finishJSTest();
+ }
+}
+
+function onStreamActive() {
+ testPassed('Clone stream active.');
+ shouldBeTrue('cloned_stream.active');
+ finishJSTest();
+}
+
+function gotStream2(s) {
+ cloned_stream.onactive = onStreamActive;
+ cloned_stream.addTrack(s.getVideoTracks()[0]);
}
-function run(s) {
- cloned_stream = new webkitMediaStream();
- cloned_stream.onaddtrack = onTrackAdded;
- cloned_stream.onended = onStreamEnded;
+function onStreamInactive() {
+ testPassed('Clone stream inactive.');
+ shouldBeFalse('cloned_stream.active');
+
+ getUserMedia({audio:true, video:true}, gotStream2);
+}
+
+function gotStream(s) {
+ var stream = s;
+
+ cloned_stream = stream.clone();
+ cloned_stream.oninactive = onStreamInactive;
+ shouldBeTrue('cloned_stream.active');
+ shouldBe('cloned_stream.getVideoTracks().length', '1');
+ shouldBe('cloned_stream.getAudioTracks().length', '1');
+ cloned_stream.getVideoTracks()[0].stop();
+ cloned_stream.getAudioTracks()[0].stop();
}
-run();
+getUserMedia({audio:true, video:true}, gotStream);
window.jsTestIsAsync = true;
window.successfullyParsed = true;

Powered by Google App Engine
This is Rietveld 408576698