summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/imagebitmap_extensions_on_worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/canvas/test/imagebitmap_extensions_on_worker.js')
-rw-r--r--dom/canvas/test/imagebitmap_extensions_on_worker.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/dom/canvas/test/imagebitmap_extensions_on_worker.js b/dom/canvas/test/imagebitmap_extensions_on_worker.js
new file mode 100644
index 000000000..63116e80e
--- /dev/null
+++ b/dom/canvas/test/imagebitmap_extensions_on_worker.js
@@ -0,0 +1,47 @@
+importScripts("imagebitmap_extensions_data.js");
+importScripts("imagebitmap_extensions.js");
+
+var gGroundTruthImageData;
+var gImageData;
+var gImageBitmap;
+var gPNGBlob;
+var gJPEGBlob;
+
+onmessage = function(event) {
+ if (event.data.type == "setSources") {
+ gGroundTruthImageData = event.data.groundTruthImageData;
+ gImageData = event.data.imageData;
+ gImageBitmap = event.data.imageBitmap;
+ gPNGBlob = event.data.pngBlob;
+ gJPEGBlob = event.data.jpegBlob;
+
+ ok(!!gGroundTruthImageData, "Get gGroundTruthImageData!");
+ ok(!!gImageData, "Get gImageData!");
+ ok(!!gImageBitmap, "Get gImageBitmap!");
+ ok(!!gPNGBlob, "Get gPNGBlob!");
+ ok(!!gJPEGBlob, "Get gJPEGBlob!");
+
+ runTests();
+ }
+};
+
+function ok(expect, msg) {
+ postMessage({"type": "status", status: !!expect, msg: msg});
+}
+
+function runTests() {
+ testExceptions().
+ then(testColorConversions()).
+ then( function() { return Promise.all([testAccessing_randomTest("ImageData", gImageData, 0),
+ testAccessing_randomTest("ImageBitmap", gImageBitmap, 0),
+ testAccessing_randomTest("PNG", gPNGBlob, 0),
+ testAccessing_randomTest("JPEG", gJPEGBlob, 10) // JPEG loses information
+ ]); }).
+ then( function() { return Promise.all([testCreateFromArrayBffer_randomTest("ImageData", gImageData, 0),
+ testCreateFromArrayBffer_randomTest("ImageBitmap", gImageBitmap, 0),
+ testCreateFromArrayBffer_randomTest("PNG", gPNGBlob, 0),
+ testCreateFromArrayBffer_randomTest("JPEG", gJPEGBlob, 10) // JPEG loses information
+ ]); }).
+ then(function() { return testInvalidAccess([gImageData, gImageBitmap, gPNGBlob, gJPEGBlob]); } ).
+ then(function() {postMessage({"type": "finish"});}, function(ev) { failed(ev); postMessage({"type": "finish"}); });
+} \ No newline at end of file