file_autoplay_policy_unmute_pauses.html (1894B)
1 <!DOCTYPE HTML> 2 <html> 3 4 <head> 5 <title>Autoplay policy window</title> 6 <style> 7 video { 8 width: 50%; 9 height: 50%; 10 } 11 </style> 12 <script src="/tests/SimpleTest/SimpleTest.js"></script> 13 <script src="/tests/SimpleTest/EventUtils.js"></script> 14 <script type="text/javascript" src="manifest.js"></script> 15 <script type="text/javascript" src="AutoplayTestUtils.js"></script> 16 </head> 17 18 <body> 19 <pre id="test"> 20 <script> 21 22 window.is = window.opener.is; 23 window.info = window.opener.info; 24 25 function testAutoplayUnmutePauses(testCase) { 26 return new Promise(function (resolve) { 27 28 info("testAutoplayUnmutePauses: " + testCase.property); 29 30 let element = document.createElement("video"); 31 element.preload = "auto"; 32 33 // Make inaudible. 34 element[testCase.property] = testCase.inaudible; 35 36 // Once we've loaded, play, then make audible. 37 // Assert that the media is paused when we make it audible. 38 element.addEventListener("loadeddata", () => { 39 info("loadeddata"); 40 element.play(); 41 is(element.paused, false, testCase.property + "=" + testCase.inaudible + " - should be playing"); 42 element[testCase.property] = testCase.audible; 43 is(element.paused, true, testCase.property + "=" + testCase.audible + " - should be paused."); 44 resolve(); 45 }); 46 47 element.src = "short.mp4"; 48 element.id = "video"; 49 document.body.appendChild(element); 50 }); 51 } 52 53 nextWindowMessage().then( 54 (event) => { 55 testAutoplayUnmutePauses(event.data, event.source) 56 .then(() => { 57 event.source.postMessage("done", "*"); 58 }); 59 }); 60 61 </script> 62 </pre> 63 </body> 64 65 </html>