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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 imageBitmapLoaded = true; | 134 imageBitmapLoaded = true; |
135 loaded(); | 135 loaded(); |
136 } | 136 } |
137 | 137 |
138 function loaded() { | 138 function loaded() { |
139 if (imageLoaded && imageBitmapLoaded) { | 139 if (imageLoaded && imageBitmapLoaded) { |
140 // check all of these elements | 140 // check all of these elements |
141 elements = [image, aCanvas, d, aCtx, testBitmap]; | 141 elements = [image, aCanvas, d, aCtx, testBitmap]; |
142 | 142 |
143 // with all of these checks | 143 // with all of these checks |
144 checks = [checkNoCrop, checkCrop, checkCropRight, checkOverCrop, checkOv
erCropRight, checkNegativeCrop, checkEmpty, checkEmpty2, checkImmutable]; | 144 checks = [checkNoCrop, checkCrop, checkCropRight, checkOverCrop, checkOv
erCropRight, checkNegativeCrop, checkEmpty, checkEmpty2]; |
145 | 145 |
146 // wait for callback to finish before each check to ensure synchronous b
ehavior | 146 // wait for callback to finish before each check to ensure synchronous b
ehavior |
147 nextCheck(); | 147 nextCheck(); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 // these counters are incremented after every check | 151 // these counters are incremented after every check |
152 var i = 0; | 152 var i = 0; |
153 var j = 0; | 153 var j = 0; |
154 var callbackCount = 0; | 154 var callbackCount = 0; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 function checkEmpty(element) { | 195 function checkEmpty(element) { |
196 debug("checkEmpty with ".concat(jsWrapperClass(element))); | 196 debug("checkEmpty with ".concat(jsWrapperClass(element))); |
197 createImageBitmap(element, callbackEmpty, -30, -30, 30, 30); | 197 createImageBitmap(element, callbackEmpty, -30, -30, 30, 30); |
198 } | 198 } |
199 | 199 |
200 function checkEmpty2(element) { | 200 function checkEmpty2(element) { |
201 debug("checkEmpty2 with ".concat(jsWrapperClass(element))); | 201 debug("checkEmpty2 with ".concat(jsWrapperClass(element))); |
202 createImageBitmap(element, callbackEmpty, 40, 30, 30, 30); | 202 createImageBitmap(element, callbackEmpty, 40, 30, 30, 30); |
203 } | 203 } |
204 | 204 |
205 function checkImmutable(element) { | |
206 debug("checkImmutable with ".concat(jsWrapperClass(element))); | |
207 createImageBitmap(element, callbackImmutable); | |
208 } | |
209 | |
210 function callbackNoCrop(imageBitmap) { | 205 function callbackNoCrop(imageBitmap) { |
211 bitmap = imageBitmap; | 206 bitmap = imageBitmap; |
212 shouldBe("bitmap.width", "imageWidth"); | 207 shouldBe("bitmap.width", "imageWidth"); |
213 shouldBe("bitmap.height", "imageHeight"); | 208 shouldBe("bitmap.height", "imageHeight"); |
214 | 209 |
215 // should be drawn to (0, 0), (20, 20) | 210 // should be drawn to (0, 0), (20, 20) |
216 clearContext(ctx); | 211 clearContext(ctx); |
217 ctx.drawImage(imageBitmap, 0, 0); | 212 ctx.drawImage(imageBitmap, 0, 0); |
218 shouldBeRed(9, 9); | 213 shouldBeRed(9, 9); |
219 shouldBeGreen(11, 9); | 214 shouldBeGreen(11, 9); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 clearContext(ctx); | 413 clearContext(ctx); |
419 ctx.drawImage(imageBitmap, 0, 0); | 414 ctx.drawImage(imageBitmap, 0, 0); |
420 shouldBeClear(1, 1); | 415 shouldBeClear(1, 1); |
421 shouldBeClear(9, 9); | 416 shouldBeClear(9, 9); |
422 shouldBeClear(11, 11); | 417 shouldBeClear(11, 11); |
423 shouldBeClear(22, 22); | 418 shouldBeClear(22, 22); |
424 | 419 |
425 commonCallback(imageBitmap); | 420 commonCallback(imageBitmap); |
426 } | 421 } |
427 | 422 |
428 function callbackImmutable(imageBitmap) { | |
429 // change the underlying element to ensure that it does not change the image
Bitmap | |
430 switch(i) { | |
431 case 0: // image | |
432 image = new Image(); | |
433 break; | |
434 case 1: // canvas | |
435 clearContext(aCtx); | |
436 break; | |
437 case 2: // data | |
438 d = 0; | |
439 break; | |
440 case 3: // context | |
441 clearContext(aCtx); | |
442 break; | |
443 case 4: // bitmap | |
444 testBitmap = 0; | |
445 break; | |
446 default: | |
447 testFailed("Default should not be called."); | |
448 } | |
449 // should be drawn to (0, 0), (20, 20) | |
450 callbackNoCrop(imageBitmap); | |
451 | |
452 // we potentially cleared our auxillary context, so redraw the image | |
453 drawPattern(aCtx); | |
454 } | |
455 | |
456 function commonCallback(imageBitmap) { | 423 function commonCallback(imageBitmap) { |
457 bitmap = imageBitmap; | 424 bitmap = imageBitmap; |
458 shouldBeType("bitmap", "ImageBitmap"); | 425 shouldBeType("bitmap", "ImageBitmap"); |
459 | 426 |
460 callbackCount += 1; | 427 callbackCount += 1; |
461 | 428 |
462 if (callbackCount < elements.length * checks.length) { | 429 if (callbackCount < elements.length * checks.length) { |
463 ++j; | 430 ++j; |
464 if(j == checks.length) { | 431 if(j == checks.length) { |
465 // completed all the checks for the ith element | 432 // completed all the checks for the ith element |
466 j = 0; | 433 j = 0; |
467 ++i; | 434 ++i; |
468 } | 435 } |
469 nextCheck(); | 436 nextCheck(); |
470 } else { | 437 } else { |
471 finishJSTest(); | 438 finishJSTest(); |
472 } | 439 } |
473 } | 440 } |
474 | 441 |
475 </script> | 442 </script> |
476 <script src="../js/resources/js-test-post.js"></script> | 443 <script src="../js/resources/js-test-post.js"></script> |
477 </body> | 444 </body> |
478 </html> | 445 </html> |
OLD | NEW |