4

In the context of a unit test I need to send some code to the console of a chrome app I am developing. It's clear that I can do that from the chrome.debug API, but is there a way to do that from outside the browser?

1 Answer 1

1

Yes, there is a way; if you can do something with chrome.debug you can do so with remote debugging.

You need to enable remote debugging with command line switches; you can then connect to Chrome with a debugger client instance.

Google lists some existing debugger clients, and you can implement your own by following the debugger protocol (which works over HTTP+WebSockets).

The procedure for a debugger client is to request /json from the debugger port over HTTP, which lists all possible debug targets; the client then connects to the WebSocket associated with that target to work with it.

Sign up to request clarification or add additional context in comments.

3 Comments

could you be a bit more specific? I looked into the protocol a bit but couldn't find a way to set the debuggee to an extension, or even a reference to a debuggee at all. Looking a bit into the code it looks like when the debuggee is another extension the event is dispatched internally and not through the protocol, but I could be wrong about this.
Read the first link; you need to access the /json URL for a list of debuggees and then connect to the appropriate WebSocket port. At least that's how I read it; I haven't tried it myself.
What do I do after connecting via WebSocket?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.