A canvas should not be tainted if it draws a data URL SVGImage with a <foreignObject>
[WebKit-https.git] / LayoutTests / svg / as-image / svg-canvas-data-url-svg-with-image-not-tainted.html
1 <!DOCTYPE html>
2 <head>
3     <script src="../../resources/js-test-pre.js"></script>
4 </head>
5 <body>
6     <canvas></canvas>
7     <script type="text/javascript">
8         if (window.testRunner)
9             testRunner.dumpAsText();
10
11         jsTestIsAsync = true;
12         description("Canvas should not be tainted if a data url image with a data url &lt;image&gt; which has a &lt;foreignObject&gt; is drawn into the canvas.");
13
14         var data = "data:image/svg+xml;charset=utf-8,"
15                 + '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100px" height="100px">'
16                 + '    <image width="100" height="100" xlink:href="data:image/svg+xml;charset=utf-8;base64,'
17                 + '        PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDBweCIgaGVpZ2h0PSIxMDBweCI+DQog'
18                 + '        ICAgPGZvcmVpZ25PYmplY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSI+DQogICAgICAgIDxkaXYgeG1sbnM9Imh0dHA6'
19                 + '        Ly93d3cudzMub3JnLzE5OTkveGh0bWwiIHN0eWxlPSJ3aWR0aDogMTAwJTsgaGVpZ2h0OiAxMDAlOyBiYWNrZ3JvdW5kLWNv'
20                 + '        bG9yOiBncmVlbjsiPjwvZGl2Pg0KICAgIDwvZm9yZWlnbk9iamVjdD4nDQo8L3N2Zz4NCg0K">'
21                 + '    </image>'
22                 + '</svg>';
23
24         var svg = new Image();
25         svg.onload = function() {
26             var canvas = document.querySelector('canvas');
27             window.ctx = canvas.getContext('2d');
28
29             // Wait for the data uri in the image to load.
30             setTimeout(function() {
31                 ctx.drawImage(svg, 0, 0);
32                 shouldNotThrow("window.ctx.getImageData(0, 0, 1, 1)");
33                 finishJSTest();
34             }, 50);
35         }
36         svg.src = data;
37     </script>
38     <script src="../../resources/js-test-post.js"></script>
39 </body>
40 </html>