mediasource-sourcebuffer-mode-timestamps.html (1732B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset='utf-8'> 5 <title>SourceBuffer#mode with generate timestamps flag true</title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 </head> 9 <body> 10 <div id="log"></div> 11 12 <script> 13 var mimes = ['audio/aac', 'audio/mpeg']; 14 15 //check the browser supports the MIME used in this test 16 function isTypeSupported(mime) { 17 if(!MediaSource.isTypeSupported(mime)) { 18 this.step(function() { 19 assert_unreached("Browser doesn't support the MIME used in this test: " + mime); 20 }); 21 this.done(); 22 return false; 23 } 24 return true; 25 } 26 function mediaTest(mime) { 27 async_test(function(t) { 28 if(!isTypeSupported.bind(t)(mime)) { 29 return; 30 } 31 var mediaSource = new MediaSource(); 32 mediaSource.addEventListener('sourceopen', t.step_func_done(function(e) { 33 var sourceBuffer = mediaSource.addSourceBuffer(mime); 34 assert_equals(sourceBuffer.updating, false, "SourceBuffer.updating is false"); 35 assert_throws_js(TypeError, 36 function() { 37 sourceBuffer.mode = "segments"; 38 }, 39 'SourceBuffer#mode with generate timestamps flag true'); 40 }), false); 41 var video = document.createElement('video'); 42 video.src = window.URL.createObjectURL(mediaSource); 43 }, mime + ' : ' + 44 'If generate timestamps flag equals true and new mode equals "segments", ' + 45 'then throw a TypeError exception and abort these steps.'); 46 } 47 mimes.forEach(function(mime) { 48 mediaTest(mime); 49 }); 50 </script> 51 </body> 52 </html>