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

Unified Diff: third_party/WebKit/LayoutTests/css-parser/serialize-css-alpha-value.html

Issue 2608423002: Fix RGBA alpha parsing and serialization to adhere to W3 standard. (Closed)
Patch Set: NeedsRebaseline for failed layout tests Created 3 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
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..b2e0ae229119c3200f1666a2f92ab4e065f60843
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/css-parser/serialize-css-alpha-value.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<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 should parse and serialize to the same value to 2 decimal places');
+
+test(function() {
+ var testCases = [
+ ['rgba(0, 0, 0, 0.501)', 'rgba(0, 0, 0, 0.5)'],
+ ['rgba(0, 0, 0, 0.011)', 'rgba(0, 0, 0, 0.01)'],
+ ['rgba(0, 0, 0, 0.0041)', 'rgba(0, 0, 0, 0.004)'],
+ ['rgba(0, 0, 0, 0.01601)', 'rgba(0, 0, 0, 0.016)']
+ ];
+ 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);
+ }
+}, 'Alpha values with three or more decimals should parse and serialize to ' +
+ '1, 2, or 3 decimal places according to w3c spec');
+</script>
+

Powered by Google App Engine
This is Rietveld 408576698