diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/canvas/test/test_offscreencanvas_toimagebitmap.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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/test_offscreencanvas_toimagebitmap.html')
-rw-r--r-- | dom/canvas/test/test_offscreencanvas_toimagebitmap.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/canvas/test/test_offscreencanvas_toimagebitmap.html b/dom/canvas/test/test_offscreencanvas_toimagebitmap.html new file mode 100644 index 000000000..e07f4f335 --- /dev/null +++ b/dom/canvas/test/test_offscreencanvas_toimagebitmap.html @@ -0,0 +1,69 @@ +<!DOCTYPE HTML> +<html> +<head> +<title>WebGL in OffscreenCanvas</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +</head> +<body> +<canvas id="c" width="64" height="64"></canvas> +<canvas id="c2" width="64" height="64"></canvas> +<canvas id="c-ref" width="64" height="64"></canvas> +<script> + +SimpleTest.waitForExplicitFinish(); + +function runTest() { + + var worker = new Worker("offscreencanvas.js"); + + ok(worker, "Web worker successfully created"); + + worker.onmessage = function(evt) { + var msg = evt.data || {}; + if (msg.type == "test") { + ok(msg.result, msg.name); + } + if (msg.type == "imagebitmap") { + // testing toBlob + // Fill c-ref with green color. + var c = document.getElementById("c-ref"); + var ctx = c.getContext("2d"); + ctx.rect(0, 0, 64, 64); + ctx.fillStyle = "#00FF00"; + ctx.fill(); + + var htmlCanvas = document.getElementById("c"); + var bitmapRenderer = htmlCanvas.getContext("bitmaprenderer"); + bitmapRenderer.transferFromImageBitmap(msg.bitmap); + + ok(c.toDataURL() == htmlCanvas.toDataURL(), + "imagebitmap should return a 64x64 green square"); + + // The ownership of msg.bitmap should be transferred to canvas "c" when + // we called transferFromImageBitmap. So we test if the ownership is actually + // transferred here. + var htmlCanvas = document.getElementById("c2"); + var bitmapRenderer = htmlCanvas.getContext("bitmaprenderer"); + bitmapRenderer.transferFromImageBitmap(msg.bitmap); + + SimpleTest.doesThrow( + function() { c2.toDataURL(); }, + "ImageBitmap has been transferred, toDataURL will throw."); + + worker.terminate(); + SimpleTest.finish(); + } + } + + worker.postMessage({test: 'webgl_imagebitmap'}); +} + +SpecialPowers.pushPrefEnv({'set': [ + ['gfx.offscreencanvas.enabled', true], + ['webgl.force-enabled', true], +]}, runTest); + +</script> +</body> +</html> |