Chromium Code Reviews| Index: LayoutTests/fast/dom/HTMLImageElement/image-natural-width-height-svg.html |
| diff --git a/LayoutTests/fast/dom/HTMLImageElement/image-natural-width-height-svg.html b/LayoutTests/fast/dom/HTMLImageElement/image-natural-width-height-svg.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..387fd2acb9a5e848bd4b3d05b27fe163c677e9df |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/HTMLImageElement/image-natural-width-height-svg.html |
| @@ -0,0 +1,42 @@ |
| +<!DOCTYPE html> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<style> |
| +img { |
| + width: 200px; |
| +} |
| +</style> |
| +<body></body> |
| +<script> |
| +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.
|
| + var s = "<svg xmlns='http://www.w3.org/2000/svg' "; |
| + s += dimension; |
| + s += "><circle cx='50%' cy='50%' r='50%' fill='blue'/></svg>"; |
| + return "data:image/svg+xml," + encodeURIComponent(s); |
| +} |
| + |
| +function makeTest(dimensions, expected, description) { |
| + var t = async_test("naturalWidth/Height of SVG in <img>, " + description); |
| + var img = document.body.appendChild(new Image()); |
| + img.onload = t.step_func(function() { |
| + 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"
|
| + assert_equals(img.naturalHeight, expected.height, 'naturalHeight'); |
| + |
| + requestAnimationFrame(function() { |
| + setTimeout(t.step_func(function() { |
| + assert_equals(img.naturalWidth, expected.width, 'naturalWidth'); |
| + assert_equals(img.naturalHeight, expected.height, 'naturalHeight'); |
| + t.done(); |
| + }), 0); |
| + }); |
| + }); |
| + img.src = makeSvgImageUrl(dimensions); |
| +} |
| + |
| +makeTest("width='500' height='400'", { width: 500, height: 400 }, "width/height in pixels"); |
| +makeTest("width='500'", { width: 500, height: 0 }, "width in pixels; height unspecified"); |
|
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
|
| +makeTest("width='500' height='100%'", { width: 500, height: 0 }, "width in pixels; percentage height"); |
| +makeTest("width='500' height='400' viewBox='0 0 800 600'", { width: 500, height: 400 }, "width/height in pixels; viewBox"); |
| +makeTest("viewBox='0 0 800 600'", { width: 0, height: 0 }, "width/height unspecified; viewBox"); |
| +makeTest("width='400' viewBox='0 0 800 600'", { width: 400, height: 0 }, "width in pixels; height unspecified; viewBox"); |
| +</script> |