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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGLength-viewport-units.html

Issue 1544543003: Adding support of viewport units to SVG (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Align with review comments Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <svg width="1" height="1" visibility="hidden">
5 </svg>
6 <script>
7 var svgElement = document.querySelector("svg");
8 var viewportWidth = window.innerWidth;
9 var viewportHeight = window.innerHeight;
10 var EPSILON = Math.pow(2, -8);
11
12 function viewportWidthPercent()
13 {
14 return (viewportWidth / 100);
15 }
16
17 function viewportHeightPercent()
18 {
19 return (viewportHeight / 100);
20 }
21
22 function viewportMinPercent()
23 {
24 return (Math.min(viewportWidth, viewportHeight) / 100);
25 }
26
27 function viewportMaxPercent()
28 {
29 return (Math.max(viewportWidth, viewportHeight) / 100);
30 }
31
32 test(function() {
33 svgElement.setAttribute("width", "10vw");
34 assert_approx_equals(svgElement.width.baseVal.value, 10 * viewportWidthPerce nt(), EPSILON);
35 assert_equals(svgElement.width.baseVal.valueInSpecifiedUnits, 10);
36 assert_throws(null, function() {svgElement.width.baseVal.valueAsString = '2v w'});
37 svgElement.width.baseVal.valueInSpecifiedUnits = 2;
38 assert_approx_equals(svgElement.width.baseVal.value, 2 * viewportWidthPercen t(), EPSILON);
39 assert_equals(svgElement.width.baseVal.unitType, SVGLength.SVG_LENGTHTYPE_UN KNOWN);
40 }, "Tests vw unit");
41
42 test(function() {
43 svgElement.setAttribute("width", "10vh");
44 assert_approx_equals(svgElement.width.baseVal.value, 10 * viewportHeightPerc ent(), EPSILON);
45 assert_equals(svgElement.width.baseVal.valueInSpecifiedUnits, 10);
46 assert_throws(null, function() {svgElement.width.baseVal.valueAsString = '2v h'});
47 svgElement.width.baseVal.valueInSpecifiedUnits = 2;
48 assert_approx_equals(svgElement.width.baseVal.value, 2 * viewportHeightPerce nt(), EPSILON);
49 assert_equals(svgElement.width.baseVal.unitType, SVGLength.SVG_LENGTHTYPE_UN KNOWN);
50 }, "Tests vh unit");
51
52 test(function() {
53 svgElement.setAttribute("width", "10vmin");
54 assert_approx_equals(svgElement.width.baseVal.value, 10 * viewportMinPercent (), EPSILON);
55 assert_equals(svgElement.width.baseVal.valueInSpecifiedUnits, 10);
56 assert_throws(null, function() {svgElement.width.baseVal.valueAsString = '2v min'});
57 svgElement.width.baseVal.valueInSpecifiedUnits = 2;
58 assert_approx_equals(svgElement.width.baseVal.value, 2 * viewportMinPercent( ), EPSILON);
59 assert_equals(svgElement.width.baseVal.unitType, SVGLength.SVG_LENGTHTYPE_UN KNOWN);
60 }, "Tests vmin unit");
61
62 test(function() {
63 svgElement.setAttribute("width", "10vmax");
64 assert_approx_equals(svgElement.width.baseVal.value, 10 * viewportMaxPercent (), EPSILON);
65 assert_equals(svgElement.width.baseVal.valueInSpecifiedUnits, 10);
66 assert_throws(null, function() {svgElement.width.baseVal.valueAsString = '2v max'});
67 svgElement.width.baseVal.valueInSpecifiedUnits = 2;
68 assert_approx_equals(svgElement.width.baseVal.value, 2 * viewportMaxPercent( ), EPSILON);
69 assert_equals(svgElement.width.baseVal.unitType, SVGLength.SVG_LENGTHTYPE_UN KNOWN);
70 }, "Tests vmax unit");
71
72 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698