On Wed, Jul 27, 2016 at 7:04 PM, Hallvord R. M. Steen <
geck...@hallvord.com> wrote:
> On 27.07.2016 00:51, J. Ryan Stinnett wrote:
>
>
> On Tue, Jul 26, 2016 at 8:02 AM, Hallvord R. M. Steen <
>
geck...@hallvord.com> wrote:
>
>> * What about taking a screenshot?
>
>
> One option is the device actor[1], though that takes a full chrome window
> screenshot, not just content.
>
>
> Well, I'm after a content screenshot - I can always draw the document onto
> a canvas and get the image data like I believe the GCLI command does under
> the hood. However, when I have a reference to a debug "target" (passed to
> the tool definition's build method), how do I get from there a reference to
> the related DOM document or window?
>
Your add-on runs on the client side of the connection and the target also
represents the client side. There is no "direct" reference to the document
or window, since it could be on a completely different device.
If you need to run totally custom code on the remote target, you may want
to add a custom "actor", which is a module that runs on server / targeted
thing. The Firebug examples repo[1] should help here, particularly the
"CustomActor" example. Essentially, we have a way install new actors over
the connection to add your custom feature, and then you can call it over
the protocol after it's installed.
It would also be interesting to know (just to understand how things are
> glued together) how I could invoke the device actor screenshot code. I have
> to load or require the resource://devtools/server/actors/device.js file
> in my extension code? But it isn't written like a module and doesn't export
> anything? Or can I create the device actor with some constructor I can
> reach by including something else?
You use a "front" which is a client side module that knows how to talk to
server side actor module via the protocol. You can use `getDeviceFront`[2]
to get the front for this actor. I believe `getDeviceFront(target.client,
target.root)` would work.
[1]:
https://github.com/firebug/devtools-extension-examples
[2]:
https://hg.mozilla.org/mozilla-central/annotate/fef429fba4c64c5b9c0c823a6ab713edbbcd4220/devtools/shared/fronts/device.js
- Ryan