forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMediaStream-video-element-remove-track.html
More file actions
112 lines (95 loc) · 4.16 KB
/
MediaStream-video-element-remove-track.html
File metadata and controls
112 lines (95 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
var video;
var mediaStream;
function logEvent(element, eventName, func)
{
function _eventCallback(evt)
{
if (window.wasFinishJSTestCalled)
return;
debug(`Event <em>'${evt.type}'</em>`);
if (func)
func(evt);
}
element.addEventListener(eventName, _eventCallback, true);
}
function checkVideoElement()
{
evalAndLog("video.pause()");
debug("<br>**** check video element ****");
debug("<br>**** check video tracks ****");
shouldBe('video.videoTracks.length', '1');
shouldBe('video.videoTracks[0].id', 'mediaStream.getVideoTracks()[0].id');
debug("<br>**** check audio tracks ****");
shouldBe('video.audioTracks.length', '1');
shouldBe('video.audioTracks[0].id', 'mediaStream.getAudioTracks()[0].id');
setTimeout(removeAudioTrack, 100);
}
function checkVideoElement2()
{
debug("<br>**** check video element ****");
shouldBe('video.videoWidth', 'mediaStream.getVideoTracks()[0].getSettings().width');
shouldBe('video.videoHeight', 'mediaStream.getVideoTracks()[0].getSettings().height');
debug("<br>**** check video tracks ****");
shouldBe('video.videoTracks.length', '1');
shouldBe('video.videoTracks[0].id', 'mediaStream.getVideoTracks()[0].id');
shouldBeEqualToString('video.videoTracks[0].language', '');
shouldBeEqualToString('video.videoTracks[0].kind', 'main');
debug("<br>**** check no audio track ****");
shouldBe('video.audioTracks.length', '0');
shouldBe('mediaStream.getAudioTracks().length', '0');
finishJSTest();
}
function canplay()
{
debug("<br>*** start playback ****");
evalAndLog("video.play()");
setTimeout(checkVideoElement, 100);
}
function removeAudioTrack() {
track = mediaStream.getAudioTracks()[0];
debug("<br>**** removing audio track ****");
try {
mediaStream.removeTrack(track);
} catch (exception) {
testFailed("removeTrack threw an exception.");
finishJSTest();
}
setTimeout(checkVideoElement2, 100);
}
function setupStream(stream)
{
mediaStream = stream;
testPassed('mediaDevices.getUserMedia succeeded.');
debug("<br>**** setup video element ****");
evalAndLog("video.srcObject = mediaStream");
}
function start()
{
description("Tests checking removing MediaStream track applies to the video element.");
video = document.querySelector('video');
logEvent(video, 'canplay', canplay)
debug("<br>**** calling mediaDevices.getUserMedia() ****");
if (window.testRunner)
testRunner.setUserMediaPermission(true);
navigator.mediaDevices.getUserMedia( {video: true, audio: true} )
.then(setupStream)
.catch(function(reason) {
debug(`Stream generation failed with error: ${reason}`);
});
}
window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
</head>
<body onload="start()">
<p id="description"></p>
<video controls width="680" height="360"></video>
<div id="console"></div>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>