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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/alpha.html

Issue 2671853004: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Corrections Created 3 years, 10 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
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
5 <style> 6 <style>
6 7
7 #canvas3 { 8 #canvas3 {
8 width : 100px; 9 width : 100px;
9 height : 100px; 10 height : 100px;
10 border : 1px solid green; 11 border : 1px solid green;
11 } 12 }
12 13
13 </style> 14 </style>
14 </head>
15 <body>
16 <canvas id="canvas1" width="8" height="8"></canvas> 15 <canvas id="canvas1" width="8" height="8"></canvas>
17 <canvas id="canvas2" width="8" height="8"></canvas> 16 <canvas id="canvas2" width="8" height="8"></canvas>
18 <canvas id="canvas3" width="8" height="8"></canvas> 17 <canvas id="canvas3" width="8" height="8"></canvas>
19 <canvas id="canvas4" width="8" height="8"></canvas> 18 <canvas id="canvas4" width="8" height="8"></canvas>
20 <script src="alpha.js"></script> 19 </head>
20 <body>
21 <script>
22 test(function(t) {
23 var canvas1 = document.getElementById('canvas1');
24 var canvas2 = document.getElementById('canvas2');
25 var canvas3 = document.getElementById('canvas3');
26 var canvas4 = document.getElementById('canvas4');
27
28 var ctx1 = canvas1.getContext('2d');
29 var ctx2 = canvas2.getContext('2d', {} );
30 var ctx3 = canvas3.getContext('2d', { alpha: false } );
31 var ctx4 = canvas4.getContext('2d', { alpha: true } );
32
33 assert_equals(ctx1.getContextAttributes().alpha,true);
34 var imgData1 = ctx1.getImageData(0, 0, 1, 1);
35 assert_equals(imgData1.data[0],0);
36 assert_equals(imgData1.data[1],0);
37 assert_equals(imgData1.data[2],0);
38 assert_equals(imgData1.data[3],0);
39
40 assert_equals(ctx2.getContextAttributes().alpha,true);
41 var imgData2 = ctx2.getImageData(0, 0, 1, 1);
42 assert_equals(imgData2.data[0],0);
43 assert_equals(imgData2.data[1],0);
44 assert_equals(imgData2.data[2],0);
45 assert_equals(imgData2.data[3],0);
46
47 assert_equals(ctx3.getContextAttributes().alpha,false);
48 assert_equals(ctx4.getContextAttributes().alpha,true);
49
50 var imgData4 = ctx4.getImageData(0, 0, 1, 1);
51 assert_equals(imgData4.data[0],0);
52 assert_equals(imgData4.data[1],0);
53 assert_equals(imgData4.data[2],0);
54 assert_equals(imgData4.data[3],0);
55
56 // Check that mutating the returned value of getContextAttributes() doesn't
57 // affect the existing canvas, or the values of subsequent calls to
58 // getContextAttributes().
59 var attrs = ctx4.getContextAttributes();
60 assert_equals(attrs.alpha,true);
61 attrs.alpha = false;
62
63 var imgData4 = ctx4.getImageData(0, 0, 1, 1);
64 assert_equals(ctx4.getContextAttributes().alpha,true);
65 assert_equals(imgData4.data[0],0);
66 assert_equals(imgData4.data[1],0);
67 assert_equals(imgData4.data[2],0);
68 assert_equals(imgData4.data[3],0);
69 }, 'Series of tests for canvas alpha');
70 </script>
21 </body> 71 </body>
22 </html> 72 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698