test_bug1229639.html (1511B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Bug 1229639 - Percent encoded CSP path matching.</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 8 </head> 9 <body> 10 <p id="display"></p> 11 <div id="content" style="display: none"></div> 12 13 <iframe style="width:200px;height:200px;" id='cspframe'></iframe> 14 <script class="testbody" type="text/javascript"> 15 16 // This is used to watch the blocked data bounce off CSP and allowed data 17 // get sent out to the wire. 18 function examiner() { 19 SpecialPowers.addObserver(this, "csp-on-violate-policy"); 20 SpecialPowers.addObserver(this, "specialpowers-http-notify-request"); 21 } 22 23 examiner.prototype = { 24 observe(subject, topic, data) { 25 if (data === 'http://mochi.test:8888/tests/dom/security/test/csp/%24.js') { 26 is(topic, "specialpowers-http-notify-request"); 27 this.remove(); 28 SimpleTest.finish(); 29 } 30 }, 31 32 // must eventually call this to remove the listener, 33 // or mochitests might get borked. 34 remove() { 35 SpecialPowers.removeObserver(this, "csp-on-violate-policy"); 36 SpecialPowers.removeObserver(this, "specialpowers-http-notify-request"); 37 } 38 } 39 40 window.examiner = new examiner(); 41 42 SimpleTest.waitForExplicitFinish(); 43 44 // save this for last so that our listeners are registered. 45 // ... this loads the testbed of good and bad requests. 46 document.getElementById('cspframe').src = 'file_bug1229639.html'; 47 48 </script> 49 </pre> 50 </body> 51 </html>