test_hevc_support.html (1604B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test HEVC video support</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 7 <script type="application/javascript"> 8 9 /** 10 * This test is used to check we can get correct HEVC support information from 11 * `canPlayType` and mediaCapabilities API on different platforms. 12 */ 13 const contentType = 'video/mp4; codecs="hev1.1.6.L93.B0"'; 14 const videoConfiguration = { 15 type: "file", 16 video: { 17 contentType, 18 width: 1920, 19 height: 1080, 20 bitrate: 1000000, 21 framerate: 30, 22 }, 23 }; 24 25 const supportedOSs = ["WINNT", "Darwin", "Android"]; 26 27 add_task(async function testHEVCSupport() { 28 // Disable fingerprinting resistance/protection to get an accurate result. 29 await SpecialPowers.pushPrefEnv({ 30 set: [ 31 ["privacy.resistFingerprinting", false], 32 ["privacy.fingerprintingProtection", false], 33 ], 34 }); 35 const os = SpecialPowers.Services.appinfo.OS; 36 const canPlay = document.createElement('video').canPlayType(contentType); 37 if (supportedOSs.includes(os)) { 38 ok(canPlay != "", `HEVC is supported`); 39 } else { 40 ok(canPlay == "", "HEVC is not supported on current platform"); 41 } 42 43 const capability = await navigator.mediaCapabilities.decodingInfo(videoConfiguration); 44 if (supportedOSs.includes(os)) { 45 ok(capability.supported, `HEVC is supported`); 46 ok(capability.powerEfficient, `HEVC is powerEfficient`); 47 } else { 48 ok(!capability.supported, "HEVC is not supported on current platform"); 49 } 50 }); 51 52 </script> 53 </head> 54 <body> 55 </body> 56 </html>