Bug 1400487 - Move img src declaration after onload and onerror declaration in file_meta_element.html. r=ckerschb, a=test-only
authorvinoth <cegvinoth@gmail.com>
Thu, 29 Mar 2018 15:22:53 -0400
changeset 776124 53f99c14e98c2048ed1ac8dd888bcf1a75e9d955
parent 776123 56f03343f294de37c563836d010a6d10946b0c92
child 776125 a44672d0cf7c92be218ae11e0504a751bb42b6b2
push id104821
push userbmo:rrosario@mozilla.com
push dateMon, 02 Apr 2018 18:45:53 +0000
reviewersckerschb, test-only
bugs1400487
milestone60.0
Bug 1400487 - Move img src declaration after onload and onerror declaration in file_meta_element.html. r=ckerschb, a=test-only
dom/security/test/csp/file_meta_element.html
--- a/dom/security/test/csp/file_meta_element.html
+++ b/dom/security/test/csp/file_meta_element.html
@@ -4,22 +4,24 @@
   <meta charset="utf-8">
   <meta http-equiv="Content-Security-Policy"
         content= "img-src 'none'; script-src 'unsafe-inline'; report-uri http://www.example.com; frame-ancestors https:; sandbox allow-scripts">
   <title>Bug 663570 - Implement Content Security Policy via meta tag</title>
 </head>
 <body>
 
   <!-- try to load an image which is forbidden by meta CSP -->
-  <img id="testimage" src="http://mochi.test:8888/tests/image/test/mochitest/blue.png"></img>
+  <img id="testimage"></img>
 
   <script type="application/javascript">
     var myImg = document.getElementById("testimage");
     myImg.onload = function(e) {
       window.parent.postMessage({result: "img-loaded"}, "*");
     };
     myImg.onerror = function(e) {
       window.parent.postMessage({result: "img-blocked"}, "*");
     };
+    //Image should be tried to load only after onload/onerror event declaration.
+    myImg.src = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
   </script>
 
 </body>
 </html>