summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_preload_suspend.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/test/test_preload_suspend.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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_preload_suspend.html')
-rw-r--r--dom/media/test/test_preload_suspend.html112
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 000000000..4a9478462
--- /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 type="application/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 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: function(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: function(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: function(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>