video_volume_check.html (2676B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Video Test: video_volume_check</title> 5 <link rel="author" title="Intel" href="http://www.intel.com" /> 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-media-volume" /> 7 <meta name="flags" content="" /> 8 <meta name="assert" content="Check that video.volume returns the value of the muted content attribute" /> 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 </head> 12 <body> 13 <div id="log"></div> 14 <video id="m">The user agent doesn't support media element.</video> 15 <script type="text/javascript"> 16 var media = document.getElementById("m"); 17 var VOLUME = { 18 'SILENT' : 0.0, 19 'NORMAL' : 0.5, 20 'LOUDEST' : 1.0, 21 'LOWER' : -1.1, 22 'UPPER' : 1.1, 23 }; 24 25 test(function() { 26 assert_false(media.volume < VOLUME.SILENT || media.volume > VOLUME.LOUDEST, "media.volume outside the range 0.0 to 1.0 inclusive"); 27 }, "Check if the intial value of the video.volume is in the range 0.0 to 1.0 inclusive"); 28 29 function volume_setting(vol, name) 30 { 31 if (vol < VOLUME.SILENT || vol > VOLUME.LOUDEST) { 32 try { 33 media.volume = vol; 34 test(function() { 35 assert_true(false, "media.volume setting exception"); 36 }, name); 37 } catch(e) { 38 test(function() { 39 // 1 should be e.IndexSizeError or e.INDEX_SIZE_ERR in previous spec 40 assert_equals(e.code, 1, "media.volume setting exception"); 41 }, name); 42 } 43 } else { 44 media.volume = vol; 45 test(function() { 46 assert_equals(media.volume, vol, "media.volume new value"); 47 }, name); 48 } 49 } 50 51 volume_setting(VOLUME.NORMAL, "Check if video.volume is able to set to new value in the range 0.0 to 1.0"); 52 volume_setting(VOLUME.SILENT, "Check if media.volume is able to set to new value 0.0 as silent"); 53 volume_setting(VOLUME.LOUDEST, "Check if media.volume is able to set to new value 1.0 as loudest"); 54 volume_setting(VOLUME.LOWER, "Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown"); 55 volume_setting(VOLUME.UPPER, "Check if video.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown"); 56 </script> 57 </body> 58 </html>