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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <body>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script>
6 test(function() {
7 for (var i = 0.0; i <= 1.0; i += 0.01) {
8 var rgba = 'rgba(0, 0, 0, ' + parseFloat(i.toFixed(2)) + ')';
9 document.body.style.color = rgba;
10 assert_equals(document.body.style.color, rgba);
11 assert_equals(getComputedStyle(document.body).color, rgba);
12 }
13 }, 'Alpha values should parse and serialize to the same value to 2 decimal place s');
14
15 test(function() {
16 var testCases = [
17 ['rgba(0, 0, 0, 0.501)', 'rgba(0, 0, 0, 0.5)'],
18 ['rgba(0, 0, 0, 0.011)', 'rgba(0, 0, 0, 0.01)'],
19 ['rgba(0, 0, 0, 0.0041)', 'rgba(0, 0, 0, 0.004)'],
20 ['rgba(0, 0, 0, 0.01601)', 'rgba(0, 0, 0, 0.016)']
21 ];
22 for (var i = 0; i < testCases.length; ++i) {
23 var rgba = testCases[i][0];
24 var expected = testCases[i][1];
25 document.body.style.color = rgba;
26 assert_equals(document.body.style.color, expected);
27 assert_equals(getComputedStyle(document.body).color, expected);
28 }
29 }, 'Alpha values with three or more decimals should parse and serialize to ' +
30 '1, 2, or 3 decimal places according to w3c spec');
31 </script>
32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698