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

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

Issue 2515623003: Stop OffscreenCanvas resize from changing placeholder attributes (Closed)
Patch Set: report correct intrinsic size Created 4 years, 1 month 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferControlToOffscreen.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 assert_equals(offscreen.height, 40); 73 assert_equals(offscreen.height, 40);
74 var image = offscreen.transferToImageBitmap(); 74 var image = offscreen.transferToImageBitmap();
75 assert_equals(image.width, 30); 75 assert_equals(image.width, 30);
76 assert_equals(image.height, 40); 76 assert_equals(image.height, 40);
77 }); 77 });
78 t.step(function() { 78 t.step(function() {
79 // Verify that setting the size of an OffscreenCanvas does not directly upda te the size of its placeholder canvas. 79 // Verify that setting the size of an OffscreenCanvas does not directly upda te the size of its placeholder canvas.
80 assert_equals(placeholder.width, 10); 80 assert_equals(placeholder.width, 10);
81 assert_equals(placeholder.height, 20); 81 assert_equals(placeholder.height, 20);
82 }); 82 });
83 var asyncStepsCompleted = 0;
83 ctx.commit(); 84 ctx.commit();
84 t.step(function() { 85 createImageBitmap(placeholder).then(image => {
85 // Verify that commit() does not synchronously update the size of its placeh older canvas. 86 t.step(function() {
86 assert_equals(placeholder.width, 10); 87 // Verify that the placeholder was not updated synchronously.
87 assert_equals(placeholder.height, 20); 88 assert_equals(image.width, 10);
89 assert_equals(image.height, 20);
90 });
91 asyncStepsCompleted = asyncStepsCompleted + 1;
92 if (asyncStepsCompleted == 2) {
93 t.done();
94 }
88 }); 95 });
89 // Set timeout acts as a sync barrier to allow commit to propagate 96 // Set timeout acts as a sync barrier to allow commit to propagate
90 setTimeout(function(){ 97 setTimeout(function(){
91 t.step(function() { 98 t.step(function() {
92 // Verify that commit() asynchronously updates the size of its placeholder canvas. 99 // Verify that commit() asynchronously updates the size of its placeholder canvas.
93 assert_equals(placeholder.width, 30); 100 assert_equals(placeholder.width, 10);
94 assert_equals(placeholder.height, 40); 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);
95 }); 109 });
96 createImageBitmap(placeholder).then(image => { 110 createImageBitmap(placeholder).then(image => {
97 t.step(function() { 111 t.step(function() {
98 // Verify that an image grabbed from the placeholder has the correct dim ensions 112 // Verify that an image grabbed from the placeholder has the correct dim ensions
99 assert_equals(image.width, 30); 113 assert_equals(image.width, 30);
100 assert_equals(image.height, 40); 114 assert_equals(image.height, 40);
101 }); 115 });
102 t.done(); 116 asyncStepsCompleted = asyncStepsCompleted + 1;
117 if (asyncStepsCompleted == 2) {
118 t.done();
119 }
103 }); 120 });
104 }, 0); 121 }, 0);
105 }, "Verify that resizing an OffscreenCanvas with a 2d context propagates the new size to its placeholder canvas asynchronously, upon commit."); 122 }, "Verify that resizing an OffscreenCanvas with a 2d context propagates the new size to its placeholder canvas asynchronously, upon commit.");
106 123
107 async_test(function(t) { 124 async_test(function(t) {
108 var placeholder = document.createElement('canvas'); 125 var placeholder = document.createElement('canvas');
109 placeholder.width = 10; 126 placeholder.width = 10;
110 placeholder.height = 20; 127 placeholder.height = 20;
111 var offscreen = placeholder.transferControlToOffscreen(); 128 var offscreen = placeholder.transferControlToOffscreen();
112 var ctx = offscreen.getContext('webgl'); 129 var ctx = offscreen.getContext('webgl');
113 t.step(function() { 130 t.step(function() {
114 // Verify that setting the size of an OffscreenCanvas that has a placeholder works. 131 // Verify that setting the size of an OffscreenCanvas that has a placeholder works.
115 offscreen.width = 30; 132 offscreen.width = 30;
116 offscreen.height = 40; 133 offscreen.height = 40;
117 assert_equals(offscreen.width, 30); 134 assert_equals(offscreen.width, 30);
118 assert_equals(offscreen.height, 40); 135 assert_equals(offscreen.height, 40);
119 var image = offscreen.transferToImageBitmap(); 136 var image = offscreen.transferToImageBitmap();
120 assert_equals(image.width, 30); 137 assert_equals(image.width, 30);
121 assert_equals(image.height, 40); 138 assert_equals(image.height, 40);
122 }); 139 });
123 t.step(function() { 140 t.step(function() {
124 // Verify that setting the size of an OffscreenCanvas does not directly upda te the size of its placeholder canvas. 141 // Verify that setting the size of an OffscreenCanvas does not directly upda te the size of its placeholder canvas.
125 assert_equals(placeholder.width, 10); 142 assert_equals(placeholder.width, 10);
126 assert_equals(placeholder.height, 20); 143 assert_equals(placeholder.height, 20);
127 }); 144 });
145 var asyncStepsCompleted = 0;
128 ctx.commit(); 146 ctx.commit();
129 t.step(function() { 147 createImageBitmap(placeholder).then(image => {
130 // Verify that commit() does not synchronously update the size of its placeh older canvas. 148 t.step(function() {
131 assert_equals(placeholder.width, 10); 149 // Verify that the placeholder was not updated synchronously.
132 assert_equals(placeholder.height, 20); 150 assert_equals(image.width, 10);
151 assert_equals(image.height, 20);
152 });
153 asyncStepsCompleted = asyncStepsCompleted + 1;
154 if (asyncStepsCompleted == 2) {
155 t.done();
156 }
133 }); 157 });
134 // Set timeout acts as a sync barrier to allow commit to propagate 158 // Set timeout acts as a sync barrier to allow commit to propagate
135 setTimeout(function(){ 159 setTimeout(function(){
136 t.step(function() { 160 t.step(function() {
137 // Verify that commit() asynchronously updates the size of its placeholder canvas. 161 // Verify that commit() asynchronously updates the size of its placeholder canvas.
138 assert_equals(placeholder.width, 30); 162 assert_equals(placeholder.width, 10);
139 assert_equals(placeholder.height, 40); 163 assert_equals(placeholder.height, 20);
164 });
165 t.step(function() {
166 // Verify that width/height attributes are still settable even though they have no effect.
167 placeholder.width = 50;
168 placeholder.height = 60;
169 assert_equals(placeholder.width, 50);
170 assert_equals(placeholder.height, 60);
140 }); 171 });
141 createImageBitmap(placeholder).then(image => { 172 createImageBitmap(placeholder).then(image => {
142 t.step(function() { 173 t.step(function() {
143 // Verify that an image grabbed from the placeholder has the correct dim ensions 174 // Verify that an image grabbed from the placeholder has the correct dim ensions
144 assert_equals(image.width, 30); 175 assert_equals(image.width, 30);
145 assert_equals(image.height, 40); 176 assert_equals(image.height, 40);
146 }); 177 });
147 t.done(); 178 asyncStepsCompleted = asyncStepsCompleted + 1;
179 if (asyncStepsCompleted == 2) {
180 t.done();
181 }
148 }); 182 });
149 }, 0); 183 }, 0);
150 }, "Verify that resizing an OffscreenCanvas with a webgl context propagates the new size to its placeholder canvas asynchronously, upon commit."); 184 }, "Verify that resizing an OffscreenCanvas with a webgl context propagates the new size to its placeholder canvas asynchronously, upon commit.");
151 185
186 async_test(function(t){
187 var placeholder = document.createElement('canvas');
188 placeholder.width = 1;
189 placeholder.height = 1;
190 var offscreen = placeholder.transferControlToOffscreen();
191 var ctx = offscreen.getContext('2d');
192 offscreen.width = offscreen.height = 10;
193 ctx.fillStyle = '#0f0';
194 ctx.fillRect(0, 0, 10, 10);
195 ctx.commit();
196 // Set timeout acts as a sync barrier to allow commit to propagate
197 setTimeout(function(){
198 var testCanvas = document.createElement('canvas');
199 testCanvas.width = testCanvas.height = 20;
200 testCtx = testCanvas.getContext('2d');
201 testCtx.drawImage(placeholder, 0, 0);
202 var pixel1 = testCtx.getImageData(9, 9, 1, 1).data;
203 var pixel2 = testCtx.getImageData(9, 10, 1, 1).data;
204 var pixel3 = testCtx.getImageData(10, 9, 1, 1).data;
205 t.step(function() {
206 assert_equals(placeholder.width, 1);
207 assert_equals(placeholder.height, 1);
208 assert_array_equals(pixel1, [0, 255, 0, 255]);
209 assert_array_equals(pixel2, [0, 0, 0, 0]);
210 assert_array_equals(pixel3, [0, 0, 0, 0]);
211 });
212 t.done();
213 });
214
215 }, "Verify that drawImage uses the size of the committed frame as the intinsic s ize of a placeholder canvas.");
152 </script> 216 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferControlToOffscreen.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698