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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage.html

Issue 2249853008: Reject createImageBitmap promise when the cropRect or resize is too big (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: debugging Created 4 years, 3 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 PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 8
9 description("Ensure correct behavior of drawImage with ImageBitmaps."); 9 description("Ensure correct behavior of drawImage with ImageBitmaps.");
10 window.jsTestIsAsync = true; 10 window.jsTestIsAsync = true;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 xhr.send(); 146 xhr.send();
147 xhr.onload = function() { 147 xhr.onload = function() {
148 blob = xhr.response; 148 blob = xhr.response;
149 blobLoaded = true; 149 blobLoaded = true;
150 loaded(); 150 loaded();
151 } 151 }
152 152
153 function loaded() { 153 function loaded() {
154 if (imageLoaded && imageBitmapLoaded && blobLoaded) { 154 if (imageLoaded && imageBitmapLoaded && blobLoaded) {
155 // check all of these elements 155 // check all of these elements
156 elements = [image, aCanvas, d, testBitmap, blob]; 156 // elements = [image, aCanvas, d, testBitmap, blob];
157 elements = [blob];
157 // wait for callback to finish before each check to ensure synchronous b ehavior 158 // wait for callback to finish before each check to ensure synchronous b ehavior
158 nextCheck(0); 159 nextCheck(0);
159 } 160 }
160 } 161 }
161 162
162 function nextCheck(elementIndex) { 163 function nextCheck(elementIndex) {
163 if (elementIndex == elements.length) { 164 if (elementIndex == elements.length) {
164 finishJSTest(); 165 finishJSTest();
165 return; 166 return;
166 } 167 }
167 var element = elements[elementIndex]; 168 var element = elements[elementIndex];
168 imageBitmaps = {}; 169 imageBitmaps = {};
169 debug("Checking " + jsWrapperClass(element) + "."); 170 debug("Checking " + jsWrapperClass(element) + ".");
170 var p1 = createImageBitmap(element).then(function (image) { imageBitmaps.noC rop = image }); 171 var p1 = createImageBitmap(element).then(function (image) { imageBitmaps.noC rop = image });
171 var p2 = createImageBitmap(element, 0, 0, 10, 10).then(function (image) { im ageBitmaps.crop = image }); 172 /*var p2 = createImageBitmap(element, 0, 0, 10, 10).then(function (image) { imageBitmaps.crop = image });
172 var p3 = createImageBitmap(element, 5, 5, 10, 10).then(function (image) { im ageBitmaps.cropCenter = image }); 173 var p3 = createImageBitmap(element, 5, 5, 10, 10).then(function (image) { im ageBitmaps.cropCenter = image });
173 var p4 = createImageBitmap(element, 10, 10, 10, 10).then(function (image) { imageBitmaps.cropRight = image }); 174 var p4 = createImageBitmap(element, 10, 10, 10, 10).then(function (image) { imageBitmaps.cropRight = image });
174 var p5 = createImageBitmap(element, -10, -10, 60, 60).then(function (image) { imageBitmaps.overCrop = image }); 175 var p5 = createImageBitmap(element, -10, -10, 60, 60).then(function (image) { imageBitmaps.overCrop = image });
175 var p6 = createImageBitmap(element, 10, 10, 50, 50).then(function (image) { imageBitmaps.overCropRight = image }); 176 var p6 = createImageBitmap(element, 10, 10, 50, 50).then(function (image) { imageBitmaps.overCropRight = image });
176 var p7 = createImageBitmap(element, 10, 10, -10, -10).then(function (image) { imageBitmaps.negativeCrop = image }); 177 var p7 = createImageBitmap(element, 10, 10, -10, -10).then(function (image) { imageBitmaps.negativeCrop = image });
177 var p8 = createImageBitmap(element, -30, -30, 30, 30).then(function (image) { imageBitmaps.empty = image }); 178 var p8 = createImageBitmap(element, -30, -30, 30, 30).then(function (image) { imageBitmaps.empty = image });
178 var p9 = createImageBitmap(element, 40, 30, 30, 30).then(function (image) { imageBitmaps.emptyTwo = image }); 179 var p9 = createImageBitmap(element, 40, 30, 30, 30).then(function (image) { imageBitmaps.emptyTwo = image });
179 Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9]).then(function() { 180 Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9]).then(function() {*/
180 checkNoCrop(imageBitmaps.noCrop); 181 Promise.all([p1]).then(function() {
182 /*checkNoCrop(imageBitmaps.noCrop);
181 checkCrop(imageBitmaps.crop); 183 checkCrop(imageBitmaps.crop);
182 checkCropCenter(imageBitmaps.cropCenter); 184 checkCropCenter(imageBitmaps.cropCenter);
183 checkCropRight(imageBitmaps.cropRight); 185 checkCropRight(imageBitmaps.cropRight);
184 checkOverCrop(imageBitmaps.overCrop); 186 checkOverCrop(imageBitmaps.overCrop);
185 checkOverCropRight(imageBitmaps.overCropRight); 187 checkOverCropRight(imageBitmaps.overCropRight);
186 checkCrop(imageBitmaps.negativeCrop); 188 checkCrop(imageBitmaps.negativeCrop);
187 checkEmpty(imageBitmaps.empty); 189 checkEmpty(imageBitmaps.empty);
188 checkEmpty(imageBitmaps.emptyTwo); 190 checkEmpty(imageBitmaps.emptyTwo);*/
189 createImageBitmap(element, 0, 0, Math.pow(10, 6), Math.pow(10, 6)).then( function() { 191 createImageBitmap(element, 0, 0, 0x8000, 0x8000).then(function() {
190 testFailed('Creating a huge ImageBitmap is resolved unexpectedly.'); 192 testFailed('Creating a huge ImageBitmap is resolved unexpectedly.');
191 finishJSTest(); 193 finishJSTest();
192 }, function() { 194 }, function() {
193 testPassed('Creating a huge ImageBitmap is rejected as expected.'); 195 testPassed('Creating a huge ImageBitmap is rejected as expected.');
194 nextCheck(elementIndex + 1); 196 nextCheck(elementIndex + 1);
195 }); 197 });
196 }, shouldNotBeCalled); 198 }, shouldNotBeCalled);
197 } 199 }
198 200
199 function checkNoCrop(imageBitmap) { 201 function checkNoCrop(imageBitmap) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 ctx.drawImage(imageBitmap, 0, 0); 411 ctx.drawImage(imageBitmap, 0, 0);
410 shouldBeClear(1, 1); 412 shouldBeClear(1, 1);
411 shouldBeClear(9, 9); 413 shouldBeClear(9, 9);
412 shouldBeClear(11, 11); 414 shouldBeClear(11, 11);
413 shouldBeClear(22, 22); 415 shouldBeClear(22, 22);
414 } 416 }
415 417
416 </script> 418 </script>
417 </body> 419 </body>
418 </html> 420 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698