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

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: rebaseline 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..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>
+

Powered by Google App Engine
This is Rietveld 408576698