OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../js/resources/js-test-pre.js"></script> | 3 <script src="../js/resources/js-test-pre.js"></script> |
4 </head> | 4 </head> |
5 <body> | 5 <body> |
6 <script> | 6 <script> |
7 description("Ensure correct behavior of drawImage with ImageBitmaps constructed
from ImageBitmaps that are constructed from images (not pinned to memory) and ca
nvases (pinned to memory)."); | 7 description("Ensure correct behavior of drawImage with ImageBitmaps constructed
from ImageBitmaps that are constructed from images (not pinned to memory) and ca
nvases (pinned to memory)."); |
8 | 8 |
9 window.jsTestIsAsync = true; | 9 window.jsTestIsAsync = true; |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 var canvas = document.createElement("canvas"); | 52 var canvas = document.createElement("canvas"); |
53 canvas.setAttribute("width", "50"); | 53 canvas.setAttribute("width", "50"); |
54 canvas.setAttribute("height", "50"); | 54 canvas.setAttribute("height", "50"); |
55 var ctx = canvas.getContext("2d"); | 55 var ctx = canvas.getContext("2d"); |
56 | 56 |
57 image = new Image(); | 57 image = new Image(); |
58 image.onload = imageLoaded; | 58 image.onload = imageLoaded; |
59 image.src = aCanvas.toDataURL(); | 59 image.src = aCanvas.toDataURL(); |
60 | 60 |
61 function imageLoaded() { | 61 function imageLoaded() { |
62 var bitmapFromImage, bitmapFromCanvas; | 62 var bitmaps = {}; |
63 var p1 = createImageBitmap(image, -10, -10, 20, 20).then(function(imageBitma
p) { bitmapFromImage = imageBitmap }); | 63 var p0 = createImageBitmap(image, -10, -10, 20, 20).then(function(imageBitma
p) { bitmaps.upperLeft1 = imageBitmap }); |
64 var p2 = createImageBitmap(aCanvas, 10, 10, 20, 20).then(function(imageBitma
p) { bitmapFromCanvas = imageBitmap }); | 64 var p1 = createImageBitmap(aCanvas, -10, -10, 20, 20).then(function(imageBit
map) { bitmaps.upperLeft2 = imageBitmap }); |
65 Promise.every(p1, p2).then(function() { | 65 var p2 = createImageBitmap(image, 10, 10, 20, 20).then(function(imageBitmap)
{ bitmaps.lowerRight1 = imageBitmap }); |
66 checkBitmaps(bitmapFromImage, bitmapFromCanvas); | 66 var p3 = createImageBitmap(aCanvas, 10, 10, 20, 20).then(function(imageBitma
p) { bitmaps.lowerRight2 = imageBitmap }); |
| 67 Promise.every(p0, p1, p2, p3).then(function() { |
| 68 checkBitmaps(bitmaps); |
67 }, shouldNotBeCalled); | 69 }, shouldNotBeCalled); |
68 } | 70 } |
69 | 71 |
70 function checkBitmaps(bitmapFromImage, bitmapFromCanvas) { | 72 function checkBitmaps(bitmaps) { |
71 var funcs = []; | 73 var funcs = []; |
72 var p1 = createImageBitmap(bitmapFromImage).then(function(imageBitmap) { | 74 var p0 = createImageBitmap(bitmaps.upperLeft1).then(function(imageBitmap) { |
73 funcs[0] = checkDrawnToRect(imageBitmap, 10, 10, 10, 10); | 75 funcs[0] = checkDrawnToRect(imageBitmap, 10, 10, 10, 10); |
74 }); | 76 }); |
75 var p2 = createImageBitmap(bitmapFromImage, -10, -10, 30, 30).then(function(
imageBitmap) { | 77 var p1 = createImageBitmap(bitmaps.upperLeft1, -10, -10, 30, 30).then(functi
on(imageBitmap) { |
76 funcs[1] = checkDrawnToRect(imageBitmap, 20, 20, 10, 10); | 78 funcs[1] = checkDrawnToRect(imageBitmap, 20, 20, 10, 10); |
77 }); | 79 }); |
78 var p3 = createImageBitmap(bitmapFromImage, 10, 10, 20, 20).then(function(im
ageBitmap) { | 80 var p2 = createImageBitmap(bitmaps.upperLeft1, 10, 10, 20, 20).then(function
(imageBitmap) { |
79 funcs[2] = checkDrawnToRect(imageBitmap, 0, 0, 10, 10); | 81 funcs[2] = checkDrawnToRect(imageBitmap, 0, 0, 10, 10); |
80 }); | 82 }); |
81 var p4 = createImageBitmap(bitmapFromCanvas).then(function(imageBitmap) { | 83 var p3 = createImageBitmap(bitmaps.upperLeft2).then(function(imageBitmap) { |
82 funcs[3] = checkDrawnToRect(imageBitmap, 0, 0, 10, 10); | 84 funcs[3] = checkDrawnToRect(imageBitmap, 10, 10, 10, 10); |
83 }); | 85 }); |
84 var p5 = createImageBitmap(bitmapFromCanvas, -15, -10, 35, 40).then(function
(imageBitmap) { | 86 var p4 = createImageBitmap(bitmaps.upperLeft2, -10, -10, 30, 30).then(functi
on(imageBitmap) { |
85 funcs[4] = checkDrawnToRect(imageBitmap, 15, 10, 10, 10); | 87 funcs[4] = checkDrawnToRect(imageBitmap, 20, 20, 10, 10); |
86 }); | 88 }); |
87 var p6 = createImageBitmap(bitmapFromCanvas, 5, 5, 10, 10).then(function(ima
geBitmap) { | 89 var p5 = createImageBitmap(bitmaps.upperLeft2, 10, 10, 20, 20).then(function
(imageBitmap) { |
88 funcs[5] = checkDrawnToRect(imageBitmap, 0, 0, 5, 5); | 90 funcs[5] = checkDrawnToRect(imageBitmap, 0, 0, 10, 10); |
89 }); | 91 }); |
90 Promise.every(p1, p2, p3, p4, p5, p6).then(function() { | 92 var p6 = createImageBitmap(bitmaps.lowerRight1).then(function(imageBitmap) { |
| 93 funcs[6] = checkDrawnToRect(imageBitmap, 0, 0, 10, 10); |
| 94 }); |
| 95 var p7 = createImageBitmap(bitmaps.lowerRight1, -15, -10, 35, 40).then(funct
ion(imageBitmap) { |
| 96 funcs[7] = checkDrawnToRect(imageBitmap, 15, 10, 10, 10); |
| 97 }); |
| 98 var p8 = createImageBitmap(bitmaps.lowerRight1, 5, 5, 10, 10).then(function(
imageBitmap) { |
| 99 funcs[8] = checkDrawnToRect(imageBitmap, 0, 0, 5, 5); |
| 100 }); |
| 101 var p9 = createImageBitmap(bitmaps.lowerRight2).then(function(imageBitmap) { |
| 102 funcs[9] = checkDrawnToRect(imageBitmap, 0, 0, 10, 10); |
| 103 }); |
| 104 var p10 = createImageBitmap(bitmaps.lowerRight2, -15, -10, 35, 40).then(func
tion(imageBitmap) { |
| 105 funcs[10] = checkDrawnToRect(imageBitmap, 15, 10, 10, 10); |
| 106 }); |
| 107 var p11 = createImageBitmap(bitmaps.lowerRight2, 5, 5, 10, 10).then(function
(imageBitmap) { |
| 108 funcs[11] = checkDrawnToRect(imageBitmap, 0, 0, 5, 5); |
| 109 }); |
| 110 |
| 111 Promise.every(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11).then(functio
n() { |
91 for (var i = 0; i < funcs.length; ++i) | 112 for (var i = 0; i < funcs.length; ++i) |
92 funcs[i](); | 113 funcs[i](); |
93 finishJSTest(); | 114 finishJSTest(); |
94 }, shouldNotBeCalled); | 115 }, shouldNotBeCalled); |
95 } | 116 } |
96 | 117 |
97 function checkDrawnToRect(bitmap, x, y, w, h) { | 118 function checkDrawnToRect(bitmap, x, y, w, h) { |
98 // x, y, w, h are the expected location of the green square | 119 // x, y, w, h are the expected location of the green square |
99 var imageBitmap = bitmap; | 120 var imageBitmap = bitmap; |
100 var x1 = x; | 121 var x1 = x; |
(...skipping 28 matching lines...) Expand all Loading... |
129 clearContext(ctx); | 150 clearContext(ctx); |
130 ctx.drawImage(imageBitmap, x1, y1, w1, h1, 0, 0, 50, 50); | 151 ctx.drawImage(imageBitmap, x1, y1, w1, h1, 0, 0, 50, 50); |
131 shouldBeFilled(0, 0, 50, 50); | 152 shouldBeFilled(0, 0, 50, 50); |
132 } | 153 } |
133 } | 154 } |
134 | 155 |
135 </script> | 156 </script> |
136 <script src="../js/resources/js-test-post.js"></script> | 157 <script src="../js/resources/js-test-post.js"></script> |
137 </body> | 158 </body> |
138 </html> | 159 </html> |
OLD | NEW |