Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Unified Diff: LayoutTests/fast/dom/HTMLImageElement/image-natural-width-height-svg.html

Issue 422503002: HTMLImageElement.natural{Width,Height} should return intrinsic dimensions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Two more spots... Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLImageElement/image-natural-width-height-svg-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..996faed7ed5fb46a0a91d84d4a6bd58c067b8714
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLImageElement/image-natural-width-height-svg.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<style>
+img {
+ width: 200px;
+}
+</style>
+<body></body>
+<script>
+function makeSvgImageUrl(sizingAttributes) {
+ var s = "<svg xmlns='http://www.w3.org/2000/svg' ";
+ s += sizingAttributes;
+ s += "><circle cx='50%' cy='50%' r='50%' fill='blue'/></svg>";
+ return "data:image/svg+xml," + encodeURIComponent(s);
+}
+
+function assertImageDimensions(img, expected) {
+ assert_equals(img.naturalWidth + "x" + img.naturalHeight, expected.width + "x" + expected.height);
+}
+
+function makeTest(sizingAttributes, 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() {
+ assertImageDimensions(img, expected);
+
+ requestAnimationFrame(function() {
+ setTimeout(t.step_func(function() {
+ assertImageDimensions(img, expected);
+ t.done();
+ }), 0);
+ });
+ });
+ img.src = makeSvgImageUrl(sizingAttributes);
+}
+
+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");
+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>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLImageElement/image-natural-width-height-svg-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698