test_bug1388015.html (1697B)
1 <!DOCTYPE HTML> 2 <html> 3 4 <head> 5 <title>Bug 1388015 - Test if Firefox respect Port in Wildcard Host </title> 6 <meta http-equiv="Content-Security-Policy" content="img-src https://*:443"> 7 <script src="/tests/SimpleTest/SimpleTest.js"></script> 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 9 </head> 10 11 <body> 12 13 <img alt="Should be Blocked"> 14 <script class="testbody" type="text/javascript"> 15 SimpleTest.waitForExplicitFinish(); 16 17 let image = document.querySelector("img"); 18 19 Promise.race([ 20 new Promise((res) => { 21 window.addEventListener("securitypolicyviolation", () => res(true), {once:true}); 22 }), 23 new Promise((res) => { 24 image.addEventListener("load", () => res(false),{once:true}); 25 })]) 26 .then((result) => { 27 ok(result, " CSP did block Image with wildcard and mismatched Port"); 28 }) 29 .then(()=> Promise.race([ 30 new Promise((res) => { 31 window.addEventListener("securitypolicyviolation", () => res(false), {once:true}); 32 }), 33 new Promise((res) => { 34 image.addEventListener("load", () => res(true),{once:true}); 35 requestIdleCallback(()=>{ 36 image.src = "https://example.com:443/tests/dom/security/test/csp/file_dummy_pixel.png" 37 }) 38 })])) 39 .then((result) => { 40 ok(result, " CSP did load the Image with wildcard and matching Port"); 41 SimpleTest.finish(); 42 }) 43 image.src = "file_dummy_pixel.png" // mochi.test:8888 44 </script> 45 </body> 46 </html>