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-feimage-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;feimage&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                 + '    <defs>'
17                 + '        <filter id="image">'
18                 + '            <feImage xlink:href="data:image/svg+xml;charset=utf-8;base64,'
19                 + '                PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDBweCIgaGVpZ2h0PSIxMDBweCI+DQog'
20                 + '                ICAgPGZvcmVpZ25PYmplY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSI+DQogICAgICAgIDxkaXYgeG1sbnM9Imh0dHA6'
21                 + '                Ly93d3cudzMub3JnLzE5OTkveGh0bWwiIHN0eWxlPSJ3aWR0aDogMTAwJTsgaGVpZ2h0OiAxMDAlOyBiYWNrZ3JvdW5kLWNv'
22                 + '                bG9yOiBncmVlbjsiPjwvZGl2Pg0KICAgIDwvZm9yZWlnbk9iamVjdD4nDQo8L3N2Zz4NCg0K">'
23                 + '            </feImage>'
24                 + '        </filter>'
25                 + '    </defs>'
26                 + '    <rect width="100%" height="100%" style="filter:url(#image);"/>'
27                 + '</svg>';
28
29         var svg = new Image();
30         svg.onload = function() {
31             var canvas = document.querySelector('canvas');
32             window.ctx = canvas.getContext('2d');
33
34             // Wait for the data uri in the image to load.
35             setTimeout(function() {
36                 ctx.drawImage(svg, 0, 0);
37                 shouldNotThrow("window.ctx.getImageData(0, 0, 1, 1)");
38                 finishJSTest();
39             }, 50);
40         }
41         svg.src = data;
42     </script>
43     <script src="../../resources/js-test-post.js"></script>
44 </body>
45 </html>