test_image_clone_load.html (785B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Test for image clones doing their load</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id="log"></div> 7 <script> 8 var t = async_test("The clone of an image should do the load of the same image, and do it synchronously"); 9 t.step(function() { 10 var img = new Image(); 11 img.onload = t.step_func(function() { 12 var clone = img.cloneNode(); 13 assert_not_equals(img.naturalWidth, 0, "Should have a width"); 14 assert_equals(clone.naturalWidth, img.naturalWidth, 15 "Clone should have a width too"); 16 // And make sure the clone fires onload too, which happens async. 17 clone.onload = function() { t.done() } 18 }); 19 img.src = "image.png"; 20 }); 21 </script>