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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-resize.html

Issue 2738773004: No longer clamp setTimeout(..., 0) to 1ms. (Closed)
Patch Set: update webgl2 conformance expectations as well Created 3 years, 8 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 <title>Test resizing an OffscreenCanvas with a 2d context</title> 2 <title>Test resizing an OffscreenCanvas with a 2d context</title>
3 <script src="../../resources/testharness.js"></script> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 5
6 <script> 6 <script>
7 test(function() { 7 test(function() {
8 var canvas = new OffscreenCanvas(10, 20); 8 var canvas = new OffscreenCanvas(10, 20);
9 canvas.width = 30; 9 canvas.width = 30;
10 canvas.height = 40; 10 canvas.height = 40;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 t.step(function() { 86 t.step(function() {
87 // Verify that the placeholder was not updated synchronously. 87 // Verify that the placeholder was not updated synchronously.
88 assert_equals(image.width, 10); 88 assert_equals(image.width, 10);
89 assert_equals(image.height, 20); 89 assert_equals(image.height, 20);
90 }); 90 });
91 asyncStepsCompleted = asyncStepsCompleted + 1; 91 asyncStepsCompleted = asyncStepsCompleted + 1;
92 if (asyncStepsCompleted == 2) { 92 if (asyncStepsCompleted == 2) {
93 t.done(); 93 t.done();
94 } 94 }
95 }); 95 });
96 // Set timeout acts as a sync barrier to allow commit to propagate 96 // TODO(junov): Use the Promise returned by commit to schedule after the
97 setTimeout(function(){ 97 // commit. (crbug.com/709484)
98 t.step(function() { 98 setTimeout(function() {
99 // Verify that commit() asynchronously updates the size of its placeholder canvas. 99 setTimeout(function() {
100 assert_equals(placeholder.width, 10);
101 assert_equals(placeholder.height, 20);
102 });
103 t.step(function() {
104 // Verify that width/height attributes are still settable even though they have no effect.
105 placeholder.width = 50;
106 placeholder.height = 60;
107 assert_equals(placeholder.width, 50);
108 assert_equals(placeholder.height, 60);
109 });
110 createImageBitmap(placeholder).then(image => {
111 t.step(function() { 100 t.step(function() {
112 // Verify that an image grabbed from the placeholder has the correct dim ensions 101 // Verify that commit() asynchronously updates the size of its placehold er canvas.
113 assert_equals(image.width, 30); 102 assert_equals(placeholder.width, 10);
114 assert_equals(image.height, 40); 103 assert_equals(placeholder.height, 20);
115 }); 104 });
116 asyncStepsCompleted = asyncStepsCompleted + 1; 105 t.step(function() {
117 if (asyncStepsCompleted == 2) { 106 // Verify that width/height attributes are still settable even though th ey have no effect.
118 t.done(); 107 placeholder.width = 50;
119 } 108 placeholder.height = 60;
120 }); 109 assert_equals(placeholder.width, 50);
110 assert_equals(placeholder.height, 60);
111 });
112 createImageBitmap(placeholder).then(image => {
113 t.step(function() {
114 // Verify that an image grabbed from the placeholder has the correct d imensions
115 assert_equals(image.width, 30);
116 assert_equals(image.height, 40);
117 });
118 asyncStepsCompleted = asyncStepsCompleted + 1;
119 if (asyncStepsCompleted == 2) {
120 t.done();
121 }
122 });
123 }, 0);
121 }, 0); 124 }, 0);
122 }, "Verify that resizing an OffscreenCanvas with a 2d context propagates the new size to its placeholder canvas asynchronously, upon commit."); 125 }, "Verify that resizing an OffscreenCanvas with a 2d context propagates the new size to its placeholder canvas asynchronously, upon commit.");
123 126
124 async_test(function(t) { 127 async_test(function(t) {
125 var placeholder = document.createElement('canvas'); 128 var placeholder = document.createElement('canvas');
126 placeholder.width = 10; 129 placeholder.width = 10;
127 placeholder.height = 20; 130 placeholder.height = 20;
128 var offscreen = placeholder.transferControlToOffscreen(); 131 var offscreen = placeholder.transferControlToOffscreen();
129 var ctx = offscreen.getContext('webgl'); 132 var ctx = offscreen.getContext('webgl');
130 t.step(function() { 133 t.step(function() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 t.step(function() { 176 t.step(function() {
174 // Verify that an image grabbed from the placeholder has the correct dim ensions 177 // Verify that an image grabbed from the placeholder has the correct dim ensions
175 assert_equals(image.width, 30); 178 assert_equals(image.width, 30);
176 assert_equals(image.height, 40); 179 assert_equals(image.height, 40);
177 }); 180 });
178 asyncStepsCompleted = asyncStepsCompleted + 1; 181 asyncStepsCompleted = asyncStepsCompleted + 1;
179 if (asyncStepsCompleted == 2) { 182 if (asyncStepsCompleted == 2) {
180 t.done(); 183 t.done();
181 } 184 }
182 }); 185 });
183 }, 0); 186 }, 1);
184 }, "Verify that resizing an OffscreenCanvas with a webgl context propagates the new size to its placeholder canvas asynchronously, upon commit."); 187 }, "Verify that resizing an OffscreenCanvas with a webgl context propagates the new size to its placeholder canvas asynchronously, upon commit.");
185 188
186 async_test(function(t){ 189 async_test(function(t){
187 var placeholder = document.createElement('canvas'); 190 var placeholder = document.createElement('canvas');
188 placeholder.width = 1; 191 placeholder.width = 1;
189 placeholder.height = 1; 192 placeholder.height = 1;
190 var offscreen = placeholder.transferControlToOffscreen(); 193 var offscreen = placeholder.transferControlToOffscreen();
191 var ctx = offscreen.getContext('2d'); 194 var ctx = offscreen.getContext('2d');
192 offscreen.width = offscreen.height = 10; 195 offscreen.width = offscreen.height = 10;
193 ctx.fillStyle = '#0f0'; 196 ctx.fillStyle = '#0f0';
194 ctx.fillRect(0, 0, 10, 10); 197 ctx.fillRect(0, 0, 10, 10);
195 ctx.commit(); 198 ctx.commit();
196 // Set timeout acts as a sync barrier to allow commit to propagate 199 // Set timeout acts as a sync barrier to allow commit to propagate
197 setTimeout(function(){ 200 setTimeout(function(){
198 var testCanvas = document.createElement('canvas'); 201 var testCanvas = document.createElement('canvas');
199 testCanvas.width = testCanvas.height = 20; 202 testCanvas.width = testCanvas.height = 20;
200 testCtx = testCanvas.getContext('2d'); 203 testCtx = testCanvas.getContext('2d');
201 testCtx.drawImage(placeholder, 0, 0); 204 testCtx.drawImage(placeholder, 0, 0);
202 var pixel1 = testCtx.getImageData(9, 9, 1, 1).data; 205 var pixel1 = testCtx.getImageData(9, 9, 1, 1).data;
203 var pixel2 = testCtx.getImageData(9, 10, 1, 1).data; 206 var pixel2 = testCtx.getImageData(9, 10, 1, 1).data;
204 var pixel3 = testCtx.getImageData(10, 9, 1, 1).data; 207 var pixel3 = testCtx.getImageData(10, 9, 1, 1).data;
205 t.step(function() { 208 t.step(function() {
206 assert_equals(placeholder.width, 1); 209 assert_equals(placeholder.width, 1);
207 assert_equals(placeholder.height, 1); 210 assert_equals(placeholder.height, 1);
208 assert_array_equals(pixel1, [0, 255, 0, 255]); 211 assert_array_equals(pixel1, [0, 255, 0, 255]);
209 assert_array_equals(pixel2, [0, 0, 0, 0]); 212 assert_array_equals(pixel2, [0, 0, 0, 0]);
210 assert_array_equals(pixel3, [0, 0, 0, 0]); 213 assert_array_equals(pixel3, [0, 0, 0, 0]);
211 }); 214 });
212 t.done(); 215 t.done();
213 }); 216 }, 1);
214 217
215 }, "Verify that drawImage uses the size of the committed frame as the intinsic s ize of a placeholder canvas."); 218 }, "Verify that drawImage uses the size of the committed frame as the intinsic s ize of a placeholder canvas.");
216 </script> 219 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698