Bug 1579088 - Do not use img.complete check whether the img is loaded; r=ckerschb
authorEdgar Chen <echen@mozilla.com>
Mon, 09 Sep 2019 17:44:36 +0000
changeset 553746 bdbfce5477b817b6267eb8dd74f0bd2d2899c9b0
parent 553745 8b5aa1f7d1f35feed967c5d0a962bbee95dbf241
child 553747 48cbb73a01add0c158fd17bfe633efd93a7ebd22
push id12169
push userffxbld-merge
push dateMon, 14 Oct 2019 16:59:29 +0000
treeherdermozilla-beta@c819687300ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1579088
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1579088 - Do not use img.complete check whether the img is loaded; r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D44842
dom/security/test/csp/file_strict_dynamic_default_src.html
dom/security/test/csp/test_strict_dynamic_default_src.html
--- a/dom/security/test/csp/file_strict_dynamic_default_src.html
+++ b/dom/security/test/csp/file_strict_dynamic_default_src.html
@@ -3,12 +3,18 @@
 <head>
   <title>Bug 1299483 - CSP: Implement 'strict-dynamic'</title>
 </head>
 <body>
 
 <div id="testdiv">blocked</div>
 <script nonce="foo" src="http://mochi.test:8888/tests/dom/security/test/csp/file_strict_dynamic_default_src.js"></script>
 
-<img id="testimage" src="http://mochi.test:8888/tests/image/test/mochitest/blue.png"></img>
+<img id="testimage" src="http://mochi.test:8888/tests/image/test/mochitest/blue.png" data-result="blocked">
+<script>
+let img = document.getElementById("testimage");
+img.addEventListener("load", function() {
+  img.dataset.result = "allowed";
+}, { once: true });
+</script>
 
 </body>
 </html>
--- a/dom/security/test/csp/test_strict_dynamic_default_src.html
+++ b/dom/security/test/csp/test_strict_dynamic_default_src.html
@@ -100,30 +100,31 @@ function loadNextTest() {
 
 function checkResults() {
   try {
     var testframe = document.getElementById("testframe");
     testframe.removeEventListener('load', checkResults);
 
     // check if script loaded
     var divcontent = testframe.contentWindow.document.getElementById('testdiv').innerHTML;
+    var imgcontent = testframe.contentWindow.document.getElementById('testimage').dataset.result;
     if (curTest.script_result === "blocked") {
       todo_is(divcontent, curTest.script_result, curTest.script_desc);
     }
     else {
       is(divcontent, curTest.script_result, curTest.script_desc);
     }
 
     // check if image loaded
     var testimg = testframe.contentWindow.document.getElementById("testimage");
     if (curTest.img_result === "allowed") {
-      ok(testimg.complete, curTest.img_desc);
+      todo_is(imgcontent, curTest.img_result, curTest.img_desc);
     }
     else {
-      ok((testimg.width == 0) && (testimg.height == 0), curTest.img_desc);
+      is(imgcontent, curTest.img_result, curTest.img_desc);
     }
   }
   catch (e) {
     ok(false, "ERROR: could not access content for test: '" + curTest.script_desc + "'");
   }
 
   loadNextTest();
 }