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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/svg/dom/SVGLength-viewport-units.html
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGLength-viewport-units.html b/third_party/WebKit/LayoutTests/svg/dom/SVGLength-viewport-units.html
new file mode 100644
index 0000000000000000000000000000000000000000..b7c29228a8e572504d04e5c4d57ee7822ffbca23
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGLength-viewport-units.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<svg width="1" height="1" visibility="hidden">
+</svg>
+<script>
+var svgElement = document.querySelector("svg");
+var viewportWidth = window.innerWidth;
+var viewportHeight = window.innerHeight;
+var EPSILON = Math.pow(2, -8);
+
+function viewportWidthPercent()
+{
+ return (viewportWidth / 100);
+}
+
+function viewportHeightPercent()
+{
+ return (viewportHeight / 100);
+}
+
+function viewportMinPercent()
+{
+ return (Math.min(viewportWidth, viewportHeight) / 100);
+}
+
+function viewportMaxPercent()
+{
+ return (Math.max(viewportWidth, viewportHeight) / 100);
+}
+
+test(function() {
+ svgElement.setAttribute("width", "10vw");
+ assert_approx_equals(svgElement.width.baseVal.value, 10 * viewportWidthPercent(), EPSILON);
+ assert_equals(svgElement.width.baseVal.valueInSpecifiedUnits, 10);
+ assert_throws(null, function() {svgElement.width.baseVal.valueAsString = '2vw'});
+ svgElement.width.baseVal.valueInSpecifiedUnits = 2;
+ assert_approx_equals(svgElement.width.baseVal.value, 2 * viewportWidthPercent(), EPSILON);
+ assert_equals(svgElement.width.baseVal.unitType, SVGLength.SVG_LENGTHTYPE_UNKNOWN);
+}, "Tests vw unit");
+
+test(function() {
+ svgElement.setAttribute("width", "10vh");
+ assert_approx_equals(svgElement.width.baseVal.value, 10 * viewportHeightPercent(), EPSILON);
+ assert_equals(svgElement.width.baseVal.valueInSpecifiedUnits, 10);
+ assert_throws(null, function() {svgElement.width.baseVal.valueAsString = '2vh'});
+ svgElement.width.baseVal.valueInSpecifiedUnits = 2;
+ assert_approx_equals(svgElement.width.baseVal.value, 2 * viewportHeightPercent(), EPSILON);
+ assert_equals(svgElement.width.baseVal.unitType, SVGLength.SVG_LENGTHTYPE_UNKNOWN);
+}, "Tests vh unit");
+
+test(function() {
+ svgElement.setAttribute("width", "10vmin");
+ assert_approx_equals(svgElement.width.baseVal.value, 10 * viewportMinPercent(), EPSILON);
+ assert_equals(svgElement.width.baseVal.valueInSpecifiedUnits, 10);
+ assert_throws(null, function() {svgElement.width.baseVal.valueAsString = '2vmin'});
+ svgElement.width.baseVal.valueInSpecifiedUnits = 2;
+ assert_approx_equals(svgElement.width.baseVal.value, 2 * viewportMinPercent(), EPSILON);
+ assert_equals(svgElement.width.baseVal.unitType, SVGLength.SVG_LENGTHTYPE_UNKNOWN);
+}, "Tests vmin unit");
+
+test(function() {
+ svgElement.setAttribute("width", "10vmax");
+ assert_approx_equals(svgElement.width.baseVal.value, 10 * viewportMaxPercent(), EPSILON);
+ assert_equals(svgElement.width.baseVal.valueInSpecifiedUnits, 10);
+ assert_throws(null, function() {svgElement.width.baseVal.valueAsString = '2vmax'});
+ svgElement.width.baseVal.valueInSpecifiedUnits = 2;
+ assert_approx_equals(svgElement.width.baseVal.value, 2 * viewportMaxPercent(), EPSILON);
+ assert_equals(svgElement.width.baseVal.unitType, SVGLength.SVG_LENGTHTYPE_UNKNOWN);
+}, "Tests vmax unit");
+
+</script>
« 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