WebDriver currently uses the WebContent::ConnectionFromClient IPC class
directly for these features. To support headless-browser, WebDriver will
instead need to rely on PageClient to provide these.
WebDriverConnection can now work with PageClient's virtual interface.
This will allow constructing a WebDriverConnection from the PageClient
implementation in headless-browser.
Currently, all handling of pending dialogs occurs in PageHost. In order
to re-use this functionality to run WebDriver in a headless move, move
it to Page.
When timeouts are implemented, the start node used to find elements may
not remain valid for the entire duration of the timeout. For example,
the active document element may change, or the start node may be removed
from the DOM.
To handle this, we will need to re-evaluate the start node on each
iteration of the find() operation. This patch wraps the steps to do so
in a lambda to be executed on each iteration.
The way in which dialogs should be handled is configurable by the driver
capabilities object, which we don't support yet. So this implements just
the default mode to dismiss the dialog and return an error if there is
one open.
In the OOPWV, this means we need to refer to the dialog after it has
been open, so we now hold a pointer to whatever dialog is open.
This moves Get Window Handle, Close Window, and Get Window Handles over
to WebContent so they may be implemented closer to the spec and be used
by Ladybird.
Success responses are meant to be wrapped in a JSON object with a single
"value" key. Instead of doing this in both WebContent and WebDriver, do
it once in LibWeb.
There are a couple changes here from the existing Get All Cookies
implementation.
1. Previously, WebDriver actually returned *all* cookies in the cookie
jar. The spec dictates that we only return cookies that match the
document's URL. Specifically, it calls out that we must run just the
first step of RFC 6265 section 5.4 to perform domain matching.
This change adds a special mode to our implementation of that section
to skip the remaining steps.
2. We now fill in the SameSite cookie attribute when serializing the
cookie to JSON (this was a trival FIXME that didn't get picked up
when SameSite was implemented).
This is how WebContent::ConnectionFromClient also behaves. Returning the
element as a DOM::ParentNode isn't quite strict enough for upcoming
endpoints.