-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docs for servodriver. #59
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
I will review this on Wednesday :) |
Sorry for the delay, I will try to review this tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! These are very useful docs, and my comments are mostly very minor.
# The Servodriver test harness | ||
|
||
Servodriver is a test harness built on top of the wptrunner framework and a WebDriver server. It is not yet enabled by default, but can be run with the `--product servodriver` argument appended to any `test-wpt` command. | ||
Servodriver is made of three main components—the web server inside Servo that implements the [WebDriver specification](https://www.w3.org/TR/webdriver2/), the python test harness that orchestrates the browser, and the scripts that are loaded inside the test pages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Servodriver is made of three main components—the web server inside Servo that implements the [WebDriver specification](https://www.w3.org/TR/webdriver2/), the python test harness that orchestrates the browser, and the scripts that are loaded inside the test pages. | |
Servodriver is made of three main components: the web server inside Servo that implements the [WebDriver specification](https://www.w3.org/TR/webdriver2/), the Python test harness that orchestrates the browser, and the scripts that are loaded inside the test pages. |
this is a list, so we can be more specific and use a colon. also, consider reordering this list to match the order of the sections below or vice versa?
|
||
## Servo’s webdriver implementation | ||
|
||
There are three main components to this implementation—the server handler, the script handler, and the input handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three main components to this implementation—the server handler, the script handler, and the input handler. | |
There are three main components to this implementation: the server handler, the script handler, and the input handler. |
Our Servodriver executor delegates a lot of logic to the common [WebDriverTestharnessExecutor](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L948). This executor is responsible for executing scripts that ensure that the [testdriver harness executes](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L840) and that the python harness is able to retrieve test results from the browser. | ||
|
||
|
||
## Servo’s webdriver implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Servo’s webdriver implementation | |
## Servo’s WebDriver implementation |
|
||
When a webdriver message is received that targets a specific browsing context, it is [handled](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/components/script/script_thread.rs#L2076) by the ScriptThread that contains that document. The logic for processing each command lives in [webdriver_handlers.rs](https://github.com/servo/servo/blob/main/components/script/webdriver_handlers.rs). Any command that returns a value derived from web content must [serialize JS values](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/components/script/webdriver_handlers.rs#L162) as values that the webdriver server can convert into [API value types](https://doc.servo.org/serde_json/value/enum.Value.html). | ||
|
||
We expose [two web-accessible methods](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/components/script/dom/window.rs#L1189-L1203) for communicating async results to the webdriver server, `Window.webdriverCallback` and `Window.webdriverTimeout`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We expose [two web-accessible methods](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/components/script/dom/window.rs#L1189-L1203) for communicating async results to the webdriver server, `Window.webdriverCallback` and `Window.webdriverTimeout`. | |
We expose [two web-accessible methods](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/components/script/dom/window.rs#L1189-L1203) for communicating async results to the WebDriver server: `Window.webdriverCallback` and `Window.webdriverTimeout`. |
## The wptrunner harness | ||
|
||
Wptrunner is the harness that uses an `executor` and `browser` combination to launch a supported product. | ||
The [browser](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py) defines python classes to instantiate and methods to invoke for supported configurations, as well as arguments to pass to the Servo binary when launching it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The [browser](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py) defines python classes to instantiate and methods to invoke for supported configurations, as well as arguments to pass to the Servo binary when launching it. | |
The [browser](https://github.com/servo/servo/blob/main/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/servodriver.py) defines Python classes to instantiate and methods to invoke for supported configurations, as well as arguments to pass to the Servo binary when launching it. |
## The test page scripts | ||
|
||
The testdriver harness works by incorporating all of these elements together. | ||
The executor [opens a new window](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L850) and invokes an async script that [sets up a testdriver callback](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/testharness_webdriver_resume.js) (which is `Window.webdriverCallback`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The executor [opens a new window](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L850) and invokes an async script that [sets up a testdriver callback](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/testharness_webdriver_resume.js) (which is `Window.webdriverCallback`). | |
The executor [opens a new window](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L850) and invokes an async script that [sets the testdriver callback](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/testharness_webdriver_resume.js) to `Window.webdriverCallback` (`arguments[arguments.length - 1]`). |
|
||
The testdriver harness works by incorporating all of these elements together. | ||
The executor [opens a new window](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L850) and invokes an async script that [sets up a testdriver callback](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/testharness_webdriver_resume.js) (which is `Window.webdriverCallback`). | ||
This window creates [a message queue](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/message-queue.js#L30) which is [read by the executor harness](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L904-L905). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This window creates [a message queue](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/message-queue.js#L30) which is [read by the executor harness](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L904-L905). | |
This window creates [a message queue](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/message-queue.js#L30), which is [read by the executor harness](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L904-L905). |
The testdriver harness works by incorporating all of these elements together. | ||
The executor [opens a new window](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L850) and invokes an async script that [sets up a testdriver callback](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/testharness_webdriver_resume.js) (which is `Window.webdriverCallback`). | ||
This window creates [a message queue](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/message-queue.js#L30) which is [read by the executor harness](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L904-L905). | ||
Subsequently, each test that runs is opened as a new window—this allows them to use `opener.postMessage` to communicate with the original window, which allows the testdriver APIs to send messages that [represent webdriver API calls](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/testdriver-extra.js#L286-L296). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subsequently, each test that runs is opened as a new window—this allows them to use `opener.postMessage` to communicate with the original window, which allows the testdriver APIs to send messages that [represent webdriver API calls](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/testdriver-extra.js#L286-L296). | |
Subsequently, each test that runs is opened as a new window; these windows can then use `opener.postMessage` to communicate with the original window, which allows the testdriver APIs to send messages that [represent WebDriver API calls](https://github.com/servo/servo/blob/3421185737deefe27e51e104708b02d9b3d4f4f3/tests/wpt/tests/tools/wptrunner/wptrunner/testdriver-extra.js#L286-L296). |
RUST_LOG=webdriver_server,webdriver,script::webdriver_handlers,constellation | ||
``` | ||
|
||
This usually makes clear if the expected API calls are being processed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This usually makes clear if the expected API calls are being processed. | |
This usually makes it clear if the expected API calls are being processed. |
|
||
This usually makes clear if the expected API calls are being processed. | ||
|
||
When debugging input-related problems, add JS debugging lines that log the `getBoundingClientRect()` of whatever element is being clicked, then compare the coordinates received by the compositor when clicking manually vs. the coordinates received from the webdriver server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When debugging input-related problems, add JS debugging lines that log the `getBoundingClientRect()` of whatever element is being clicked, then compare the coordinates received by the compositor when clicking manually vs. the coordinates received from the webdriver server. | |
When debugging input-related problems, add JS debugging lines that log the `getBoundingClientRect()` of whatever element is being clicked, then compare the coordinates received by the compositor when clicking manually vs the coordinates received from the WebDriver server. |
No description provided.