diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/test/test_mediatrack_replay_from_end.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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/test/test_mediatrack_replay_from_end.html')
-rw-r--r-- | dom/media/test/test_mediatrack_replay_from_end.html | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/dom/media/test/test_mediatrack_replay_from_end.html b/dom/media/test/test_mediatrack_replay_from_end.html new file mode 100644 index 000000000..584849a59 --- /dev/null +++ b/dom/media/test/test_mediatrack_replay_from_end.html @@ -0,0 +1,146 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test media tracks if replay after playback has ended</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> + <script type="text/javascript" src="manifest.js"></script> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +var manager = new MediaTestManager; + +function startTest(test, token) { + // Scenario to test: + // 1. Audio tracks and video tracks should be added to the track list when + // playing, and all tracks should be removed from the list after we seek + // to the end. + // 2. All tracks should be added back to the list if we replay from the end, + // and all tracks should be removed from the list after we seek to the end. + // 3. After seek to the middle from end of playback, all tracks should be + // added back to the list if we play from here, and all tracks should be + // removed from the list after we seek to the end. + + var elemType = getMajorMimeType(test.type); + var element = document.createElement(elemType); + + var audioOnchange = 0; + var audioOnaddtrack = 0; + var audioOnremovetrack = 0; + var videoOnchange = 0; + var videoOnaddtrack = 0; + var videoOnremovetrack = 0; + var isPlaying = false; + var steps = 0; + + element.audioTracks.onaddtrack = function(e) { + audioOnaddtrack++; + } + + element.audioTracks.onremovetrack = function(e) { + audioOnremovetrack++; + } + + element.videoTracks.onaddtrack = function(e) { + videoOnaddtrack++; + } + + element.videoTracks.onremovetrack = function(e) { + videoOnremovetrack++; + } + + function testTrackEventCalls(expectedCalls) { + if (test.hasAudio) { + is(audioOnaddtrack, expectedCalls, + 'Calls of onaddtrack on audioTracks should be '+expectedCalls+' times.'); + is(audioOnremovetrack, expectedCalls, + 'Calls of onremovetrack on audioTracks should be '+expectedCalls+' times.'); + } + if (test.hasVideo) { + is(videoOnaddtrack, expectedCalls, + 'Calls of onaddtrack on videoTracks should be '+expectedCalls+' times.'); + is(videoOnremovetrack, expectedCalls, + 'Calls of onremovetrack on videoTracks should be '+expectedCalls+' times.'); + } + } + + function finishTesting() { + element.onpause = null; + element.onseeked = null; + element.onplaying = null; + element.onended = null; + manager.finished(element.token); + } + + function onended() { + if (isPlaying) { + switch(steps) { + case 1: + testTrackEventCalls(1); + element.onplaying = onplaying; + element.play(); + steps++; + break; + case 2: + testTrackEventCalls(2); + element.currentTime = element.duration * 0.5; + element.onplaying = onplaying; + element.play(); + steps++; + break; + case 3: + testTrackEventCalls(3); + finishTesting(); + break; + } + } else { + ok(true, 'Finish the test anyway if ended is fired before other events.'); + finishTesting(); + } + } + + function seekToEnd() { + element.onpause = null; + element.currentTime = element.duration * 1.1; + } + + function onseeked() { + element.onseeked = null; + element.onpause = seekToEnd; + element.pause(); + } + + function onplaying() { + isPlaying = true; + element.onplaying = null; + element.onseeked = onseeked; + } + + element.token = token; + manager.started(token); + + element.src = test.name; + element.test = test; + element.onplaying = onplaying; + element.onended = onended; + element.play(); + steps++; +} + +SimpleTest.waitForExplicitFinish(); +SpecialPowers.pushPrefEnv( + { + "set": [ + ["media.track.enabled", true] + ] + }, + function() { + manager.runTests(gTrackTests, startTest); + }); + +</script> +</pre> +</body> +</html> |