test_image_crossorigin_data_url.html (1372B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Test for handling of 'crossorigin' attribute on CSS link with data: URL</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id="log"></div> 7 <div id="someuniqueidhere"></div> 8 <img id="testimg" crossorigin src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC"> 9 <script> 10 /* global async_test, assert_equals */ 11 var t = async_test("img@crossorigin with data: src"); 12 window.addEventListener("load", t.step_func_done(function() { 13 var img = document.getElementById("testimg"); 14 assert_equals(img.naturalWidth, 1, "Should have 1px width"); 15 assert_equals(img.naturalHeight, 1, "Should have 1px height"); 16 var c = document.createElement("canvas"); 17 c.width = c.height = 1; 18 var ctx = c.getContext("2d"); 19 ctx.drawImage(img, 0, 0); 20 var data = ctx.getImageData(0, 0, 1, 1); 21 assert_equals(data.width, 1, "Should have 1px data width"); 22 assert_equals(data.height, 1, "Should have 1px data height"); 23 assert_equals(data.data[0], 255, "Should have lots of red"); 24 assert_equals(data.data[1], 0, "Should have no green"); 25 assert_equals(data.data[2], 0, "Should have no blue"); 26 assert_equals(data.data[3], 255, "Should have no translucency"); 27 })); 28 </script>