Gated behind the feature flag `dom_navigator_sendbeacon_enabled` as the
`keep-alive` fetch parameter is crucial for real-life use cases such as
analytics requests.
Part of #4577
Part of #38302
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
When a testharness test also prints debugging output, sometimes the
output can be mixed with the JSON output printed via an alert. This
causes a JSON decoding error in the output. Instead of crashing the
harness and printing many lines of Python stack trace output, print a
nice error. This makes the test output easier to read.
Testing: This is a change to the test harness itself, so no tests
necessary.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Properly caps the minimum offset on each side as recommended by the
standards: https://drafts.csswg.org/css-ui-3/#outline-offset
Testing: Covered by WPT tests. (3 new passing!)
Fixes: #19508
---------
Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
As noted in #38345, vello scenes only grow. While we can reset them when
clearing viewport (#38356) that is not enough. We need to reset scene on
each render (~each frame) and providing old frame as backdrop to new
scene. Be do this lazily so multiple rendering without any changes
should be cheaper, we still do GPUBuffer mapping, because that would
require more complex work.
Testing: Code functionality is covered by existing WPT tests, but we do
not have any performance test.
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
The function handle_get_attribute should act differently when the
attribute is a boolean attribute.
The full list of attributes can be found in [1]. All attributes marked
as "Boolean attribute" in the "Value" column are boolean attributes.
Note that "hidden" is effectively treated as a boolean attribute,
according to WPT test "test_global_boolean_attributes" in
webdriver/tests/classic/get_element_attribute/get.py
[1] https://html.spec.whatwg.org/multipage/#attributes-3
Testing: Updated WPT test expectation
Fixes: #38353
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
With some adjustment for `NamedKey`. The two crates need to be bumped
together to avoid duplicate of `keyboard-types` action.
---------
Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Implement JS scroll event firing compliant to
https://drafts.csswg.org/cssom-view/#scrolling-events. Basically
whenever, the an element or the viewport is scrolled, we will fire a
scroll event. The changes push a scroll event whenever an API causes a
scroll position to change.
Testing: New WPT tests for basic APIs.
Part of: https://github.com/servo/servo/issues/31665
---------
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Testing: `element_click/interactability.py`. For some other tests in
headed window, even tho the target is in view it falsely claim not in
view previously.
---------
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
Add timeout and strictFileInteractability capabilities to response of
new session command.
Allow delete session command to run without a session.
Testing: Clear some unexpected results of session tests in webdriver CI
and
`tests/wpt/meta/webdriver/tests/classic/delete_session/delete.py.ini`
---------
Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Vello scene only ever grows, so we need to clear it as soon as it's
possible (in clear rect). This PR also adds ignore_clips to
vello_backend (already exists in vello_cpu_backend).
Testing: Behavior is verified by existing tests, as this is mainly a
change for performance. There are currently no performance tests. This
makes bunnymark actually playable (from 3 FPS to 20 FPS on vello_cpu).
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
When calculating the node to world transform for use in bounding box
queries, cache the values of the transform. In addition, when scroll
offsets change, ensure that the cached values are invalided properly.
This change necessitated the storage of children for each node in the
tree, so that we can walk both up and down the tree. The purpose of this
part of the change is to increase performance when doing multiple
queries and prepare the tree for hit testing.
In addition, this change also tries to take into account sticky offsets,
using the algorithm from WebRender to calculate sticky offsets. This is
also going to be important for hit testing.
Testing: Newly passing tests:
- /css/css-position/position-sticky-dynamic-ancestor-001.html
- /css/css-tables/tentative/position-sticky-container.html
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
The recent changes that cached the Scroll Tree present an opportunity to
calculate the queries that consider transform and scroll (dubbed as post
composite queries) accurately.
This PR propose a solution for this calculation by noting the lowest
scroll tree nodes that would affect a fragment. To do this, each
fragment would store a new attribute `spatial_tree_node` -- scroll tree
node id that we could use for the query. This referencing is considered
because the scroll tree node construction is managed by the fragment
itself. Therefore it would ease the managing the possibly stale
reference and future query cache invalidation considering the
development of incremental layout.
The bounding box query then could transform the bounding content rect of
a fragment using the computed current transformation matrix.
Fixes: https://github.com/servo/servo/issues/35768
Testing: Existing and new WPT
---------
Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
For current implementation, when a command may trigger a navigation,
webdriver only waits for document readiness state.
However, not all navigations make change in document.
This PR handles more cases for waiting for a navigation, and apply to
`element_click`.
- Before sending a command which may trigger a navigation, `webdriver`
sets `load status send` to `embedder`, `constelltation` and `script
thread` to listen to `navigation events`.
- Webdriver check if there is a navigation with `script thread`.
- If the navigation is loading a new url, webdriver checks if the
request is approved with `constellation`, then waits for document
readiness state.
- If the navigation is a hashchange, webdriver waits untill all new
generated dom events have been processed.
Testing:
`tests/wpt/tests/webdriver/tests/classic/element_click/navigate.py`
`tests/wpt/tests/webdriver/tests/classic/element_click/user_prompts.py`
https://github.com/longvatrong111/servo/actions/runs/16488690749
cc: @xiaochengh
---------
Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
Keep Constellation alive even when all browsing context closed in
WebDriver mode. In this case, when creating a new session, we would open
a new top-level browsing context.
Fixes: #37408
Testing: `./mach test-wpt -r
.\tests\wpt\tests\webdriver\tests\classic\close_window\close.py
--product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
The logic was wrong, sometimes we weren't setting it to true on flex
containers that needed it, and then as a workaround we were setting it
to to true on flex items that didn't need it.
For example, this testcase had 5 cache misses when stretching the items,
now we will avoid laying them out again:
```html
<div style="display: flex">
<div></div> <div></div> <div></div> <div></div> <div></div>
</div>
```
Also, the workaround wasn't always working, e.g. it failed to stretch
the green element here:
```html
<div style="display: flex; min-height: 200px">
<div>
<div style="display: flex; height: 100%; background-color: red">
<div style="width: 200px; background-color: green;"></div>
</div>
</div>
</div>
```
Testing: Adding new test
Fixes: #38023
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
If a cell would e.g. span 2 columns, each 50px wide, separated by a 10px
gutter, then we used to lay out the contents of the cell with a 100px
wide containing block. Now we will include the size of the gutter.
Testing: Adding new test
Fixes: #38277
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This PR implements the `TextDecoderStream`. Other than introducing the
necessary mod and webidl files corresponding to `TextDecoderStream`,
this PR also involves some changes in `TextDecoder` and
`TrasnformStream`:
- The common part that can be shared between `TextDecoder` and
`TextDecoderStream` are extracted into a separate type
`script::dom::textdecodercommon::TextDecoderCommon`. This type could
probably use a different name because there is an interface called
`TextDecoderCommon` in the spec
(https://encoding.spec.whatwg.org/#textdecodercommon) which just gets
included in `TextDecoder` and `TextDecoderStream`.
- The three algorithms in `TransformStream` (`cancel`, `flush`, and
`transform`) all have become `enum` that has a `Js` variant for a JS
function object and a `Native` variant for a rust trait object. Whether
the cancel algorithm needs this enum type is debatable as I did not find
any interface in the spec that explicitly sets the cancel algorithm.
Testing: Existing WPT tests `tests/wpt/tests/encoding/stream` should be
sufficient
Fixes: #37723
---------
Signed-off-by: minghuaw <michael.wu1107@gmail.com>
Signed-off-by: minghuaw <wuminghua7@huawei.com>
Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Adds a regression test for https://github.com/servo/servo/pull/38186,
verifying that the CSP header on the image is ignored when it's loaded
as a document.
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Before script just crashed in those cases because IPCSender was dropped,
now we send `None` to tell script about the failure and fail getContext
or registerPainter accordingly.
This PR also unifies `dom_canvas_{backends}_enabled` prefs into
`dom_canvas_backend` which is more flexible in multi-backends scenarios.
Reviewable per commit.
Testing: Added servo specific WPT test.
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
vello_cpu does not have any tests timeouts, because we do not need
download stuff from GPU as all work happens on CPU. So performance wise
it's better then classic vello at least for our usecase. There are some
vello bugs, but I think we will be able to sort them out within
upstream, eventually. Interestingly enough there are no new PASS like
they were with classic vello.
Difference with raqote can be observed here:
https://github.com/sagudev/servo/actions/runs/16549241085/attempts/1#summary-46802486798
## Known vello problems:
- https://github.com/linebender/vello/issues/1119
- https://github.com/linebender/vello/issues/1056
-
`/html/canvas/element/fill-and-stroke-styles/2d.gradient.interpolate.coloralpha.html`
- `kurbo::Cap::Butt` is defect (only visible with big lineWidth)
https://github.com/linebender/vello/issues/1063
- `/html/canvas/element/line-styles/2d.line.cross.html`
- `/html/canvas/element/line-styles/2d.line.miter.acute.html`
- other lack of strong correct problems
(https://github.com/linebender/vello/issues/1063#issuecomment-2998084736):
- `/html/canvas/element/path-objects/2d.path.rect.selfintersect.html`
- `putImageData(getImageData(...), ...)` is lossy (precision problems,
might be due to ImageData being unmultiplied)
-
`/html/canvas/element/pixel-manipulation/2d.imageData.put.unchanged.html`
Testing: Tested using vello_cpu_canvas subsuite
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
We just need to pass user provided FillRule via IPC to canvas paint
thread, then pass it all down to backend, which will handle it.
Testing: Added WPT tests.
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Handler::handle_add_cookie did not configure the attributes "Expires"
and "SameSite". This patch adds them.
Testing: Passing WPT tests that were expected to fail.
Fixes: https://github.com/servo/servo/pull/37715#issuecomment-3069734014
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
- Implement [Maximize
Window](https://w3c.github.io/webdriver/#maximize-window)
- Previously, headless window screen size is same as inner size if not
specified in preference. We make it double as required by the test to
not have max window initially.
- Some other random cleanup.
Testing: webdriver Stress test for maximize window (headed + headless).
---------
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This change aims to supplement the missing incremental box tree
construction when text-related styles change. Since certain text style
adjustments can alter visible text content and typography. Therefore,
the parent nodes of such text are marked as needing to re-collect their
box tree children to ensure the correct display of text.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
Add vello backend by implementing Backend traits in canvas crate (so
this lives in canvas_paint_thread - embedded process). Current
implementation uses normal wgpu, so we block on GPU work. Vello backend
is gated behind `vello` feature and `dom_canvas_vello_enabled` pref.
Feature-wise this backend is on on par with raqote (sometimes better
sometimes worse), but performance wise it's worse.
## Known vello problems:
- image roundtrip does not work (fixed in
https://github.com/linebender/vello/pull/974)
- https://github.com/linebender/vello/issues/1066 (fixed)
- clip layers are not working properly:
https://github.com/linebender/vello/issues/1061
- `/html/canvas/element/pixel-manipulation/2d.imageData.put.*`
- `/html/canvas/element/path-objects/2d.path.clip.intersect.html`
- https://github.com/linebender/vello/issues/1056
-
`/html/canvas/element/fill-and-stroke-styles/2d.gradient.interpolate.coloralpha.html`
- `kurbo::Cap::Butt` is defect (only visible with big lineWidth)
https://github.com/linebender/vello/issues/1063
- `/html/canvas/element/line-styles/2d.line.cross.html`
- `/html/canvas/element/line-styles/2d.line.miter.acute.html`
- other lack of strong correct problems
(https://github.com/linebender/vello/issues/1063#issuecomment-2998084736):
- `/html/canvas/element/path-objects/2d.path.rect.selfintersect.html`
- There is currently no way to do put image properly in vello as we
would need to ignore all clips and other stuff (we try to work around
this on best effort basis)
https://github.com/linebender/vello/issues/1088
- `/html/canvas/element/pixel-manipulation/2d.imageData.put.*`
- precision problems
- `/html/canvas/element/path-objects/2d.path.stroke.scale2.html`
- `/html/canvas/element/path-objects/2d.path.arc.scale.1.html`
## Known servo problems
- bad performance due to blocking on GPU work
- some get/put intensive tests `TIMEOUT`
- proper shadow support (non-blocker as we already are living without it
now)
- support for rect shadow is there but unimplemented currently as that's
the state in raqote
Testing: `mach try vello` will run normal WPT (with raqote) +
vello_canvas subsuite that runs only on `/html/canvas/element`. All
subsuite expectations are stored separately.
Fixes: #36823Fixes: #35230
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
#37684 provided the backend for this change. The key range interface
just wraps a `IndexedDBKeyRange` and exposes the methods from it as per
the spec.
Spec: https://www.w3.org/TR/IndexedDB-2/#keyrange
Testing: WPT tests (some regressions have been exposed, but that's fine)
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
- Dates are now serialized as f64s (like how firefox does it)
- Array buffers are serialized with structured cloning (this is not the
most correct/efficent way to serialize them, however it is currently
better than not supporting array buffers at all)
- Array types are still unimplemented.
Testing: WPT
Fixes: Some panicking
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Remote end step of [element send
keys](https://w3c.github.io/webdriver/#element-send-keys)
> Step 8.2. Set the text insertion caret using [set selection
range](https://w3c.github.io/webdriver/#dfn-set-selection-range) using
current text length for both the start and end parameters.
Also check if the element is already an active element before focusing
(Step 7.7).
Testing:
`./tests/wpt/tests/webdriver/tests/classic/element_send_keys/form_controls.py`
---------
Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Signed-off-by: Kenzie Raditya Tirtarahardja <kenzieradityatirtarahardja18@gmail.com>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Implements `IDBFactory.cmp`, most of the work was done by #38123.
Testing: Covered by WPT (lots of flaky results: the appropriate tests
are in tests/wpt/meta/IndexedDB/idlharness.any.js.ini)
Fixes: None
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
- We no longer pretend that resize is always successful and simplify the
result computation.
- Adjust minimum window size to match other browsers and the test
expectation.
- Restrict some unnecessary access specifier.
Testing: ` ./mach test-wpt -r
"tests\wpt\tests\webdriver\tests\classic\set_window_rect\set.py"
--log-raw "D:\servo test log\set.txt" --product servodriver
{--headless}`
Fixes: #37804 as Task 8 is last task.
---------
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
Add virtual `window_position` to headless window so that `moveTo` and
WebDriver window command can work properly.
Testing: `./mach test-wpt -r
"tests\wpt\tests\webdriver\tests\classic\set_window_rect\set.py"
--product servodriver --headless`
Fixes: Task 7 of #37804.
---------
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
HTMLImageElement was missing the dimension source attribute, as step 9
from
[here](https://html.spec.whatwg.org/multipage/images.html#updating-the-source-set)
wasn't implemented. This meant that for an element like this:
```html
<picture>
<source media="(min-width: 1000px)"
srcset=""
width="84" height="29">
<img
src=""
width="25" height="25" alt="Wikimedia Foundation" lang="en" loading="lazy">
</picture>
```
The `width` and `height` attributes of the source tag were being
ignored. This broke stuff like these icons on the main page of
Wikipedia.
**Original:**
<img width="2252" height="229" alt="image"
src="https://github.com/user-attachments/assets/fa3fdd9d-5f91-43d4-bc9d-784b0a836d44"
/>
**Fixed:**
<img width="2252" height="229" alt="image"
src="https://github.com/user-attachments/assets/6f4ca4ae-e764-4394-ac31-9a92bbb456ab"
/>
Testing: If there isn't an existing test that covers this I'll make one,
waiting for the github runner to tell me whether this is covered and
then I'll amend the PR
---------
Signed-off-by: Leo Ring <leoring03@gmail.com>
Signed-off-by: Xiaocheng Hu <hu.xiaocheng@huawei.com>
Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
Co-authored-by: Xiaocheng Hu <hu.xiaocheng@huawei.com>
Co-authored-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
Depends on #37427.
In addition to the changes introduced by
https://github.com/servo/servo/pull/37065, there are several performance
improvements and nits as follows:
- Use the internal pseudo element for style matching, this will reduce
the performance regression by ~66%.
- Manual construction of the `Text` node inside a text container. This
is followed by the modification of the inner `Text` node instead of
using `SetTextContent` which is more expensive.
- Use `implemented_pseudo_element` instead of
`text_control_inner_editor` `NodeFlag` to handle the special cases that
these elements should follow, specifically the:
- focus delegation workaround;
- selections; and
- line height resolving.
- More documentation.
Servo's side of: https://github.com/servo/stylo/pull/217
Testing: No new unexpected WPT failure, except for the one introduced by
https://github.com/servo/servo/pull/37065/.
Fixes: #36307#37205
---------
Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
Spec:
https://drafts.csswg.org/cssom/#dom-documentorshadowroot-adoptedstylesheets
Implement `DocumentOrShadowDOM.adoptedStylesheet`. Due to
`ObservableArray` being a massive issue on its own, it will be as it was
a `FrozenArray` at first. This approach is similar to how Gecko
implement adopted stylesheet. See
https://phabricator.services.mozilla.com/D144547#change-IXyOzxxFn8sU.
All of the changes will be gated behind a preference
`dom_adoptedstylesheet_enabled`.
Adopted stylesheet is implemented by adding the setter and getter of it.
While the getter works like a normal attribute getter, the setter need
to consider the inner working of document and shadow root StylesheetSet,
specifically the ordering and the invalidations. Particularly for
setter, we will clear all of the adopted stylesheet within the
StylesheetSet and readd them. Possible optimization exist, but the focus
should be directed to implementing `ObservableArray`.
More context about the implementations
https://hackmd.io/vtJAn4UyS_O0Idvk5dCO_w.
Testing: Existing WPT Coverage
Fixes: https://github.com/servo/servo/issues/37561
---------
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Previously, we have failing many subtests in `*/user_prompt.py` with
prefix `capabilities0-*`. The name of the subtest was probably changed
before, hence the failing expectation is not removed when we do `./mach
update-wpt`. Here we reupdate the expectation.
Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
The `IFrameCollection` was previously rebuilt too often. This PR tries
to address the todo, to only rebuild the IFrameCollection when
necessary.
Testing: `CSS Selector Invalidation: :has() invalidation should not be
O(n^2)` wpt-test changed status from timeout to failed.
Fixes: #38131 (IFrameCollection::validate accounts for 30% of script
time in DOM heavy scenarios)
Co-authored-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Previously the webdriver do not wait for focus to complete, which can
cause some instability.
No matter interact as human or webdriver, the focus chain always goes
as: Embedder forwards -> Constellation (do some updates) -> Embedder (do
some updates).
---------
Signed-off-by: Euclid Ye <euclid.ye@huawei.com>