On 19 January 2016 at 11:22, Ted Mielczarek <t...@mielczarek.org> wrote: > On Tue, Jan 19, 2016, at 01:39 AM, m.bauermeis...@sto.com wrote: >> As part of my work on a prototyping suite I'd like to take screenshots >> (preferably retaining the alpha channel) of single UI elements. I'd like >> to do so on an onclick event. >> >> Is there a straightforward way to accomplish this? Possibly with XPCOM or >> js-ctypes? > > You can use the drawWindow method of CanvasRenderingContext2D: > https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawWindow > > You just need to create a canvas element, call getContext('2d') on it, > and then calculate the offset of the element you want to screenshot.
What Ted explains here is what we do for Marionette. You can probably draw some inspiration from https://dxr.mozilla.org/mozilla-central/source/testing/marionette/capture.js#17. _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform