diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/test/test_preload_suspend.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/test_preload_suspend.html')
-rw-r--r-- | dom/media/test/test_preload_suspend.html | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/dom/media/test/test_preload_suspend.html b/dom/media/test/test_preload_suspend.html new file mode 100644 index 0000000000..7f1146360f --- /dev/null +++ b/dom/media/test/test_preload_suspend.html @@ -0,0 +1,112 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test for Bug 479863</title> + <script 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 checkSuspendCount(evt) { + var v = evt.target; + ++v.suspendCount; + is(v.networkState, v.NETWORK_IDLE, v.name + " got suspended, count=" + v.suspendCount); + if (v.suspendCount == v.expectedSuspendCount) { + removeNodeAndSource(v); + manager.finished(v.name); + } + if (v.suspendCount > v.expectedSuspendCount) { + ok(false, v.name + " got too many suspend events"); + } +} + +var tests = [ + { + name: 'v1', + preload: 'none', + expectedSuspendCount: 2, + onsuspend(evt) { + checkSuspendCount(evt); + if (evt.target.suspendCount == 1) { + evt.target.preload = 'auto'; + } + } + }, + { + name: 'v2', + preload: 'auto', + expectedSuspendCount: 1, + onsuspend: checkSuspendCount + }, + { + name: 'v3', + preload: 'none', + autoplay: true, + expectedSuspendCount: 1, + onsuspend: checkSuspendCount + }, + { + name: 'v4', + preload: 'none', + expectedSuspendCount: 2, + onsuspend(evt) { + checkSuspendCount(evt); + if (evt.target.suspendCount == 1) { + evt.target.play(); + } + } + }, + // disable v5 since media element doesn't support 'load' event anymore. + /*{ + name: 'v5', + preload: 'none', + expectedSuspendCount: 2, + onsuspend: function(evt) { + checkSuspendCount(evt); + if (evt.target.suspendCount == 1) { + evt.target.currentTime = 0.1; + } + } + },*/ + { + name: 'v6', + preload: 'none', + expectedSuspendCount: 2, + onsuspend(evt) { + checkSuspendCount(evt); + if (evt.target.suspendCount == 1) { + evt.target.autoplay = true; + } + } + } +]; + +function startTest(test, token) { + var v = document.createElement("video"); + v.name = test.name; + var key = Math.random(); + v.src = "seek.ogv?key=" + key + "&id=" + v.name; + v.preload = test.preload; + v.suspendCount = 0; + v.expectedSuspendCount = test.expectedSuspendCount; + if (test.autoplay) { + v.autoplay = true; + } + v.onsuspend = test.onsuspend; + document.body.appendChild(v); + manager.started(v.name); +} + +SimpleTest.waitForExplicitFinish(); +SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, function() { + manager.runTests(tests, startTest); +}); + +</script> +</pre> +</body> +</html> |