1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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"}); });
}
|