audiocontext-after-unload-1.html (954B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <head> 4 <title>Test for bug 1646601</title> 5 <script> 6 document.addEventListener('DOMContentLoaded', async () => { 7 const frame = document.createElement('iframe'); 8 document.body.appendChild(frame); 9 frame.srcdoc = '<html></html>'; 10 await new Promise(resolve => frame.onload = resolve); 11 const subwin = frame.contentWindow; 12 const subcontext = subwin.AudioContext; 13 // Construct an AudioContext while the subdocument is fully active to start 14 // a MediaTrackGraph. 15 new subcontext(); 16 // Unload the subdocument and wait for completion. 17 // This shuts down the MediaTrackGraph. 18 subwin.location.reload(); 19 await new Promise(resolve => frame.onload = resolve); 20 // Test that a new AudioContext on the inactive subdocument does not attempt 21 // to use the shut-down MediaTrackGraph. 22 try { new subcontext() } catch {} 23 document.documentElement.removeAttribute('class'); 24 }); 25 </script> 26 </head> 27 </html>