Commit Graph

1327 Commits

Author SHA1 Message Date
Martin Robinson
e7ee1171d8 script: Remove some proprietary Servo-only testing methods from Window (#42728)
These three methods date back from the very early history of Servo and
are no longer necessary:

1. `Window.debug`: `console.log` is a better replacement for this method
   now. A manual test that tests the very basics of JavaScript used
   this. This test is removed as well.
2. `Window.gc`: This can be replaced with `TestUtils.gc`, which is part
    of a W3C specification.
3. `Window.js_backtrace`: This method is moved to `ServoTestUtils`.

Testing: Tests are updated to reflect these changes.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-02-20 17:32:34 +00:00
Luke Warlow
853fcf4fda script: Introduce ServoTestUtils and a forceLayout() function (#42714)
This introduces a new `ServoTestUtils` namespace with a `forceLayout()`
function. This `forceLayout()` function returns an object which
currently has an array of the phases ran by layout. Also moves
`panic()`, `crashHard()` and `advanceClock()` from `TestBinding` to this
new namespace.  `TestBinding` is meant to test the bindings generation,
but these are more generic helpers for Servo-only tests.

Testing: This change adds a series of Servo-only tests that verify the
behavior of the new `forceLayout()` function. Tests that rely on the
moved interfaces are updated and should continue to pass.

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-02-20 13:00:06 +00:00
Taym Haddadi
590ae85779 Indexeddb: transaction lifecycle (#41508)
Indexeddb: transaction lifecycle

Testing: more Indexeddb test should pass
part of #40983

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2026-02-19 11:05:33 +00:00
Oriol Brufau
2a3f23c78d Upgrade Stylo to 2026-02-02 (#42361)
This continues #41916

Changelog:
- Upstream:
360787fff5...7cd2a178d3
- Servo fixups:
e4d50e905e...d9831d464b

Stylo tracking issue: https://github.com/servo/stylo/issues/305

In particular, this adds support for `alignment-baseline` and
`baseline-shift`, and turns `vertical-align` into a shorthand of them.
This also introduces `vertical-align: center`.

Testing: Various tests improve. Some internal tests are updated because
they were wrong. And some fail because we don't support presentation
attributes on SVG elements.

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2026-02-09 11:16:42 +00:00
Martin Robinson
36aa8e9c73 layout: Expand text clipping boundaries based on the largest advance in run (#42403)
Servo does not yet calculate the ink overflow area, as this sort of
thing is usually a result of `contain: paint` which Servo does not
support yet. We just need to ensure that text clipping is large
enough to contain the ink of all of the glyphs in the run. This change
just expands the rectangle based on glyph advances by 2 times the
largest advance, which should be big enough for most glyphs.

This is a big of a workaround until we have support for `contain:
paint`.

Testing:
- This change adds a Servo-specific test to ensure glyphs are fully
inked. While this test would run just fine in other browsers, it isn't
very
useful to them as this is test is very specific to the way that Servo
draws
glyphs.
- This also fixes a variety of existing WPT tests.

Fixes: #41413.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-02-07 22:12:15 +00:00
Shubham Gupta
2ca7808083 script: Remove Worker scope from PerformancePaintTiming (#42409)
This will align `PerformancePaintTiming` interface according to `W3C`
specifications.

Specifiactions:
[PerformancePaintTiming](https://w3c.github.io/paint-timing/#sec-PerformancePaintTiming)

Testing: `_mozilla/mozilla/interfaces.worker.html`

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
2026-02-06 16:32:05 +00:00
Martin Robinson
edbce7e854 layout: Properly count characters when segmenting IFC text (#42399)
There was a bug where characters were not properly counted when
segmeting IFC text. Immediately incrementing the
`current_character_index` meant that the count was always one character
off. This character count is mainly used for drawing selections and
really matters when multiple text segments are in a single IFC. This
change fixes that by counting characters in the same way we were
counting byte indices for the text.

Testing: This change adds a Servo-specific WPT-style test. As it is
quite
difficult to reproduce the correct display in a different way, a
mismatch test
is used. Since this is mainly about appearance and is very specific to
our
implementation the test is Servo-specific.
Fixes: #42354.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-02-06 13:37:19 +00:00
Oriol Brufau
4d0606c0c7 Add test tracking web-exposed CSS properties (#42385)
When doing a Stylo upgrade, it may happen that a commit imported from
upstream accidentally enables a CSS property on Servo. That is even more
likely after https://phabricator.services.mozilla.com/D280900, since the
new default is that properties are enabled everywhere.

Therefore, this test will help detect these accidents. Ideally, the test
would only track CSS properties exposed to stable, but that requires
running the test without experimental features, or using internal APIs.
So for now, the test will also track experimental properties.

Testing: just adding a new test, no behavior change

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2026-02-06 03:51:57 +00:00
Steven Novaryo
42359b26a2 script: Impl UserActivation interface (#42060)
User activation is a concept used to prevents annoying usage of specific
API (Fullscreen API, Virtual Keyboard) to the user by states that the
API needs to have in order to process. This PR implements the
`UserActivation` interface and keep track of the last user interaction.
Each `Window` will keep track the [last activation time
stamp](https://html.spec.whatwg.org/multipage/interaction.html#last-activation-timestamp),
which will be set if there are a triggering input event firing in the
`Window` and propagating across the browsing contexts ancestors and
descendants. These timestamp could be consumed, and the timestamp will
be set to negative infinite.

It is then used to gate some APIs within browser that is determined as
transient activation consuming-gated APIs, which needs transient
activation to be true and consumes the activation. For the purpose of
testing, this PR would implement this behavior on fullscreen API which
is used to test activation consuming behavior.

Spec:
https://html.spec.whatwg.org/multipage/interaction.html#the-useractivation-interface

Testing: Existing WPT

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
2026-02-03 23:20:54 +00:00
Martin Robinson
db2a7cbe2a layout: Add support for -webkit-text-security (#42181)
This change adds support for the unspecified `-webkit-text-security`
property. All major browsers support this property. The benefit of
adding this property is that the first addition of a prefixed CSS
property will allow us to start running MotionMark.

This depends on servo/stylo#295.

Testing: Three new Servo-specific tests are added for this change. There
are a few `-webkit-text-security` tests in WPT, but they do not seem
to test basic functionality.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-31 19:12:59 +00:00
Euclid Ye
624e9b49e1 css: Enable registered custom properties with CSSOM but stay unanimatable (#42136)
Many websites use Tailwind CSS script which utilizes registered custom
properties.
This PR makes such websites look as expected, such as #42129.

Before: 
<img width="485" height="120" alt="image"
src="https://github.com/user-attachments/assets/428000b1-eed1-4f10-bbf8-eca9e7b630f5"
/>

After:
<img width="487" height="82" alt="image"
src="https://github.com/user-attachments/assets/ab016cbf-9c00-4bd8-adc8-be28f13e42e5"
/>


Testing: Updated existing WPT results.
Fixes: #42129
Fixes: #41417 

Stylo Companion: https://github.com/servo/stylo/pull/293

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-01-31 14:11:35 +00:00
Martin Robinson
bfccb3ec41 layout: Improve and make consistent the look of various form controls (#42085)
This change makes a variety of changes to form controls to improve their
appearance. In general, they now look more similar to Chrome and
Firefox:

- Padding is added everywhere
- Checkboxes and radio buttons are more centered in their containers
  and they no longer affect the baseline of their surroundings.
- Buttons react when hovered and clicked.
- Form control styles are organized a bit.
- More controls have a style making it obvious they are disabled.

There's more work to do here, but it is saved for followup changes
- Checkbox checks are not well positioned -- they should likely be an
image.
- More work is necessary to ensure that the controls look consistent at
all font sizes and that font sizes from the surrounding content do not
leak in.
 
Testing: This change causes some WPT tests to start passing some to
start failing,
due to the fact that we do not properly implement all of the behavior of
form controls.

Failures:
 - `/css/css-flexbox/stretch-flex-item-checkbox-input.html` and
`/css/css-flexbox/stretch-flex-item-checkbox-input.html`: These test the
  behavior of checkboxes and radio buttons in flex containers, but since
  we do not have a Shadow DOM or custom rendering for our controls, we
  must limit the height and width of the controls. Further refinement
  is necessary here to get this working properly, though it only affects
  controls in flex.
- `/css/css-grid/subgrid/subgrid-button.html`,
  `/css/css-transforms/transform-input-002.html`,
`/html/rendering/widgets/button-layout/scrollbars.html`: These two seem
to be
  minor subpixel variations in the output.
-
`/html/rendering/widgets/baseline-alignment-and-overflow.tentative.html`:
This tests uspecified behavior about where baselines come from in
controls.
  We do not implement this yet.
-
`/pointerevents/pointerevent_lostpointercapture_for_disconnected_shadow_host.html`:
We do not support the `lostpointercapture` event so I suspect this is
just
  timing out in a slightly different way.

Fixes: #34969.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-27 10:28:00 +00:00
Shubham Gupta
5504a05158 script: Expose toJSON on LargestContentfulPaint (#42004)
This PR targets on adding JSON to `IDL` to show all supported values in
JS API.

This was missed during implementation. Screenshot Attached for JS API 

Testing: `components/servo/tests/largest_contentful_paint.rs` 
Fixes: None, this is just an refinement.

<img width="772" height="360" alt="Screenshot from 2026-01-19 17-13-20"
src="https://github.com/user-attachments/assets/1730f3f6-423c-466c-b0d4-976d35d82827"
/>

---------

Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
2026-01-24 10:40:22 +00:00
Martin Robinson
ceedfec729 script: Allow selecting text in input fields with the mouse (#42049)
This change adds basic support for selecting text via dragging the mouse
in text inputs. This is currently handled entirely inside of text
inputs, but will be integrated into a more global drag handler when that
is implemented in the `DocumentEventHandler`. This means that events
that happen outside of the text input currently don't update the
selection.

Testing: This adds Servo-specific WPT-style tests. There are WPT tests
that test this sort of behavior, but I believe they rely on selection
events, which we have no implemented yet (we will soon).

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-22 07:51:51 +00:00
Martin Robinson
983482b5f3 script: Ignore platform mouse move events that do not change the cursor location (#42034)
winit on macOS seems to send a mousemove event right before mouse button
up events. This interferes with interactive use of text boxes -- for
instance double-clicking to select the hovered word. This change makes
it so
that mouse move events that do not change the cursor location are
ignored.

Testing: This change adds a Servo-specific WPT-style test.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-20 18:30:59 +00:00
Martin Robinson
e8f88468d0 script: Consider a selection collapsed when the edit point equals the selection origin (#41978)
In text inputs, the edit point can be equal to a non-`None` selection
origin for a variety of reasons such as when the selection is set by a
DOM API or when a composition event inserts a zero length string. In
both of these cases, we should treat the selection as collapsed. It is
important to do this because for the purposes of arrow key movement and
context menu entries, we should think of the text input as not having a
selection at all.

Testing: This change adds a Servo-specific WPT test, as key press
behavior is
platform specific.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-19 15:08:40 +00:00
Rod Borovyk
eacdbd9a34 layout: Accept lengths in arbitrary units for SVG width and height (#40761)
Previously it was only possible to set width and height of SVG elements
in pixels. These changes allow parsing other units like em using a CSS
parser in SVGSVGElement and resolving them to computed values in the
layout code.

Testing: Tested manually
Fixes: -

---------

Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2026-01-19 13:31:27 +00:00
Martin Robinson
93fa5d3e0a layout: Properly account for transforms when finding glyph index (#41931)
This change makes it so that tranforms (including CSS transform and
scrolling) are properly accounted for when calculating glyph indices.
Containing block sizes are moved to `BaseFragment`. This should reduce
the size of the StackingContextTree a little.

Testing: A Servo-specific WPT-style test is added for this change.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-01-18 13:07:25 +00:00
Martin Robinson
37cef428de script: Do not adjust the edit point in text fields when non-primary buttons are pressed (#41974)
We should not move the text cursor or change the text selection when
non-primary (such as the right) mouse buttons are pressed. Doing so
interferes with the common operations:

1. Select text
2. Open context menu
3. Copy text

This change fixes that.

Testing: New WPT-style tests are added.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-17 13:30:59 +00:00
Martin Robinson
ee8c727944 script: Add selection behavior for double and triple click in text fields (#41926)
This change adds support for updating the selection when double and
triple clicking in text fields. Double clicking selects the most
relevant word while triple clicking selects the entire line.

Testing: This change adds unit tests for `Rope` as well as a
Servo-specific WPT style test. These behaviors are platform
dependent.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-16 23:03:05 +00:00
Martin Robinson
5c76c529e1 layout: Add support for clicking past the end of multiline inputs (#41909)
Make it so that clicking past the end of the text of a multiline input,
moves the edit point to the end of that line. Now we evaluate all
potential target `TextFragment`s and find the most appropriate one,
putting the edit point there.

Testing: This updates expected test results for the `<textarea>`
clicking tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-01-15 08:11:12 +00:00
Martin Robinson
d5dcdd6e06 script: Add support for setting the edit point with the mouse in <input> and <textarea> (#41906)
This change updates and implements the old `query_text_index` layout
query to properly look for the glyph index of a point within a node's
`Fragment`s. This should work properly with the shadow DOM of both
`<input>` and `<textarea>` elements. In particular, multiple lines are
supported.

Caveats:
 - `<input>` and `<textarea>` that are transformed are currently not
   supported. This will happen in a followup.
 - For multi-line inputs, we should be finding the text offset of the
   nearest line that is within the block range of the click. This will
   happen in a followup.

Testing: This change adds two Servo-specific WPT-style tests. These are
Servo-specific because the behavior of clicking in text fields isn't
fully specified.

Fixes: #35432
Fixes: #10083

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-01-14 13:23:43 +00:00
Martin Robinson
bf452331b1 Remove the vello_cpu compilation option and enable it by default (#41820)
There is currently no way to disable canvas on the whole in Servo, so
one canvas backend must be enabled for the build to succeed. Currently,
the Vello GPU backend is much slower than the CPU backend, as it
downloads pixels to CPU memory before reuploading them and displaying
them. Fixing that requires allowing rendering Vello GPU contents to a
OpenGL texture or some kind of surface that can be represented by an
OpenGL texture during display.

Historically, the approach that other browsers have taken with regard to
GPU canvas is that CPU canvas is used as a fallback until the GPU
version can be counted on to be reliably faster. I think that Servo
should take the same approach. We should always expose a CPU version of
canvas and a GPU version. Embedders should not care about how these are
implemented, just that they work as expected and perform well.

Testing: This change just adjusts the build configuration option, so no
tests are necessary.
Fixes: #40779

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-12 22:42:14 +00:00
Martin Robinson
3cda70dbbb script: Include click count as the detail of mouseup and mousedown events (#41833)
This change improves the counting of clicks for mouse button events by
ensuring that `detail` property of those events includes the click
count. This `detail` differs from that of `dblclick` events where the
`detail` is always 2. In addition, it ensures that the click count can
increase for mouse buttons that do not cause `click` and `dblclick`
events (such as the right mouse button).

Testing: This change adds two Servo-specific WPT-style tests. While this
behavior is specified a bit, the details are implementation specific.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-12 08:47:20 +00:00
WaterWhisperer
56bc26a7cc script: Implement Origin API (#41712)
Testing: `./mach test-wpt /html/browsers/origin/api/`
Fixes: #41106

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2026-01-08 15:35:39 +00:00
Josh Matthews
c6f2fc2eb5 script: Capitalize Content-Type key in formdata. (#41722)
The tests were performing exact string matching on the contents of the
request body, so this change allows them to match.

Testing: Newly passing tests.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-01-07 06:05:41 +00:00
Freya Arbjerg
c2e7484ef7 layout: Fix caret never rendering following a newline (#41330)
Fixes caret rendering when the caret is placed a the start of a line

```
Hello,

{here}World!
```

Also adds a utility function to the `range` crate.

Note that the rendering of the caret on many non-empty lines is still
broken due to the presence of several other bugs

Testing: I ran unit tests. Add a new reftest
Fixes: Part of #40839

---------

Signed-off-by: Freya Arbjerg <git@arbjerg.dev>
2025-12-18 22:31:25 +00:00
Taym Haddadi
b2aa0ac859 Fix RefCell double-borrow in Window::remove_reporting_observer (#41261)
lot of RefCell already borrowed crashes are because of code like this:
```
if let Some(index) = self
    .array
    .borrow()
    .iter()
    .position(|p| &**p == r_p)
{
    self.array.borrow_mut().remove(index);
}
```
this will always panic whenever the position() finds an index, because
the immutable borrow from borrow() is still alive when we call
borrow_mut().

Fix by ensuring the borrow is dropped before taking a mutable borrow (by
computing the index in a separate scope / temporary), then remove
safely.



Testing: added crash test.
Fixes: #41260

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-12-14 21:11:32 +00:00
Josh Matthews
d86d2a90aa script: Use rooted typed arrays in generated code and buffer source APIs (#41228)
There are two flavours of the mozjs `TypedArray<T>` wrapper for typed
array objects: one stores a `Box<Heap<*mut JSObject>>`, while the other
just has a bare `*mut JSObject`. The second one must only be stored
inside the `CustomAutoRoot` rooting values, but we were using it in many
other places like WebIDL dictionaries without rooting it safely. These
changes make our typed array APIs always use
`RootedTraceableBox<TypedArray<T>>` with the `Box<Heap<*mut JSObject>>`
flavour, which ensures that the JS object stored inside the typed array
wrapper is always visible to the SpiderMonkey GC.

Testing: Adds a new test that crashes without these changes.
Fixes: #41206

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-12-12 14:33:45 +00:00
Steven Novaryo
e05e9730e7 dom: Focus scroll to the element only if it is not visible (#40447)
Currently when we call a `Focus` we always scroll a focusable element to
the center of the container. However, this would causes a different
behavior where UAs wouldn't scroll when a focus is called to a visible
element. This PR add implementations following the behavior of Firefox
[nsFocusManager::ScrollIntoView](e613f4df35/dom/base/nsFocusManager.cpp (L3121)),
where we are scrolling to the element if it is not visible.

This would enhance the user experience of focusing an input element,
where we should avoid moving the element if it is visible.

Incidentally fix a calculation bug for the calculation of
`ScrollIntoView` with `nearest` block or inline option.

Testing: Private WPT for the implementation defined behavior and public
WPT for the bug.

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
2025-11-28 01:52:21 +00:00
Taym Haddadi
66a50ad687 Fix RefCell already borrowed panic in HTMLMediaElement::set_audio_renderer (#40729)
Fix RefCell already borrowed panic in
HTMLMediaElement::set_audio_renderer

Testing: new crash test should pass.
Fixes: #40720

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-19 00:34:15 +00:00
Simon Wülker
c039078ab3 xpath: Apply predicate list before sorting result when evaluating location step expression (#40592)
The result of a predicate can depend on the position of the node in its
set, and this position is dependent on the axis that the node set came
from. This is specified in
https://www.w3.org/TR/1999/REC-xpath-19991116/#predicates.

Additionally, this change fixes a small bug in the implementation of
`preceding::` (https://github.com/servo/servo/pull/40588) where the root
of a subtree would be included twice. That wasn't discovered earlier
because nodes are deduplicated at the end of the evaluation.

Testing: New tests start to pass, this change adds more tests

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-13 10:27:06 +00:00
Simon Wülker
900243f00d tests: Remove duplicate xpath test (#40565)
The test query `//L/*` is present twice in the xpathmark-FT test suite.
Our WPT harness was complaining about that, so I've removed the second
test instance.

Depends on https://github.com/servo/servo/pull/40564
Testing: The relevant test is now `OK`

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-11 16:48:33 +00:00
Simon Wülker
9207c7d6b4 tests: Import the XPathMark-FT test suite (#40541)
[XPathMark-FT](https://web.archive.org/web/20070720155520/https://users.dimi.uniud.it/~massimo.franceschet/xpathmark/FT.html)
is a test suite targeting xpath 1.0 from 2005. It's not very big, but
covers all operators, axes and functions. I've converted it to a web
platform test in `mozilla/`.

This exposes numerous new bugs (one of which being
https://github.com/servo/servo/issues/40540), which will be fixed in
followup changes. Firefox and chrome both pass all tests.

Testing: This change adds new tests
Fixes #39726

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-11 10:45:22 +00:00
Excitable Snowball
a5c3cc3b4e script: Use InputEvent for input events (#39989)
Use `InputEvent` for text input and set appropriate values for the
`composed`, `data`, `isComposing`, and `inputType` attributes. Use a
placeholder for `dataTransfer` attribute and `getTargetRanges` function,
as they are only applicable to contenteditable, which isn't implemented.

Testing: I added two tests under `tests/wpt/mozilla/tests/input-events`
based on the similarly named ones for contenteditable under
`tests/wpt/tests/input-events`.
Fixes: https://github.com/servo/servo/issues/36398

---------

Signed-off-by: Excitable Snowball <excitablesnowball@gmail.com>
2025-11-08 23:04:03 +00:00
Gregory Terzian
933ebe428d script: extend the prevention of the firing of load events to all iframes (#40401)
This extends the preventing of the firing of the load events when there
is a pending navigation from the initial blank document only to all
iframes. Part of https://github.com/servo/servo/issues/31973

Testing: tests/wpt/mozilla/tests/mozilla/FileAPI/file-upload.html
Fixes: This should fix the intermittency of
https://github.com/servo/servo/issues/40348

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-11-07 15:47:36 +00:00
Shubham Gupta
71196c02ea Add basic IDL implementation for LargestContentfulPaint (#39714)
Add basic `IDL` implementation for `LargestContentfulPaint`

Testing: Tested locally
Fixes: N/A

<img width="800" height="210" alt="Screenshot from 2025-11-06 12-56-37"
src="https://github.com/user-attachments/assets/af453b8d-7605-4300-8c87-c2574feff81f"
/>

---------

Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
2025-11-07 02:56:30 +00:00
Martin Robinson
f08460cded script: Handle broken image icon in HTMLImageElement (#40429)
Instead of having the `ImageCache` return the broken image icon for
failed loads, have `HTMLImageElement` explicitly request it. This means
that the image is loaded on demand (reducing the usage of resources) and
also simplifying the interface of the `ImageCache` greatly.

In addition, the display of the broken image icon is improved, more
closely matching other browsers. A test for this display (which was
falsely passing before) is updated to reflect the new display of the
broken image icon.

Testing: There is a Servo-specific test for this change. Some WPT tests
start to fail as well. Before these were not properly loading the broken
image icon so they were failing before, just in a hidden way.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-11-06 09:36:21 +00:00
Luke Warlow
8ca4ecba02 script: Implement ToggleEvent and use for <details> element (#40271)
Implement ToggleEvent and use for details element

Testing: Covered by existing WPTs

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2025-11-02 18:20:18 +00:00
Martin Robinson
f5865c77f9 wpt: Turn on selectFiles and handle asynchronicity in FileAPI test (#40349)
This change fixes the Servo-specific FileAPI tests which need the
special `SelectFiles` API. In addition, file selection is now totally
asynchronous, so update the tests to handle this.

Testing: This change fixes some tests.
Fixes: #40348.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-02 11:07:54 +00:00
Kingsley Yung
e061e5c1b9 script: Implement Compression API (#39658)
The patch implements Compression (https://compression.spec.whatwg.org/)
with the compression and decompression provided by the `flate2` crate
(https://crates.io/crates/flate2).

`flate2` supports several different backends, controlled through the
crate's features. By default, it uses `miniz_oxide`
(https://crates.io/crates/miniz_oxide).

`flate2` provides three modules `read`, `write` and `bufread` which work
on instances of the `std::io::Read`, `std::io::Write` and
`std::io::Bufread` traits, respectively. The `write` module is chosen in
the patch since it matches the streaming model in the specification.

Testing: Enable WPT for Compression API, and introduce WPT expectation.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-10-27 08:21:35 +00:00
Simon Wülker
f0c18f7dc8 xpath: Verify context node in XPathExpression::evaluate_internal (#40105)
`evaluate_internal` is the common code path used when evaluating an
expression, so any verification that always applies must happen there.

Testing: This change adds a test
Fixes https://github.com/servo/servo/issues/40104
Part of #34527

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-24 12:27:03 +00:00
batu_hoang
813280860e Box tree construction: only unset pseudo elements if the box is rebuilt (#39930)
Box Tree re-construction may cause the loss of pseudo element:
https://github.com/servo/servo/issues/39225#issuecomment-3404462089,
then causes transition stucks.
We should only unset  pseudo elements if the box is rebuilt.

Testing: fix manual test in https://github.com/servo/servo/issues/39225,
CI reports no regression:
[action](https://github.com/longvatrong111/servo/actions/runs/18572401080)
Fixes: https://github.com/servo/servo/issues/39225

cc: @xiaochengh

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
2025-10-23 03:01:41 +00:00
Simon Wülker
201364060c xpath: Infer result type when reusing result value (#39958)
When the provided xpath result type is `XPathResult.ANY_TYPE` then we
need to infer the result type from the result value. Previously we were
doing this in the XPathResult constructor, but that isn't being called
when we reuse a result. Instead, we move the inferring to right after we
evaluate an expression.

Testing: This change adds a new test
Fixes https://github.com/servo/servo/issues/39955
Part of #34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-18 04:01:52 +00:00
Simon Wülker
01641b2374 xpath: let absolute path expressions begin at the root node (#39965)
Testing: This change adds a test
Fixes #39964
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-17 18:11:53 +00:00
Gregory Terzian
1af34ca483 script: prevent panic when opening an auxiliary using a window with a closed browsing context(iframe) (#39922)
When one unbinds an iframe from the tree, its browsing context is
destroyed, however if script keeps a reference to the window, it can
still try to open an auxiliary, resulting in a crash because the
constellation has already removed the browsing context. This adds a
non-intermittent test for the problem, and addresses it in a seemingly
ad-hoc way by checking whether the browsing context has already been
discarded, and if so doing an early return, as part of the window open
steps.

Testing: Added a crash test in the mozilla wpt folder.
Fixes: https://github.com/servo/servo/issues/39716

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-10-17 12:05:08 +00:00
Josh Matthews
86e61b0415 Add abort signal preference to experimental web features (#39421) (#39943)
This way we have full coverage on WPT rather than the specific folders
with tests. The timeout in `/performance-timeline/` will be addressed by
#39941. The timeout under `/webmessaging/` [makes us match all other
browsers](https://wpt.fyi/results/webmessaging/message-channels/close-event/document-destroyed.tentative.window.html?label=experimental&label=master&aligned).

Testing: Lots of new passing tests.
Fixes: #39904
Fixes: #39513

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2025-10-17 06:13:26 +00:00
Simon Wülker
84d30339b5 xpath: Cast query result to desired type (#39764)
When running an XPath query, users supply a target result type (eg
`XPathResult.NUMBER_TYPE`). When this type does match the return value
of the query, then we need to convert to it.

See
https://searchfox.org/firefox-main/rev/ab5bf2401717970560597083d6ac72915bde2d89/dom/xslt/xpath/XPathResult.cpp#160
for the relevant part in gecko.

Testing: This change adds a test
Part of #34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-13 13:20:55 +00:00
Simon Wülker
de7e776e28 script: Restrict allowed node types for XPath context node (#39751)
See
https://searchfox.org/firefox-main/rev/b30a9b734819436853abf4eba6d768037514b3f6/dom/xslt/xpath/XPathExpression.cpp#115
for the equivalent code in firefox. Chrome also throws the same error.

Testing: This change adds a test
Part of #34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-11 08:28:01 +00:00
Simon Wülker
f6bdad4c05 Add test-wait to /_mozilla/shadow-dom/move-element-with-ua-shadow-tree-crash.html (#39476)
Without the `test-wait` class the testharness won't wait until the
actual test executes.

I'm not sure if this is the reason for
https://github.com/servo/servo/issues/39473 (I don't understand how that
could cause the test to time out), but it's definitely *a* bug. The test
is not intermittent locally. Let's do a couple try runs and then see
where we go from there.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-09 10:09:17 +00:00