Index: third_party/WebKit/LayoutTests/css-parser/serialize-css-alpha-value.html |
diff --git a/third_party/WebKit/LayoutTests/css-parser/serialize-css-alpha-value.html b/third_party/WebKit/LayoutTests/css-parser/serialize-css-alpha-value.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f8594c2ff793fee0b94a82deac355f3bdf257795 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/css-parser/serialize-css-alpha-value.html |
@@ -0,0 +1,32 @@ |
+<!DOCTYPE html> |
+<title>Floating point alpha value parssing and serialization</title> |
sashab
2017/01/06 02:56:16
Do we have lots of other layout tests like this? G
ktyliu
2017/01/08 22:01:09
Removed <title> and fixed documentation in separat
|
+<body> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script> |
+test(function() { |
+ for (var i = 0.0; i <= 1.0; i += 0.01) { |
+ var rgba = 'rgba(0, 0, 0, ' + parseFloat(i.toFixed(2)) + ')'; |
+ document.body.style.color = rgba; |
+ assert_equals(document.body.style.color, rgba); |
+ assert_equals(getComputedStyle(document.body).color, rgba); |
+ } |
+}, 'Alpha values with two decimals should parse and serialize to the same value'); |
sashab
2017/01/06 02:56:16
How about, "Alpha values should parse and serializ
ktyliu
2017/01/08 22:01:09
Done.
|
+ |
+test(function() { |
+ var testCases = [ |
+ ['rgba(0, 0, 0, 0.004)', 'rgba(0, 0, 0, 0.004)'], |
+ ['rgba(0, 0, 0, 0.011)', 'rgba(0, 0, 0, 0.01)'], |
+ ['rgba(0, 0, 0, 0.016)', 'rgba(0, 0, 0, 0.016)'], |
+ ['rgba(0, 0, 0, 0.501)', 'rgba(0, 0, 0, 0.5)'] |
+ ]; |
+ for (var i = 0; i < testCases.length; ++i) { |
+ var rgba = testCases[i][0]; |
+ var expected = testCases[i][1]; |
+ document.body.style.color = rgba; |
+ assert_equals(document.body.style.color, expected); |
+ assert_equals(getComputedStyle(document.body).color, expected); |
+ } |
+}, 'Expected alpha values with three decimals'); |
sashab
2017/01/06 02:56:16
"Alpha values with three decimals should parse and
ktyliu
2017/01/08 22:01:09
Updated wording and also test cases to highlight t
|
+</script> |
+ |