OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../../resources/testharness.js"></script> | |
3 <script src="../../../resources/testharnessreport.js"></script> | |
4 <style> | |
5 img { | |
6 width: 200px; | |
7 } | |
8 </style> | |
9 <body></body> | |
10 <script> | |
11 function makeSvgImageUrl(dimension) { | |
pdr.
2014/07/25 20:02:56
Maybe call this sizingAttributes instead of dimens
fs
2014/07/28 08:57:00
Done.
| |
12 var s = "<svg xmlns='http://www.w3.org/2000/svg' "; | |
13 s += dimension; | |
14 s += "><circle cx='50%' cy='50%' r='50%' fill='blue'/></svg>"; | |
15 return "data:image/svg+xml," + encodeURIComponent(s); | |
16 } | |
17 | |
18 function makeTest(dimensions, expected, description) { | |
19 var t = async_test("naturalWidth/Height of SVG in <img>, " + description); | |
20 var img = document.body.appendChild(new Image()); | |
21 img.onload = t.step_func(function() { | |
22 assert_equals(img.naturalWidth, expected.width, 'naturalWidth'); | |
pdr.
2014/07/25 20:02:56
Can you assert both the width and the height toget
fs
2014/07/28 08:57:00
Rewrote the assertion(s) to the use the form "WxH"
| |
23 assert_equals(img.naturalHeight, expected.height, 'naturalHeight'); | |
24 | |
25 requestAnimationFrame(function() { | |
26 setTimeout(t.step_func(function() { | |
27 assert_equals(img.naturalWidth, expected.width, 'naturalWidth'); | |
28 assert_equals(img.naturalHeight, expected.height, 'naturalHeight'); | |
29 t.done(); | |
30 }), 0); | |
31 }); | |
32 }); | |
33 img.src = makeSvgImageUrl(dimensions); | |
34 } | |
35 | |
36 makeTest("width='500' height='400'", { width: 500, height: 400 }, "width/height in pixels"); | |
37 makeTest("width='500'", { width: 500, height: 0 }, "width in pixels; height unsp ecified"); | |
pdr.
2014/07/25 20:02:56
I don't have my IE machine with me, but if my netr
fs
2014/07/28 08:57:00
I solicited results for IE (v11) and it seemed to
| |
38 makeTest("width='500' height='100%'", { width: 500, height: 0 }, "width in pixel s; percentage height"); | |
39 makeTest("width='500' height='400' viewBox='0 0 800 600'", { width: 500, height: 400 }, "width/height in pixels; viewBox"); | |
40 makeTest("viewBox='0 0 800 600'", { width: 0, height: 0 }, "width/height unspeci fied; viewBox"); | |
41 makeTest("width='400' viewBox='0 0 800 600'", { width: 400, height: 0 }, "width in pixels; height unspecified; viewBox"); | |
42 </script> | |
OLD | NEW |