summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/imagebitmap_on_worker.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/canvas/test/imagebitmap_on_worker.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/canvas/test/imagebitmap_on_worker.js')
-rw-r--r--dom/canvas/test/imagebitmap_on_worker.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/dom/canvas/test/imagebitmap_on_worker.js b/dom/canvas/test/imagebitmap_on_worker.js
new file mode 100644
index 000000000..be7046710
--- /dev/null
+++ b/dom/canvas/test/imagebitmap_on_worker.js
@@ -0,0 +1,86 @@
+importScripts("imagebitmap_bug1239300.js");
+
+function ok(expect, msg) {
+ postMessage({type: "status", status: !!expect, msg: msg});
+}
+
+function doneTask() {
+ postMessage({type: "doneTask"});
+}
+
+function promiseThrows(p, name) {
+ var didThrow;
+ return p.then(function() { didThrow = false; },
+ function() { didThrow = true; })
+ .then(function() { ok(didThrow, "[TestException] " + name); });
+}
+
+onmessage = function(event) {
+ if (event.data.type == "testImageData") {
+ var width = event.data.width;
+ var height = event.data.height;
+ var imageData = event.data.source;
+ ok(imageData, "[CreateFromImageData] An ImageData is passed into worker.")
+ ok(imageData.width == width, "[CreateFromImageData] Passed ImageData has right width = " + width);
+ ok(imageData.height == height, "[CreateFromImageData] Passed ImageData has right height = " + height);
+
+ var promise = createImageBitmap(imageData);
+ promise.then(function(bitmap) {
+ ok(bitmap, "[CreateFromImageData] ImageBitmap is created successfully.");
+ ok(bitmap.width == width, "[CreateFromImageData] ImageBitmap.width = " + bitmap.width + ", expected witdth = " + width);
+ ok(bitmap.height == height, "[CreateFromImageData] ImageBitmap.height = " + bitmap.height + ", expected height = " + height);
+
+ doneTask();
+ });
+ } else if (event.data.type == "testBlob") {
+ var width = event.data.width;
+ var height = event.data.height;
+ var blob = event.data.source;
+ ok(blob, "[CreateFromBlob] A Blob object is passed into worker.");
+
+ var promise = createImageBitmap(blob);
+ promise.then(function(bitmap) {
+ ok(bitmap, "[CreateFromBlob] ImageBitmap is created successfully.");
+ ok(bitmap.width == width, "[CreateFromBlob] ImageBitmap.width = " + bitmap.width + ", expected witdth = " + width);
+ ok(bitmap.height == height, "[CreateFromBlob] ImageBitmap.height = " + bitmap.height + ", expected height = " + height);
+
+ doneTask();
+ });
+ } else if (event.data.type == "testImageBitmap") {
+ var width = event.data.width;
+ var height = event.data.height;
+ var source = event.data.source;
+ ok(source, "[CreateFromImageBitmap] A soruce object is passed into worker.");
+
+ var promise = createImageBitmap(source);
+ promise.then(function(bitmap) {
+ ok(bitmap, "[CreateFromImageBitmap] ImageBitmap is created successfully.");
+ ok(bitmap.width == width, "[CreateFromImageBitmap] ImageBitmap.width = " + bitmap.width + ", expected witdth = " + width);
+ ok(bitmap.height == height, "[CreateFromImageBitmap] ImageBitmap.height = " + bitmap.height + ", expected height = " + height);
+
+ var promise2 = createImageBitmap(bitmap);
+ promise2.then(function(bitmap2) {
+ ok(bitmap2, "[CreateFromImageBitmap] 2nd ImageBitmap is created successfully.");
+ ok(bitmap.width == width, "[CreateFromImageBitmap] ImageBitmap.width = " + bitmap.width + ", expected witdth = " + width);
+ ok(bitmap.height == height, "[CreateFromImageBitmap] ImageBitmap.height = " + bitmap.height + ", expected height = " + height);
+
+ doneTask();
+ });
+ });
+ } else if (event.data.type == "testException") {
+ var source = event.data.source;
+ if (event.data.sx) {
+ var sx = event.data.sx;
+ var sy = event.data.sy;
+ var sw = event.data.sw;
+ var sh = event.data.sh;
+ promiseThrows(createImageBitmap(source, sx, sy, sw, sh), event.data.msg);
+ } else {
+ promiseThrows(createImageBitmap(source), event.data.msg);
+ }
+ doneTask();
+ } else if (event.data.type == "testBug1239300") {
+ var promise = testBug1239300();
+ promise.then(doneTask, doneTask);
+ }
+}; \ No newline at end of file