1. Narrow the lifetime of `input_cancel_list` to avoid Runtime multiple
BorrowMut error.
2. Work around the buggy spec by removing matching item in
`input_cancel_list` when dispatch `keyUp` and `mouseUp`. See
https://github.com/servo/servo/issues/37579#issuecomment-2990762713
Testing: All WebDriver WPT test.
Fixes: #37579
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Also renamed all "CSS" selector variants of `WebDriverScriptCommand` to
avoid confusion.
Testing: Mostly `./mach test-wpt -r
tests\wpt\tests\webdriver\tests\classic\find_*_from_shadow_root\find.py
--product servodriver`
But many other test also relies on finding element(s) from shadow root,
so I ran the entire test.
All deleted lines are from test expectations.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
1. Correctly Serialize the ShadowRoot. Previously, it contains a nested
element identifier "element-6066-11e4-a52e-4f735466cecf"
2. Improve coding style with what I learnt from Josh today
Testing: Passing way more "Find Elements from Shadow Root" test locally
now
Fixes: #37559
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Moving `webdriver` to `servoshell`:
- Let `servoshell` manage lifecycle of `webdriver`
- One by one, move the handling of webdriver commands from
`constellation` to `embedder`
Partially fix: https://github.com/servo/servo/issues/37370
Partially fix webdriver test timeout with `no_top_browsing_context`
cc: @xiaochengh
---------
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
The retry in previous implementation doesn't have a good reason, it
seems like webdriver just want to try its luck.
If get focused webview return None, better just return it.
There is a case webdriver still runs when all webview are closed.
cc: @xiaochengh
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
1. Properly report new types of errors for `find_element` and
`find_elements`. Previously never reported.
1.1. `InvalidSelector`
1.2. `NoSuchElement`
1.3. `InvalidArgument`
2. Get the visible text for `<a>` correctly in
`script::webdriver_handler` so that matching would work.
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
webdriver/tests/classic/find_element/find.py
webdriver/tests/classic/find_elements/find.py --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Fix `WebDriverScriptCommand::GetElementText` similar to
https://github.com/servo/servo/pull/37452#discussion_r2146350739, by
correctly retrieving rendered text.
Testing: `./mach test-wpt -r --log-raw "D:\servo test
log\gt_ele_txt.txt" webdriver/tests/classic/get_element_text --product
servodriver`
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Report `NoSuchElement` if the active element is null, according to spec.
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\get_active_element --product
servodriver`
Partly fixes: #37420. We can pass `get_active_element` test once #37424
is done.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
SwitchToParentFrame webdriver commands do not handle the case where the
current top-level browsing context has been closed.
Tests:
`./tests/wpt/tests/webdriver/tests/classic/switch_to_parent_frame/switch.py`
`./tests/wpt/tests/webdriver/tests/classic/switch_to_frame/switch.py`
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Improve some session/window handling according to spec.
Testing:`./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
1. Tidy up some WebDriver handling with browsing context
2. Enable more wpt-test which no longer panic
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
As titled. This is what
[spec](https://w3c.github.io/webdriver/#dfn-dispatch-actions-inner)
requires. The motivation is that the previous action might have changed
the browsing context.
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Implement action synchronization for wheel event. Previously only done
for pointer here https://github.com/servo/servo/pull/36932.
Testing:
`tests/wpt/meta/webdriver/tests/classic/perform_actions/wheel.py`
---------
Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
For WebDriver, return "No Such Window" properly according to spec.
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
For Desktop port of `request_open_auxiliary_webview`, stay on the
original WebView if the request originates WebDriver.
This is to make sure `webdriver_server::handle_new_window` does not
focus the new window, according to spec. See
c7eba2dbba/tests/wpt/tests/webdriver/tests/classic/new_window/new_window.py (L31-L37)
**To clarify**: this won't change the behaviour when user interacts, but
only affects WebDriver [New
Window](https://w3c.github.io/webdriver/#new-window).
Testing: `./mach test-wpt -r --log-raw "D:/servo log/all.txt"
./tests/wpt/tests/webdriver/tests/classic --product servodriver` based
on 96b0973037
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Remove `embedder/webdriver.rs::WebDriverCookieError` and use universal
`ErrorStatus` from webdriver crate. This is needed as we might need to
send back more universal error such as `NoSuchWindow`.
Testing: No behaviour change.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Implement Get Element Shadow Root
https://www.w3.org/TR/webdriver2/#dfn-get-element-shadow-root
cc: @xiaochengh, @yezhizhen, @PotatoCP
Testing:
`\tests\wpt\tests\webdriver\tests\classic\get_element_shadow_root\get.py`
is blocked by `no_browsing_context` and `closed_window`
pass for other sub-tests.
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
We can now send keys to file input, which results in uploading file with
given filename. Needs
`pref=dom_testing_html_input_element_select_files_enabled` flag to work.
https://w3c.github.io/webdriver/#element-send-keys
Testing:
`tests/wpt/meta/webdriver/tests/classic/element_send_keys/{events,
file_upload}.py.`
Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
Webdriver actions only wait for response from constellation if
`dispatch_tick_actions` sends at least 1 event.
Testing:
`./mach test-wpt -r --product servodriver
./tests/wpt/tests/webdriver/tests/classic/perform_actions/perform.py `
cc: @xiaochengh, @yezhizhen
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This change adds support for rendering static SVG images using the
`resvg` crate, allowing svg sources in the `img` tag and in CSS
`background` and `content` properties. There are some limitations in
using resvg:
1. There is no support for animations or interactivity as these would
require implementing the full DOM layer of SVG specification.
2. Only system fonts can be used for text rendering. There is some
mechanism to provide a custom font resolver to usvg, but that is not
explored in this change.
3. resvg's handling of certain edge cases involving lack of explicit
`width` and `height` on the root svg element deviates from what the
specification expects from browsers. For example, resvg uses the values
in `viewBox` to derive the missing width or height dimension, but
without scaling that dimension to preserve the aspect ratio. It also
doesn't allow overriding this behavior.
Demo screenshot:

<details>
<summary>Source</summary>
```
<style>
#svg1 {
border: 1px solid red;
}
#svg2 {
border: 1px solid red;
width: 300px;
}
#svg3 {
border: 1px solid red;
width: 300px;
height: 200px;
object-fit: contain;
}
#svg4 {
border: 1px solid red;
width: 300px;
height: 200px;
object-fit: cover;
}
#svg5 {
border: 1px solid red;
width: 300px;
height: 200px;
object-fit: fill;
}
#svg6 {
border: 1px solid red;
width: 300px;
height: 200px;
object-fit: none;
}
</style>
</head>
<body>
<div>
<img id="svg1" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
</div>
<div>
<img id="svg2" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
<img id="svg3" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
<img id="svg4" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
</div>
<div>
<img id="svg5" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
<img id="svg6" src="https://raw.githubusercontent.com/servo/servo/refs/heads/main/resources/servo.svg" alt="Servo logo">
</div>
</body>
```
</details>
---------
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Removed unused dependencies in various crates using cargo-machete, grep
and cargo-udeps.
Testing: The CI tests if any dependencies were used that are removed.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Re-remove deleted logic from `WebDriverSession::input_cancel_list` logic
in #37010 which was re-adedd during merge resolution in #36932.
Otherwise, duplicate items would be registered in Release Actions.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Implement missing synchronization in `dispatch_actions` of `WebDriver`.
https://w3c.github.io/webdriver/#dispatching-actions
> The user agent event loop has spun enough times to process the DOM
events generated by the last invocation of the >[dispatch tick
actions](https://w3c.github.io/webdriver/#dfn-dispatch-tick-actions)
steps.
- Add a way for `ScriptThread` to notify `WebDriver` about the
completion of input commands.
- Add a `webdriver_id` field for `InputEvent`. `ScriptThread` uses it to
distinguish WebDriver events and sends notification.
Tests:
`./mach test-wpt --product servodriver -r
tests\wpt\tests\webdriver\tests\classic\element_click\events.py` pass if
`hit_testing` pass. Check
[issue](https://github.com/servo/servo/issues/36676#issuecomment-2882917136)
cc: @xiaochengh
---------
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This makes servo use less file descriptors for animated images and
avoids the crash described in
https://github.com/servo/servo/issues/36792.
Doing this also forces the end users to be more explicit about whether
they want to deal with all image frames or just the first one.
Previously, `Image::bytes` silently returned only the data for the first
frame. With this change there's now a `frames` method which returns an
iterator over all frames in the image.
Testing: No tests - this simply reduces the number of fds used. Servo
doesn't currently display animated gifs anyways.
Fixes: https://github.com/servo/servo/issues/36792
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
- Remove incorrect addition to `input_cancel_list` in
`dispatch_keyup_action`
- For `KeyDown` and `PointerDown`, delay the addition to
`input_cancel_list` until "Dispatching action algorithm" is done to
match the spec. Previously the addition is done before notifying
constellation. Moreover, this makes sure that `pointerUp` is appended
even if `dispatch_pointerdown_action` returns early, so that [Release
Actions](https://w3c.github.io/webdriver/#release-actions) always have
the correct order.
- Remove incorrect addition to `input_cancel_list` in
`dispatch_pointerup_action`. This wrongly added "pointerdown" in
[Release Actions](https://w3c.github.io/webdriver/#release-actions)
- Reduce code duplication
- Add TODO for PointerInputState::subtype and pointerID
Testing: `./mach test-wpt -r --log-raw "D:\servo test
log\perform-actions.txt"
tests\wpt\tests\webdriver\tests\classic\perform_actions --product
servodriver` has no new failures so no regression. There are a lot more
passing tests, but I think mostly are because there is no CI for
webdriver.
cc @xiaochengh @jdm @PotatoCP @longvatrong111
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
- Wheel scroll action can get coordinates relative to an element origin
([previously](https://github.com/servo/servo/pull/36744) only
implemented for viewport).
- Extract the element coordinate into a function
Testing: Partially
`tests/wpt/tests/infrastructure/testdriver/actions/wheelScroll.html`,
but we still have synchronization problem. You can try to add sleep in
the test to see OK result.
cc: @xiaochengh @longvatrong111 @yezhizhen
Signed-off-by: PotatoCP <kenzieradityatirtarahardja.18@gmail.com>
Co-authored-by: PotatoCP <kenzieradityatirtarahardja.18@gmail.com>
Fix ElementClick: `ElementClick` should use `MouseButton::Left` to
create `action`.
Testing: No pass test now. Tests still fail because of other issues.
For: https://github.com/servo/servo/issues/36658
cc: @xiaochengh , @yezhizhen , @PotatoCP
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
These changes allow test_dom_token_list from
/execute_script/collections.py to pass, and various tests in
/execute_script/arguments.py to expose new failures.
Testing: Not run in CI yet, but verified results from
tests/wpt/tests/webdriver/tests/classic/{execute_script,execute_async_script}
locally.
Fixes: #35738
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
https://github.com/web-platform-tests/wpt/pull/50041 allows us to start
running the webdriver conformance tests in Servo, which will make it
easier for us to track regressions/improvements in our webdriver server
implementation.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes are part of #15274
- [x] There are tests for these changes
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Messages that are sent to the `Constellation` have pretty ambiguous
names.
This change does two renames:
- `ConstellationMsg` → `EmbedderToConstellationMessage`
- `ScriptMsg` → `ScriptToConstellationMessage`
This naming reflects that the `Constellation` stands in between the
embedding layer and the script layer and can receive messages from both.
Soon both of these message types will live in `constellation_traits`,
reflecting the idea that the `_traits` variant for a crate is
responsible for exposing the API for that crate.
Testing: No new tests are necessary here as this just renames two enums.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This change creates a `constellation_traits` crate. Previously messages
to the `Constellation` were in the `compositing_traits` crate, which
came about organically. This change moves these to a new crate which
also contains data types that are used in both compositing/libservo and
script (ie types that cross the process boundary). The idea is similar
to `embedding_traits`, but this is meant for types not exposed to the
API.
This change allows deduplicating `UntrustedNodeAddress`, which
previously had two versions to avoid circular dependencies.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Now that Stylo considers `servo` as the default feature, Servo doesn't
need to specify `features = ["servo"]`.
Also use the same crate names as Stylo, rather than renaming them with
`package`.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* servodriver: Ensure capabilities is always a non-empty value.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* webdriver: Serialize arguments object like an array.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* webdriver: Ensure script body is always valid JS.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* webdriver: Use current browsing context when getting element center point.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* webdriver: Propagate errors received from getting element center point.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* webdriver: Ensure opening a new window records a unique window handle.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* webdriver: Don't panic if script execution fails.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* webdriver: Do not update the current browsing context after closing a window.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* webdriver: Use more precise check for arguments exotic object.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Migrate to 2024 edition
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Allow unsafe_op_in_unsafe_fn lint
This lint warns by default in the 2024
edition, but is *way* too noisy for servo.
We might enable it in the future, but not now.
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Compile using the 2024 edition
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>