1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description("Tests MediaStreamTrack callbacks.");
12 // Note that the below behaviour doesn't reflect how it works outside of LayoutTests.
13 // The underlying mock is modified to trigger the events when certain functions are called.
14 // This modified behaviour allows us to test the MediaStreamTrack class properly.
19 testFailed('Stream generation failed.');
23 function getUserMedia(constraints
, callback
) {
25 navigator
.webkitGetUserMedia(constraints
, callback
, error
);
27 testFailed('webkitGetUserMedia threw exception :' + e
);
32 function onTrackEnded() {
33 testPassed('Track onended callback succeeded.');
35 shouldBeEqualToString('track.readyState', 'ended');
40 function onTrackUnmute() {
41 testPassed('Track onunmute callback succeeded.');
43 shouldBeEqualToString('track.readyState', 'live');
44 shouldBeFalse('track.muted');
49 function onTrackMute() {
50 testPassed('Track onmute callback succeeded.');
52 shouldBeEqualToString('track.readyState', 'muted');
53 shouldBeTrue('track.muted');
58 function gotStream(stream
) {
59 testPassed('getUserMedia succeeded.');
61 track
= stream
.getVideoTracks()[0];
63 shouldBeEqualToString('track.readyState', 'live');
65 track
.onunmute
= onTrackUnmute
;
66 track
.onmute
= onTrackMute
;
67 track
.onended
= onTrackEnded
;
69 track
.enabled
= false;
72 getUserMedia({audio
:true, video
:true}, gotStream
);
74 window
.jsTestIsAsync
= true;
75 window
.successfullyParsed
= true;