security.pattern.fillStyle.sub.html (2027B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> 3 <title>Canvas test: security.pattern.canvas.fillStyle.cross</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/common/get-host-info.sub.js"></script> 7 <script src="/common/media.js"></script> 8 <script src="/html/canvas/resources/canvas-tests.js"></script> 9 10 <body> 11 <p class="desc">Setting fillStyle to a pattern of an unclean canvas makes the canvas origin-unclean</p> 12 13 <script> 14 15 forEachCanvasSource(get_host_info().HTTP_REMOTE_ORIGIN, 16 get_host_info().HTTP_ORIGIN, 17 (name, factory) => { 18 promise_test(_ => { 19 return factory().then(source => { 20 const canvas = document.createElement('canvas'); 21 const ctx = canvas.getContext('2d'); 22 const pattern = ctx.createPattern(source, 'repeat'); 23 ctx.fillStyle = pattern; 24 ctx.fillStyle = 'red'; 25 assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); 26 assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); 27 }); 28 }, `${name}: Setting fillStyle to an origin-unclean pattern makes the canvas origin-unclean`); 29 }); 30 31 forEachCanvasSource(get_host_info().HTTP_REMOTE_ORIGIN, 32 get_host_info().HTTP_ORIGIN, 33 (name, factory) => { 34 promise_test(_ => { 35 return factory().then(source => { 36 const pattern = new OffscreenCanvas(10, 10) 37 .getContext('2d') 38 .createPattern(source, 'repeat'); 39 40 const canvas = document.createElement('canvas'); 41 const ctx = canvas.getContext('2d'); 42 ctx.fillStyle = pattern; 43 ctx.fillStyle = 'red'; 44 assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); 45 assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); 46 }); 47 }, `${name}: Setting fillStyle to an origin-unclean offscreen canvas pattern makes the canvas origin-unclean`); 48 }); 49 50 </script>