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