So - Firefox exposes a tcp-based protocol (not enabled by default. The user will need to go to a special tool to start the server). It will expose feature like adding break points, exploring the DOM and the CSS rules, and editing content (CSS/HTML/JS).
So external tools can connect to Firefox. But this protocol is not accessible from a page. But we could imagine using a websocket instead of a normal tcp socket, and let the web page connect to ws://localhost.