OLD | NEW |
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="../js/resources/js-test-pre.js"></script> | 4 <script src="../js/resources/js-test-pre.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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 shouldBe("testBitmap.height", "imageHeight"); | 131 shouldBe("testBitmap.height", "imageHeight"); |
132 | 132 |
133 imageBitmapLoaded = true; | 133 imageBitmapLoaded = true; |
134 loaded(); | 134 loaded(); |
135 } | 135 } |
136 | 136 |
137 function loaded() { | 137 function loaded() { |
138 if (imageLoaded && imageBitmapLoaded) { | 138 if (imageLoaded && imageBitmapLoaded) { |
139 // check all of these elements | 139 // check all of these elements |
140 elements = [image, aCanvas, d, aCtx, testBitmap]; | 140 elements = [image, aCanvas, d, aCtx, testBitmap]; |
| 141 |
141 // wait for callback to finish before each check to ensure synchronous b
ehavior | 142 // wait for callback to finish before each check to ensure synchronous b
ehavior |
142 nextCheck(0); | 143 nextCheck(0); |
143 } | 144 } |
144 } | 145 } |
145 | 146 |
146 function nextCheck(elementIndex) { | 147 function nextCheck(elementIndex) { |
147 if (elementIndex == elements.length) { | 148 if (elementIndex == elements.length) { |
148 finishJSTest(); | 149 finishJSTest(); |
149 return; | 150 return; |
150 } | 151 } |
(...skipping 12 matching lines...) Expand all Loading... |
163 Promise.every(p1, p2, p3, p4, p5, p6, p7, p8, p9).then(function() { | 164 Promise.every(p1, p2, p3, p4, p5, p6, p7, p8, p9).then(function() { |
164 checkNoCrop(imageBitmaps.noCrop); | 165 checkNoCrop(imageBitmaps.noCrop); |
165 checkCrop(imageBitmaps.crop); | 166 checkCrop(imageBitmaps.crop); |
166 checkCropCenter(imageBitmaps.cropCenter); | 167 checkCropCenter(imageBitmaps.cropCenter); |
167 checkCropRight(imageBitmaps.cropRight); | 168 checkCropRight(imageBitmaps.cropRight); |
168 checkOverCrop(imageBitmaps.overCrop); | 169 checkOverCrop(imageBitmaps.overCrop); |
169 checkOverCropRight(imageBitmaps.overCropRight); | 170 checkOverCropRight(imageBitmaps.overCropRight); |
170 checkCrop(imageBitmaps.negativeCrop); | 171 checkCrop(imageBitmaps.negativeCrop); |
171 checkEmpty(imageBitmaps.empty); | 172 checkEmpty(imageBitmaps.empty); |
172 checkEmpty(imageBitmaps.emptyTwo); | 173 checkEmpty(imageBitmaps.emptyTwo); |
173 checkImmutable(imageBitmaps.noCrop, elementIndex); | |
174 nextCheck(elementIndex + 1); | 174 nextCheck(elementIndex + 1); |
175 }, function() { | 175 }, function() { |
176 testFailed("createImageBitmap promise rejected."); | 176 testFailed("createImageBitmap promise rejected."); |
177 finishJSTest(); | 177 finishJSTest(); |
178 }); | 178 }); |
179 } | 179 } |
180 | 180 |
181 function checkNoCrop(imageBitmap) { | 181 function checkNoCrop(imageBitmap) { |
182 debug("Check no crop."); | 182 debug("Check no crop."); |
183 bitmap = imageBitmap; | 183 bitmap = imageBitmap; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 shouldBe("bitmap.height", "30"); | 387 shouldBe("bitmap.height", "30"); |
388 | 388 |
389 // nothing should be drawn | 389 // nothing should be drawn |
390 clearContext(ctx); | 390 clearContext(ctx); |
391 ctx.drawImage(imageBitmap, 0, 0); | 391 ctx.drawImage(imageBitmap, 0, 0); |
392 shouldBeClear(1, 1); | 392 shouldBeClear(1, 1); |
393 shouldBeClear(9, 9); | 393 shouldBeClear(9, 9); |
394 shouldBeClear(11, 11); | 394 shouldBeClear(11, 11); |
395 shouldBeClear(22, 22); | 395 shouldBeClear(22, 22); |
396 } | 396 } |
397 | |
398 function checkImmutable(imageBitmap, elementIndex) { | |
399 debug("Check immutable."); | |
400 // change the underlying element to ensure that it does not change the image
Bitmap | |
401 switch(elementIndex) { | |
402 case 0: // image | |
403 image = new Image(); | |
404 break; | |
405 case 1: // canvas | |
406 clearContext(aCtx); | |
407 break; | |
408 case 2: // data | |
409 d = 0; | |
410 break; | |
411 case 3: // context | |
412 clearContext(aCtx); | |
413 break; | |
414 case 4: // bitmap | |
415 testBitmap = 0; | |
416 break; | |
417 default: | |
418 testFailed("Default should not be called."); | |
419 } | |
420 // should be drawn to (0, 0), (20, 20) | |
421 checkNoCrop(imageBitmap); | |
422 drawPattern(aCtx); | |
423 } | |
424 | |
425 </script> | 397 </script> |
426 <script src="../js/resources/js-test-post.js"></script> | 398 <script src="../js/resources/js-test-post.js"></script> |
427 </body> | 399 </body> |
428 </html> | 400 </html> |
OLD | NEW |