Land CDP prototype
Categories
(Remote Protocol :: Agent, enhancement, P1)
Tracking
(Not tracked)
People
(Reporter: ato, Assigned: ato)
References
()
Details
Attachments
(1 file, 1 obsolete file)
We want to write and land a prototype for a new agent/server that
enables Firefox to speak the Chrome DevTools Protocol (CDP).
This is an HTTP, WebSockets, and JSON based protocol for inspecting
state and controlling execution of web content documents, instrumenting
the browser in interesting ways, simulating user interaction for
automation purposes, and debugging JavaScript execution.
This bug is scoped to put together a framework and transport layer
suitable for implementing the CDP API and protocol. The initial
implementation will be an alternate target for third-party integrations
to connect to, supplementing the existing Firefox DevTools server.
The aim of this work is to enable Firefox to explore implementing
parts of the CDP APIs.
See also:
https://groups.google.com/d/msg/mozilla.dev.platform/4-4A8W-nP5g/Y9C9UkWTAAAJ
https://bugzilla.mozilla.org/show_bug.cgi?id=1512337
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 1•6 years ago
•
|
||
I’ve taken the original prototype I worked on and ported it to
use the new BrowsingContext based child actor system that is
now being deployed in the Firefox frontend. The idea is that this
will be a safer way to structure new code, given that it is its
long-term intention to entirely replace the frame script concept.
The attached prototype is a sparse, but working, implementation
of CDP in Gecko. Notably, it is missing almost every feature that
CDP has, but provides just enough functionality to make the demo in
remote/test/demo.js work. The limited feature set is intentional,
as the first order of business should be that we agree on a general
design approach.
A few words of warning when reading the diff:
-
The actor infrastructure has a limitation that child actors have
to be predefined and registered in the parent process before the
first child content process starts. This is a problem since
the remote agent is essentially an opt-in feature initialised
with a flag. Since this is the first Gecko component to need
on-demand installation of child actors, I don’t believe this
to be a show-stopper. -
The transport layer is indisputably terrible, and is held
together with a piece of string. We should accept that it is
necessary to compromise on this to deliver Puppeteer support in
the short term. But we should be aware that it is a priority to
move to a high-quality HTTPD based on rust-cdp in the longer term.As the rust-cdp crate provides a complete, typed Rust
implementation of the CDP protocol, automatically generated
from Chrome’s protocol definition, we could remove entirety
of the remote/server subfolder and the protocol schema checking
done in Protocol.jsm. One of the particularly interesting
features I find with rust-cdp is that the serde deserialisations
could be used to delegate to browser-local clients over IPDL,
meaning this XPCOM remote agent could be just one possible
underlying implementation. -
The 17k-dump of the CDP protocol definition in remote/Protocol.jsm
is pure garbage. (-;
I’d like to know what you think of this general approach? I know
there are alternate ways we could approach this (building it in
to devtools’ actor system, but with a CDP-emitting serialiser is
one option), but I feel that the prospect of a modular IPDL/XPCOM
implementation supported by plumbing in rust-cdp holds potential.
Comment 2•6 years ago
|
||
Andreas, I haven't had time to context switch this week, but I'll take time to review this early next week.
But it looks very promising. I'm not too concerned about the http endpoint as there isn't much happening there. We may even live with a very incomplete http implementation and that would still work. Most of CDP happens in the WebSocket connection. When you analyze how chromium works, I'm not sure the http endpoint is justified to list the targets. It looks like an historical thing that you have to go through. I say that because you can listen for other targets and communicate with them via a single WebSocket connection.
Also, I took some time to analyze how chromium was handling site-isolation. I'll try to summarize what I found next week as well. But I can already say that there is a lot of similar patterns between CDP / RDP and pur front-ends.
Comment 3•6 years ago
|
||
Comment 4•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 5•6 years ago
|
||
ochameau and I have addressed all the feedback from above, plus
some more.
Today I forcefully rebased and rewrote the history of the protocdp
branch in preparation of landing it in central
. A few more minor
tweaks to documentation, READMEs, and a cursory review of the commit
log history is still pending.
Instead of landing the prototype as one giant commit, I intend to
overlay the history into central as has been the practice with other
projects developed out-of-tree in the past (testing/geckodriver,
testing/webdriver, testing/mozbase/rust, et al.). This is useful
when we find ourselves understanding why a certain change was made.
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 6•6 years ago
|
||
Assignee | ||
Comment 8•6 years ago
|
||
We have a new remote protocol in Firefox that is based on the Chrome
DevTools Protocol (CDP). This is a low-level debugging interface with
which you can inspect the state and control execution of documents
running in web content, instrument Firefox in interesting ways, simulate
user interaction for automation purposes, and debug JavaScript execution.
This patch hooks the server part of this implementation, known as the
remote agent, up to the build system. The remote agent is not enabled
in the default build, so the following is needed in mozconfig to build it:
ac_add_options --enable-cdp
A subsequent change to enable the remote agent in Nightly builds only
will follow in due course. That would allow us to run TaskCluster
test jobs to verify the remote protocol's functional integrity.
Assignee | ||
Updated•6 years ago
|
Comment 10•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/51a9ef380658
https://hg.mozilla.org/mozilla-central/rev/e566701d45e0
https://hg.mozilla.org/mozilla-central/rev/4f3ebf4a8f5a
https://hg.mozilla.org/mozilla-central/rev/63370914ed49
https://hg.mozilla.org/mozilla-central/rev/67c34144b072
https://hg.mozilla.org/mozilla-central/rev/3e150e389aaa
https://hg.mozilla.org/mozilla-central/rev/f7e7800294cb
https://hg.mozilla.org/mozilla-central/rev/9b980764075b
https://hg.mozilla.org/mozilla-central/rev/7b87252c4a31
https://hg.mozilla.org/mozilla-central/rev/af7a76690b8a
https://hg.mozilla.org/mozilla-central/rev/f1d96bc26051
https://hg.mozilla.org/mozilla-central/rev/290a558818ef
https://hg.mozilla.org/mozilla-central/rev/294ef13003d0
https://hg.mozilla.org/mozilla-central/rev/bea61357248a
https://hg.mozilla.org/mozilla-central/rev/f73d7c3bced4
https://hg.mozilla.org/mozilla-central/rev/ac7c2e018cb6
https://hg.mozilla.org/mozilla-central/rev/d7e26a1b6ef7
https://hg.mozilla.org/mozilla-central/rev/819bb544204d
https://hg.mozilla.org/mozilla-central/rev/8231251f03a4
https://hg.mozilla.org/mozilla-central/rev/51927b210a12
https://hg.mozilla.org/mozilla-central/rev/c54bbccb690b
https://hg.mozilla.org/mozilla-central/rev/ff4ff4765f3b
https://hg.mozilla.org/mozilla-central/rev/16812017daad
https://hg.mozilla.org/mozilla-central/rev/4abd3301e839
https://hg.mozilla.org/mozilla-central/rev/0c3648638c85
https://hg.mozilla.org/mozilla-central/rev/705542bc7f14
https://hg.mozilla.org/mozilla-central/rev/275ad4598e75
https://hg.mozilla.org/mozilla-central/rev/705a560085d4
https://hg.mozilla.org/mozilla-central/rev/6ee3f621e6b8
https://hg.mozilla.org/mozilla-central/rev/d4ddf649862b
https://hg.mozilla.org/mozilla-central/rev/f8726e16183f
https://hg.mozilla.org/mozilla-central/rev/3f8fa17722f6
https://hg.mozilla.org/mozilla-central/rev/05d7e3b96382
https://hg.mozilla.org/mozilla-central/rev/304bff20aa1f
https://hg.mozilla.org/mozilla-central/rev/02050b4ee473
https://hg.mozilla.org/mozilla-central/rev/65f5581faf6a
https://hg.mozilla.org/mozilla-central/rev/947ad73d45af
https://hg.mozilla.org/mozilla-central/rev/e3d8a66cdad1
https://hg.mozilla.org/mozilla-central/rev/59da827edf02
https://hg.mozilla.org/mozilla-central/rev/2f7767b51e69
https://hg.mozilla.org/mozilla-central/rev/b35c2a9a00d2
https://hg.mozilla.org/mozilla-central/rev/cce704488a62
https://hg.mozilla.org/mozilla-central/rev/e3b2b601748c
https://hg.mozilla.org/mozilla-central/rev/c26cc4c7f021
https://hg.mozilla.org/mozilla-central/rev/0d1d92205068
https://hg.mozilla.org/mozilla-central/rev/b075e49fca67
https://hg.mozilla.org/mozilla-central/rev/9ffed583c0e4
https://hg.mozilla.org/mozilla-central/rev/5ce6f3fcc572
https://hg.mozilla.org/mozilla-central/rev/a1a5fdbf9bc8
https://hg.mozilla.org/mozilla-central/rev/40a677ed5cc4
https://hg.mozilla.org/mozilla-central/rev/11a98da764d1
https://hg.mozilla.org/mozilla-central/rev/8a8c0dcb9486
https://hg.mozilla.org/mozilla-central/rev/2bb69a9505ba
https://hg.mozilla.org/mozilla-central/rev/6a8bdb28bc82
https://hg.mozilla.org/mozilla-central/rev/9f03512232fb
https://hg.mozilla.org/mozilla-central/rev/10dc88c2cacb
https://hg.mozilla.org/mozilla-central/rev/298854093159
https://hg.mozilla.org/mozilla-central/rev/0c54ddfc1b58
https://hg.mozilla.org/mozilla-central/rev/7ab41ce7425a
https://hg.mozilla.org/mozilla-central/rev/45eecaf3a611
https://hg.mozilla.org/mozilla-central/rev/f9eb88415e06
https://hg.mozilla.org/mozilla-central/rev/e43dbe94d1aa
https://hg.mozilla.org/mozilla-central/rev/1244522a15c7
https://hg.mozilla.org/mozilla-central/rev/f298dfa8a1b1
https://hg.mozilla.org/mozilla-central/rev/2b1bde33c72e
https://hg.mozilla.org/mozilla-central/rev/06c54b40f312
https://hg.mozilla.org/mozilla-central/rev/d9cce6c1e153
https://hg.mozilla.org/mozilla-central/rev/0fa4b12c2f35
https://hg.mozilla.org/mozilla-central/rev/932d90008fe2
https://hg.mozilla.org/mozilla-central/rev/4696a88c5274
https://hg.mozilla.org/mozilla-central/rev/1f861b702507
https://hg.mozilla.org/mozilla-central/rev/c750fecfdf21
https://hg.mozilla.org/mozilla-central/rev/e94205832ec1
https://hg.mozilla.org/mozilla-central/rev/2c703d235c4c
https://hg.mozilla.org/mozilla-central/rev/2dd67c30b7ae
https://hg.mozilla.org/mozilla-central/rev/53947dc827dd
https://hg.mozilla.org/mozilla-central/rev/9e035690f943
https://hg.mozilla.org/mozilla-central/rev/de44fc903478
https://hg.mozilla.org/mozilla-central/rev/ed31c156cec0
https://hg.mozilla.org/mozilla-central/rev/e32546a7d4cd
https://hg.mozilla.org/mozilla-central/rev/bf6f4ba40815
https://hg.mozilla.org/mozilla-central/rev/64c382608b1c
https://hg.mozilla.org/mozilla-central/rev/56727ea2555c
https://hg.mozilla.org/mozilla-central/rev/25dd3f1e01c9
https://hg.mozilla.org/mozilla-central/rev/2932c11d19a5
https://hg.mozilla.org/mozilla-central/rev/820ed215c286
Description
•