file_bug1777572.html (1388B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Security-Policy" content="img-src https://*;"> 5 <script> 6 async function timeout (cmd) { 7 const timer = new Promise((resolve, reject) => { 8 const id = setTimeout(() => { 9 clearTimeout(id) 10 reject(new Error('Promise timed out!')) 11 }, 750) 12 }) 13 return Promise.race([cmd, timer]) 14 } 15 16 let ourOpener = window.opener; 17 18 if (location.search.includes("close")) { 19 window.close(); 20 } 21 22 document.addEventListener('DOMContentLoaded', async () => { 23 const frame = document.createElementNS('http://www.w3.org/1999/xhtml', 'frame'); 24 const image = document.createElementNS('http://www.w3.org/2000/svg', 'image'); 25 document.documentElement.appendChild(frame) 26 image.setAttribute('href', 'a.png') 27 for (let i = 0; i < 5; ++i) { 28 try { await timeout(image.decode()) } catch (e) {} 29 } 30 let w = window.open(); 31 // Need to run SpecialPowers in the newly opened window to avoid 32 // .wrap throwing because of dead objects. 33 let csp = w.eval("SpecialPowers.wrap(document).cspJSON;"); 34 ourOpener.postMessage(csp, "*"); 35 w.close(); 36 37 if (!location.search.includes("close")) { 38 window.close(); 39 } 40 }) 41 </script> 42 </head> 43 </html>