test_autoplay_policy_unmute_pauses.html (1769B)
1 <!DOCTYPE HTML> 2 <html> 3 4 <head> 5 <title>Autoplay policy test</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 8 <script type="text/javascript" src="manifest.js"></script> 9 <script type="text/javascript" src="AutoplayTestUtils.js"></script> 10 </head> 11 12 <body> 13 <pre id="test"> 14 <script> 15 16 window.is = SimpleTest.is; 17 window.info = SimpleTest.info; 18 19 // Tests that videos can only play audibly in windows/frames 20 // which have been activated by same-origin user gesture. 21 22 gTestPrefs.push(["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], 23 ["media.autoplay.blocking_policy", 0]); 24 25 SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => { 26 runTest(); 27 }); 28 29 let testCases = [ 30 { 31 property: "muted", 32 inaudible: true, 33 audible: false, 34 }, 35 36 { 37 property: "volume", 38 inaudible: 0.0, 39 audible: 1.0, 40 }, 41 ]; 42 43 let child_url = "file_autoplay_policy_unmute_pauses.html"; 44 45 async function runTest() { 46 for (const testCase of testCases) { 47 // Run each test in a new window, to ensure its user gesture 48 // activation state isn't tainted by preceeding tests. 49 let child = window.open(child_url, "", "width=500,height=500"); 50 await once(child, "load"); 51 child.postMessage(testCase, window.origin); 52 await nextWindowMessage(); 53 child.close(); 54 } 55 SimpleTest.finish(); 56 } 57 58 SimpleTest.waitForExplicitFinish(); 59 60 </script> 61 </pre> 62 </body> 63 64 </html>