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_play_twice.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_play_twice.html')
-rw-r--r-- | dom/media/test/test_play_twice.html | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/dom/media/test/test_play_twice.html b/dom/media/test/test_play_twice.html new file mode 100644 index 000000000..a1dd07e67 --- /dev/null +++ b/dom/media/test/test_play_twice.html @@ -0,0 +1,95 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test playback of media files that should play OK</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) { + var v = document.createElement('video'); + v.token = token; + manager.started(token); + v.src = test.name; + v.name = test.name; + v.playingCount = 0; + v._playedOnce = false; + + var check = function(test, v) { return function() { + checkMetadata(test.name, v, test); + }}(test, v); + + var noLoad = function(test, v) { return function() { + ok(false, test.name + " should not fire 'load' event"); + }}(test, v); + + function finish(v) { + removeNodeAndSource(v); + manager.finished(v.token); + } + + function mayFinish(v) { + if (v.seenEnded && v.seenSuspend) { + finish(v); + } + } + + var checkEnded = function(test, v) { return function() { + if (test.duration) { + ok(Math.abs(v.currentTime - test.duration) < 0.1, + test.name + " current time at end: " + v.currentTime); + } + + is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState"); + ok(v.ended, test.name + " checking playback has ended"); + ok(v.playingCount > 0, "Expect at least one playing event"); + v.playingCount = 0; + + if (v._playedOnce) { + v.seenEnded = true; + mayFinish(v); + } else { + v._playedOnce = true; + v.play(); + } + }}(test, v); + + var checkSuspended = function(test, v) { return function() { + if (v.seenSuspend) { + return; + } + + v.seenSuspend = true; + ok(true, test.name + " got suspend"); + mayFinish(v); + }}(test, v); + + var checkPlaying = function(test, v) { return function() { + is(test.name, v.name, "Should be testing file we think we're testing..."); + v.playingCount++; + }}(test, v); + + v.addEventListener("load", noLoad, false); + v.addEventListener("loadedmetadata", check, false); + v.addEventListener("playing", checkPlaying, false); + + // We should get "ended" and "suspend" events for every resource + v.addEventListener("ended", checkEnded, false); + v.addEventListener("suspend", checkSuspended, false); + + document.body.appendChild(v); + v.play(); +} + +manager.runTests(gReplayTests, startTest); + +</script> +</pre> +</body> +</html> |