content/media/test/test_load_source.html

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=534571
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 534571</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 <script type="text/javascript" src="manifest.js"></script>
michael@0 11 </head>
michael@0 12 <body>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534571">Mozilla Bug 534571</a>
michael@0 14 <p id="display"></p>
michael@0 15 <div id="content" style="display: none">
michael@0 16
michael@0 17 </div>
michael@0 18 <pre id="test">
michael@0 19 <script type="application/javascript">
michael@0 20
michael@0 21 /** Test for Bug 534571 **/
michael@0 22
michael@0 23 // Test that when we load a video from a source child and then change the
michael@0 24 // source's src attribute and load again, that the subsequent loads work.
michael@0 25
michael@0 26 var v = null;
michael@0 27 var s = null;
michael@0 28
michael@0 29 function finish(event) {
michael@0 30 ok(true, "Should have played both videos");
michael@0 31 SimpleTest.finish();
michael@0 32 }
michael@0 33
michael@0 34 var first = null;
michael@0 35 var second = null;
michael@0 36
michael@0 37 function ended(event) {
michael@0 38 s.type = second.type;
michael@0 39 s.src = second.name;
michael@0 40 v.removeEventListener("ended", ended, false);
michael@0 41 v.addEventListener("ended", finish, false);
michael@0 42 v.load();
michael@0 43 }
michael@0 44
michael@0 45 // Find 2 videos we can play.
michael@0 46 v = document.createElement('video');
michael@0 47 for (var i=0; i<gPlayTests.length; i++) {
michael@0 48 if (!v.canPlayType(gPlayTests[i].type))
michael@0 49 continue;
michael@0 50 if (!first) {
michael@0 51 first = gPlayTests[i];
michael@0 52 } else if (!second) {
michael@0 53 second = gPlayTests[i];
michael@0 54 break;
michael@0 55 }
michael@0 56 }
michael@0 57
michael@0 58 if (first && second) {
michael@0 59 s = document.createElement('source');
michael@0 60 s.type = first.type;
michael@0 61 s.src = first.name;
michael@0 62 v.appendChild(s);
michael@0 63 v.autoplay = true;
michael@0 64 v.addEventListener("ended", ended, false);
michael@0 65 document.body.appendChild(v);
michael@0 66 SimpleTest.waitForExplicitFinish();
michael@0 67 } else {
michael@0 68 todo(false, "Need at least two media of supported types for this test!");
michael@0 69 }
michael@0 70
michael@0 71
michael@0 72
michael@0 73 </script>
michael@0 74 </pre>
michael@0 75 </body>
michael@0 76 </html>

mercurial