When reporting an exception attempt to extract `ErrorInfo` from the
stack of the exception.
Testing: Covered by existing tests, expectations updated.
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
`Castable::is<T>()` calls `get_dom_class()` in a way that incurs a
roundtrip to the JS engine and
multiple pointer indirections:
self.reflector().get_jsobject().get() -> JSObject
Object.shape -> BaseShape.clasp -> JSClass
DOMJSClass.dom_class -> DOMClass
interface_chain[depth] == ID -> bool
Since the ID doesn't change after creation of reflectors, we can instead
store the ID on the reflector
and avoid most of that cost. The trick is to use a Depth First Search to
generate IDs that allow a
range check for `Castable::is<T>`. An example of IDs in the DFS looks
like:
EventTarget = 0
Node = 1
CharacterData = 2
Text = 3
CDATASection = 4
Comment = 5
ProcessingInstruction = 6
Document = 7
HTMLDocument = 8
XMLDocument = 9
Testing: Green try run at
https://github.com/webbeef/servo/actions/runs/24640508040 and manual
testing with general browsing.
Signed-off-by: webbeef <me@webbeef.org>
Replaced `GamepadButtonList` interface with a frozen array of gamepad
buttons to match the gamepad webidl specification.
Testing: No idlharness tests possible since the values can't be accessed
without a real gamepad.
Fixes: #44333
---------
Signed-off-by: Rover track <rishan.pgowda@gmail.com>
This change makes it so that hard line breaks are not shaped during
inline formatting context creation. Instead they are a separate variant
of a new `TextRunItem` enum. This will make it easier to start
linebreaking later in the flow of inline layout.
Testing: This fixes three WPT tests, likely because we are now properly
using the BiDi level of BiDi control characters. One test starts
failing, but
it depends on tab rendering, which we do not currently support properly.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
While working on this, I realised that the `current_state`
computation was wrong. Instead, the spec actually clearly
defines what to do, but I hadn't found it yet. The code
now correctly implements state computation and voila, it
also fixes the previous underline issue that I didn't
understand why it would fail.
Part of #25005
Testing: WPT
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Implement the `Sanitizer.get()` method.
Same as the previous patches on Sanitizer API, the steps related to
processing instructions are marked as TODO. Support for process
instructions was recently added to the specification, and we will
implement it later when tests are ready.
Testing: Covered by WPT tests in
`sanitizer-api/sanitizer-get.tentative.html`
Fixes: Part of #43948
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
In DOM APIs, `Node.childNodes` is a `NodeList` that has an
`.item(index)` method that allows random access, but DOM nodes only
store pointers to their first/last child and next/previous sibling. The
previous implementation involved keeping a "last accessed" pointer, and
a significant amount of logic to find the requested index by walking
next/previous sibling pointers from whichever of last accessed, first
child, or last child is nearest. This logic sometimes incorrectly
assumed the (nullable) last accessed pointer to be present, causing a
panic in `Option::unwrap`.
Rather than try to fix that logic, this replaces entirely with the
approach suggested in #25206 and used [by
Firefox](https://searchfox.org/firefox-main/source/dom/base/nsChildContentList.h):
keep a cached `Vec` of pointers to all child nodes, created lazily when
needed, and invalidated whenever any part of it changes.
Testing: the first commit adds a failing WPT crashtest, the second
commit fixes it
Fixes: https://github.com/servo/servo/issues/25206
Fixes: https://github.com/servo/servo/issues/36764
---------
Signed-off-by: Simon Sapin <simon@igalia.com>
Implement sanitizer configuration validation algorithm, and complete the
"set a configuration" algorithm.
The steps related to processing instructions are marked as TODO. Support
for process instructions was recently added to the specification, and we
will implement it later when tests are ready.
Specification:
- https://wicg.github.io/sanitizer-api/#sanitizerconfig-valid
- https://wicg.github.io/sanitizer-api/#sanitizer-set-a-configuration
Testing: Covered by WPT tests in
`sanitizer-api/sanitizer-config.tentative.html`
Fixes: Part of #43948
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
As titled.
Testing: Manually tested with multiple real websites with viewbox in
svg.
It looked terrible before, but now looking good!
New passing in WPT.
Partially addresses: #38985
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Instead of readily adding a strut for text carets when processing a line
break, wait until a line is finished. This allows placing a strut on the
final line. In addition to fixing #41338 this will also make it possible
to handle line breaks as a separate kind of text run item so that we can
preserve shaping results between layouts.
In addition, some changes are made in script to ensure that these
placeholders
are never placed for non-textual input elements.
Testing: This change adds a Servo-specific WPT test. Caret rendering
isn't specified.
Fixes: #41338
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
With these changes, we now fail the minimum set of tests. That is to
say: we don't fail any test that no other browser fails. All test
failures therefore match at least 1 other browser.
The one exception is the updated test expectation. That's because all
browsers fail this test in the exact same way, hence updating the
expectation. We fail it, since I don't know how browsers reach to that
point. I think it's related to traversal of the contained children and
the order that they are traversed in. Unfortunately my attempts at
fixing that have not been fruitful, so leaving that one for now.
Part of #25005
Testing: WPT
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Co-authored-by: Martin Robinson <martin@abandonedwig.info>
Add the Storage Standard WebIDL for NavigatorStorage and StorageManager,
wire navigator.storage on Window and Worker, and implement persisted(),
persist(), and estimate().
Testing: covered by WP test.
part of #39100fixes#39101
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
The tex-3d-size-limit.html test verifies that TexImage3D errors out with
gl.INVALID_VALUE if the width / height / depth parameters are greater
than gl.MAX_3D_TEXTURE_SIZE / 2 ** level, in accordance with the mipmap
levels definition.
This patch adds this checks, and fixes a s/depth/level/ typo, and should
stabilize tex-3d-size-limit.html: all its sub-tests will succeed until
the first call to (not implemented) TexSubImage3D, that will end the
test.
It's still possible for the test to fail on environments where
gl.MAX_3D_TEXTURE_SIZE is not 8192 (because the numbering of tests will
be different), and this will have to be until we make all sub-tests
pass, i.e. TexSubImage3D is implemented.
Testing: A bunch of expected failures are removed.
Fixes: https://github.com/servo/servo/issues/44280
Signed-off-by: Simon Martin <simon@nasilyan.com>
Several times, we first need to capture the relevant nodes, perform a
step and then iterate over the nodes. Previously, we would iterate over
it, but the iterator could have moved, hence we would jump over some
nodes.
Instead, capture these beforehand and then iterate over them.
Also fixes the issue where text-decoration wasn't properly checked,
since its a shorthand for 3 longhands. And a PropertyDeclarationBlock
only has longhands.
The two regressions are for tests that now generate the correct HTML,
but their ranges are incorrectly moved from the `a` to the `b`. I went
through the relevant algorithms and didn't spot the mistake. To keep on
making babysteps towards a full implementation, I will tackle these in a
follow-up. These algorithms are already difficult enough to reason
about.
Part of #25005
Testing: WPT
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This brings up to date with the specification for declarative shadow
roots: https://github.com/whatwg/html/pull/12267.
The `shadowrootslotassignment` attribute on `<template>` elements
specifies the slot assignment mode used by the declarative shadow root
created by the template.
Testing: New tests start to pass
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Since 5634eab8cc, tex-3d-size-limit.html is not crashing anymore, and
even though I updated the test expectations and the test is consistently
passing locally at that commit, it's now failing some tests that should
have failed since the beginning (since there's no associated check in
the code).
I'm not sure why things seem to work with the previous test expectations
update and will follow-up, but in the meanwhile let's update them.
With this, things seem to be pretty good:
```
$ ./mach test-wpt --dev tests/wpt/webgl/tests/conformance2/textures/misc/tex-3d-size-limit.html --repeat 1000 [...]
web-platform-test
~~~~~~~~~~~~~~~~~
Ran 92000 checks (91000 subtests, 1000 tests)
Expected results: 92000
Unexpected results: 0
OK
```
Testing: Test seems to pass consistently with the updated expectations.
Fixes: https://github.com/servo/servo/issues/44280
Signed-off-by: Simon Martin <simon@nasilyan.com>
Automated downstream sync of changes from upstream as of 19-04-2026
[no-wpt-sync]
Signed-off-by: WPT Sync Bot <ghbot+wpt-sync@servo.org>
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This makes further steps to generate the correct HTML. Some tests now
have more appropriate HTML, but are not fully passing yet as they
require more fixes. I also missed the fact that there is actually an
algorithm to set the tag name, which I thought didn't exist. Therefore,
also correctly implement that.
Part of #25005
Testing: WPT
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Previously, when the `Document` element was removed, no further display
list updates would be sent to paint. This change makes it so that when
the `Document` element is removed a single new empty display list is
sent.
Testing: This change adds a new WPT test .
Fixes: #44101
---------
Signed-off-by: Rover track <rishan.pgowda@gmail.com>
Previously absolutely positioned direct children of a CSS Grid had their
position (relative to their parent) hardcoded to (0, 0). This PR changes
that to correctly propagate the position computed by Taffy.
Testing: WPT tests.
---------
Signed-off-by: Nico Burns <nico@nicoburns.com>
Instead of walking the entire fragment tree to find nodes for which
animations and image animations need to be cancelled, this change moves
that logic to `script`. Now, for each animating node the animation
managers will explicitly ask `layout` if the node is being rendered (or
delegating rendering in the case of CSS animations and transitions).
The main goal here is a performance improvement, elimating roughly 1% of
layout time from the profiler when running the
`flexbox-deeply-nested-column-flow.html` test case. This will almost
certainly be an even better improvement on more complex pages as we are
no longer doing things once per fragment tree entry, but once per
animating node.
There is also a subtle behavior improvement here. Before nodes with
`display: contents` had their animations canceled, but now they are not.
For instance, this test case now works properly:
```html
<!DOCTYPE html>
<style>
@keyframes anim {
from { color: cyan }
to { color: magenta }
}
div {
display: contents;
animation: anim 1s infinite alternate linear;
}
</style>
```
The new layout query will additionally be useful for other parts of
script that need to answer the same "being rendered" or "delegates
rendering to children" question.
Testing: This change adds a new test and gets one more subtest passing.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
The generated HTML was setting `text-decoration-line` whereas it instead
should set `text-decoration`.
Part of #25005
Testing: WPT
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Add definition for generation of custom fields for interfaces inheriting
from PerformanceEntry.
Testing: More WPT Tests Passed
---------
Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
Rather than node, we should check `new_parent` for this. Unfortunately
some regressions, which have been flip-flopping in recent PRs. That's
because underline itself uses its own state to determine what to do.
However, this is a net positive PR that also adheres to the spec, so
it's another step in the right direction.
Part of #25005
Testing: WPT
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
First of all, the effective command value was wrong, since there is no
relevant CSS property for the underline command. Instead, we should
directly use the text-decoration property. This then allows us to
implement reordering of modifiable elements.
We also need to "change the element to a span", which is quite annoying
to do. Instead, it mimics what would have happened by moving children
and copying attributes.
There are some regressions, but overall this is another big step towards
the right track. The regressions look related to tricky edge cases that
I am not even sure other browsers handle.
Part of #25005
Testing: WPT
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This file was renamed incorrectly due to automated renaming of directory
contents.
Testing: This does not seem to change test results, but whether or not
the
option in this `__dir__.ini` file is another issue.
Signed-off-by: Martin Robinson <mrobinson@fastmail.fm>
Co-authored-by: Martin Robinson <mrobinson@fastmail.fm>
tex-3d-size-limit.html currently crashes because we don't check that the
input data is large enough, and happily access memory that's not ours if
it's not.
The referenced ticket comes from the fact that we don't systematically
detect a crash (which makes sense if we're (un)lucky), and this patch
eradicates the crash altogether by checking the input buffer size. The
size computation is a (partial) port of WPT's computeImageSizes3D JS
function.
Fixes: https://github.com/servo/servo/issues/42881
Testing: Some expected failures in wpt/webgl can be removed, including a
crash.
Signed-off-by: Simon Martin <simon@nasilyan.com>
Instead of just clearing layout data, also clear style data from
descendants that are now no longer part of the flat tree when attaching
shadow DOM. This ensures that Stylo does not try to process them during
restyling. This matches what Gecko does.
Testing: This change adds a crash test and also causes a few subtests
to start passing.
Fixes: #40731.
Signed-off-by: Martin Robinson <mrobinson@fastmail.fm>
Co-authored-by: Martin Robinson <mrobinson@fastmail.fm>
Add a cache for `SameFormattingContextBlock`s: A new kind of cache
is added which allows reusing fragments for
`SameFormattingContextBlock` (the majority of block level elements).
This can reduce the amount of fragment tree construction during
incremental layout (although with a 40 byte overhead per
`SameFormattingContextBlock`).
Testing: This change adds a new Servo-specific WPT test that verifies
that
the minimal number of `Fragment`s are rebuilt after an incremental
layout.
Previously, when running `flexbox-deeply-nested-column-flow.html` from
`tests/blink_perf_tests/perf_tests/layout/`, performance would degrade
with successive test runs. This is due to how slow inline layout is.
This change
removes that progressive degradation, though we may be able to remove
this cache with improvements to inline layout.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Initialize Sanitizer API implementation with partially implemented
constructor and `get()` methods of the `Sanitizer` interface, which
allows the sub-sequential implementation to be tested by WPT.
The `Sanitizer` interface is hidden behind the feature flag
`dom_sanitizer_enabled`, which is disabled by default.
Specification: https://wicg.github.io/sanitizer-api/
Testing: Enable WPT tests for Sanitizer API.
Fixes: Part of #43948
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Depends on #42251 for the overflow query.
Use containing block queries to implement the iteration of step [3.2.7.
Compute the Intersection of a Target Element and the
Root](https://w3c.github.io/IntersectionObserver/#compute-the-intersection)
within `IntersectionObserver` algorithm.
Contrary to the algorithm in the spec that maps the coordinate space of
the element for each iteration, we uses bounding client rect queries to
get the appropriate clip rect. And, to handle the mapping between
different coordinate spaces of iframes, we use a simple translation.
Due to the platform limitation, currently it would only handle the same
`ScriptThread` browsing context. Therefore innaccuracy any usage with
cross origin iframes is expected.
Testing: Existing and new WPTs.
Part of: https://github.com/servo/servo/issues/35767
Co-authored-by: Josh Matthews
[josh@joshmatthews.net](josh@joshmatthews.net)
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This is a speculative fix for #40543. Although I could not get this test
to flake locally, it is obviously wrong to assumee that web fonts (Ahem
in this case) is loaded at the time of `window.onload`. This change
makes all the tests Promise tests and has them await
`document.fonts.ready` before running. This should fix the
intermittency.
Testing: This should fix itnermittency as seen on the CI.
Fixes: #40543.
Signed-off-by: Martin Robinson <mrobinson@fastmail.fm>
Co-authored-by: Martin Robinson <mrobinson@fastmail.fm>
This is a speculative fix for #39668. Although I could not get this test
to flake locally, it is obviously wrong to assumee that web fonts (Ahem
in this case) is loaded at the time of `window.onload`. This change
makes all the tests Promise tests and has them await
`document.fonts.ready` before running. This should fix the
intermittency.
Testing: This should fix intermittency as seen on the CI.
Fixes: #39668
Signed-off-by: Martin Robinson <mrobinson@fastmail.fm>
Co-authored-by: Martin Robinson <mrobinson@fastmail.fm>
This is a very minor, but annoying bit of technical debt that we have
carried for over a decade. Many of the Servo-specific WPT-style tests
had names that didn't match the naming convention used in WPT. In some
cases tests and references were named `test_a.html` for the test and
`test_b.html` for the reference. To make things more confusing,
sometimes two tests in a series were named `test_a.html`, `test_b.html`
and `test_ref.html` for the reference.
This change makes it so that tests are named consistenty and with
hyphens which are more common in WPT:
- `test-001.html`
- `test-002.html`
- `test-ref.html`
Testing: This shouldn't change results, as this just renames the test
files.
Fixes#2463.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This tests a feature (`about:sslfail`) that was removed in #14360 and
has been flaky for years. At this point, the test has been flaking for a
decade longer after the original feature existed! We can just go ahead
and remove it I think.
Testing: This change just removes a test, so doesn't need new tests.
Fixes: #10760
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
For any generic command, the spec doesn't specify how to determine
whether its state is set. In the case of underline, it at least means
that it has an effective command value that is set (to underline in this
case).
Also implements "simple modifiable" elements, since the relevant tests
depend on that for correctness.
Lastly, also rewrite `JSContext` to use imports.
Part of #25005
Testing: WPT
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Judging by the expected result in the test, the situation described in
the bug is no longer the case.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Testing: This updates test results.
Closes: #25802.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This change converts a collection of old Servo-specific crash tests into
WPT style crash tests, which are supported directly by the WPT test
harness. The main change here is the addition of `-crash.html` to the
end
of the test name (this is how the harness detects crash tests) and the
removal of `testharness.js` from the tests. This is a preparation for
#44232.
Testing: This change just changes the tests, so should be tested by the
test run.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>