1 importScripts("imagebitmap_bug1239300.js");
3 function ok(expect, msg) {
4 postMessage({ type: "status", status: !!expect, msg });
8 postMessage({ type: "doneTask" });
11 function promiseThrows(p, name) {
23 ok(didThrow, "[TestException] " + name);
27 onmessage = function (event) {
28 if (event.data.type == "testImageData") {
29 var width = event.data.width;
30 var height = event.data.height;
31 var imageData = event.data.source;
32 ok(imageData, "[CreateFromImageData] An ImageData is passed into worker.");
34 imageData.width == width,
35 "[CreateFromImageData] Passed ImageData has right width = " + width
38 imageData.height == height,
39 "[CreateFromImageData] Passed ImageData has right height = " + height
42 var promise = createImageBitmap(imageData);
43 promise.then(function (bitmap) {
44 ok(bitmap, "[CreateFromImageData] ImageBitmap is created successfully.");
46 bitmap.width == width,
47 "[CreateFromImageData] ImageBitmap.width = " +
49 ", expected witdth = " +
53 bitmap.height == height,
54 "[CreateFromImageData] ImageBitmap.height = " +
56 ", expected height = " +
62 } else if (event.data.type == "testBlob") {
63 var width = event.data.width;
64 var height = event.data.height;
65 var blob = event.data.source;
66 ok(blob, "[CreateFromBlob] A Blob object is passed into worker.");
68 var promise = createImageBitmap(blob);
69 promise.then(function (bitmap) {
70 ok(bitmap, "[CreateFromBlob] ImageBitmap is created successfully.");
72 bitmap.width == width,
73 "[CreateFromBlob] ImageBitmap.width = " +
75 ", expected witdth = " +
79 bitmap.height == height,
80 "[CreateFromBlob] ImageBitmap.height = " +
82 ", expected height = " +
88 } else if (event.data.type == "testImageBitmap") {
89 var width = event.data.width;
90 var height = event.data.height;
91 var source = event.data.source;
94 "[CreateFromImageBitmap] A soruce object is passed into worker."
97 var promise = createImageBitmap(source);
98 promise.then(function (bitmap) {
101 "[CreateFromImageBitmap] ImageBitmap is created successfully."
104 bitmap.width == width,
105 "[CreateFromImageBitmap] ImageBitmap.width = " +
107 ", expected witdth = " +
111 bitmap.height == height,
112 "[CreateFromImageBitmap] ImageBitmap.height = " +
114 ", expected height = " +
118 var promise2 = createImageBitmap(bitmap);
119 promise2.then(function (bitmap2) {
122 "[CreateFromImageBitmap] 2nd ImageBitmap is created successfully."
125 bitmap.width == width,
126 "[CreateFromImageBitmap] ImageBitmap.width = " +
128 ", expected witdth = " +
132 bitmap.height == height,
133 "[CreateFromImageBitmap] ImageBitmap.height = " +
135 ", expected height = " +
142 } else if (event.data.type == "testException") {
143 var source = event.data.source;
145 var sx = event.data.sx;
146 var sy = event.data.sy;
147 var sw = event.data.sw;
148 var sh = event.data.sh;
149 promiseThrows(createImageBitmap(source, sx, sy, sw, sh), event.data.msg);
151 promiseThrows(createImageBitmap(source), event.data.msg);
154 } else if (event.data.type == "testBug1239300") {
155 var promise = testBug1239300();
156 promise.then(doneTask, doneTask);