This PR refactors parts of the net crate with one minor functional
change.
Most of the main functions in the net crate are quite long and rather
unwieldly. This PR tries to help make them more understandable.
- Split parts of obtain_response to have the Router callback setup in
another function.
- Move functions related to devtools into another file.
- Add some servo_tracing.
- http_network_or_cache_fetch has another function for append_cache_data
to headers.
- One functional change: previously in obtain_response, we used the
encoded_url via copies and multiple replace calls. We now use the
percent_encode crate which is already included in
content_security_policy to do this a bit more efficiently. In practice
the compiler probably fixed the multiple copies but this is more
straightforward. The output should be identical.
Testing: As this is mostly a refactor compilation is the test. The
percent_encode change is tested in multiple unit tests.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.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>
This is somehow introduced in #43617. This is causing CI failure.
For whatever reason, this thing should only be in `.git` folder. But
somehow it is at the root?
Also changed `.yml` to avoid ambiguity: we are using revision instead of
path.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This functionality already provided by `icu_properties` which is already
in our dependency graph, so this change allows us to remove one
dependency.
Testing: This should not change behavior, so is covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.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>
Integrate client storage into indexeddb for the creation and deletion of
databases.
Testing: Existing WPT tests.
Fixes: None
---------
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
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>
Bumps [mako](https://github.com/sqlalchemy/mako) from 1.2.2 to 1.3.11.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/sqlalchemy/mako/releases">mako's
releases</a>.</em></p>
<blockquote>
<h1>1.3.11</h1>
<p>Released: Tue Apr 14 2026</p>
<h2>bug</h2>
<ul>
<li>
<p><strong>[bug] [template]</strong> Fixed issue in
<code>TemplateLookup</code> where a URI with a double-slash
prefix (e.g. <code>//../../</code>) could bypass the directory traversal
check in
<code>Template</code>, allowing reads of arbitrary files outside of the
template directory. The issue was caused by an inconsistency in how
leading
slashes were stripped between <code>TemplateLookup.get_template()</code>
and
<code>Template</code> initialization.</p>
<p>References: <a
href="https://redirect.github.com/sqlalchemy/mako/issues/434">#434</a></p>
</li>
</ul>
<h1>1.3.10</h1>
<p>Released: Thu Apr 10 2025</p>
<h2>bug</h2>
<ul>
<li>
<p><strong>[bug] [lexer]</strong> Fix undefined variable errors when
<code>strict_undefined=True</code> when using a
nested list comprehension. Pull request courtesy Sébastien Granjoux.</p>
<p>References: <a
href="https://redirect.github.com/sqlalchemy/mako/issues/418">#418</a></p>
</li>
</ul>
<h1>1.3.9</h1>
<p>Released: Tue Feb 4 2025</p>
<h2>bug</h2>
<ul>
<li>
<p><strong>[bug] [tests]</strong> Fixed test suite to not rely upon
ancient "future division" statement to
test the <code>Template.future_imports</code> feature. The test is
replaced with one that tests only the rendering, not the ultimate
effect.</p>
<p>References: <a
href="https://redirect.github.com/sqlalchemy/mako/issues/408">#408</a></p>
</li>
</ul>
<h1>1.3.8</h1>
<p>Released: Sat Dec 7 2024</p>
<h2>bug</h2>
<ul>
<li><strong>[bug] [lexer]</strong> Reverted the fix for <a
href="https://redirect.github.com/sqlalchemy/mako/issues/140">#140</a>
released in Mako 1.3.7 as it produced
regressions in existing user code.</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/sqlalchemy/mako/commits">compare view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts page](https://github.com/servo/servo/network/alerts).
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [mako](https://github.com/sqlalchemy/mako) from 1.2.2 to 1.3.11.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/sqlalchemy/mako/releases">mako's
releases</a>.</em></p>
<blockquote>
<h1>1.3.11</h1>
<p>Released: Tue Apr 14 2026</p>
<h2>bug</h2>
<ul>
<li>
<p><strong>[bug] [template]</strong> Fixed issue in
<code>TemplateLookup</code> where a URI with a double-slash
prefix (e.g. <code>//../../</code>) could bypass the directory traversal
check in
<code>Template</code>, allowing reads of arbitrary files outside of the
template directory. The issue was caused by an inconsistency in how
leading
slashes were stripped between <code>TemplateLookup.get_template()</code>
and
<code>Template</code> initialization.</p>
<p>References: <a
href="https://redirect.github.com/sqlalchemy/mako/issues/434">#434</a></p>
</li>
</ul>
<h1>1.3.10</h1>
<p>Released: Thu Apr 10 2025</p>
<h2>bug</h2>
<ul>
<li>
<p><strong>[bug] [lexer]</strong> Fix undefined variable errors when
<code>strict_undefined=True</code> when using a
nested list comprehension. Pull request courtesy Sébastien Granjoux.</p>
<p>References: <a
href="https://redirect.github.com/sqlalchemy/mako/issues/418">#418</a></p>
</li>
</ul>
<h1>1.3.9</h1>
<p>Released: Tue Feb 4 2025</p>
<h2>bug</h2>
<ul>
<li>
<p><strong>[bug] [tests]</strong> Fixed test suite to not rely upon
ancient "future division" statement to
test the <code>Template.future_imports</code> feature. The test is
replaced with one that tests only the rendering, not the ultimate
effect.</p>
<p>References: <a
href="https://redirect.github.com/sqlalchemy/mako/issues/408">#408</a></p>
</li>
</ul>
<h1>1.3.8</h1>
<p>Released: Sat Dec 7 2024</p>
<h2>bug</h2>
<ul>
<li><strong>[bug] [lexer]</strong> Reverted the fix for <a
href="https://redirect.github.com/sqlalchemy/mako/issues/140">#140</a>
released in Mako 1.3.7 as it produced
regressions in existing user code.</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/sqlalchemy/mako/commits">compare view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts page](https://github.com/servo/servo/network/alerts).
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.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>
`servo-layout` only depends on `html5ever` for it's atom types which are
now split out into the `web_atoms` crate. This switches the dependency
to `web_atoms` to remove the unncessary dependency
Testing: This just imports the same types from a different crate. So if
it builds, it should work.
Signed-off-by: Nico Burns <nico@nicoburns.com>
Mostly reuses the original error message from #39051, but on the rest of
the methods that require it. Also adds a new error message for
`document_if_same_origin`.
Testing: None
Fixes: Partially #40756
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Since indexeddb is now part of the experimental features list, we can
remove it from the "more experimental" features list.
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Since https://github.com/servo/servo/pull/44182 production builds for
android are now possible in CI.
Let's unify this, since all other platforms already use production. The
production build is also ~45MB small, which is a huge reduction compared
to the ~159MB our nightly builds have. I didn't investigate further why
the difference is that large, but I installed the production version on
my phone and didn't spot any obvious issues (on servo.org).
[Mach try
android-production](https://github.com/jschwe/servo/actions/runs/24525178123)
Testing: We don't test CI workflows themselves.
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
No need to borrow `self.inline_styles.style` when the result is already
available as a parameter of the function.
Also, avoid calling `parent_style.get_font()` multiple times.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Pass the build directory to gradle via an environment variable, to
support custom profiles.
Building the custom profiles already works, but follow-up commands
expect the artifact at the location of the profile.
This allows switching the android release build to production (in a
follow-up PR).
Testing: We don't run any runtime tests for android in CI
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
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>
In CompressionStream API, the compression algorithms are provided by
`flate2::write::{DeflateEncoder, GzEncoder, ZlibEncoder}` and
`brotli::CompressorWriter`, and the decompression algorithms are
provided by `flate2::write::{DeflateDecoder, GzDecoder, ZlibDecoder}`
and `brotli::DecompressorWriter`.
Although all of them `std::io::Write`, they have subtle difference in
their workflow. For example, `DeflateEncoder`, `GzEncoder` and
`ZlibEncoder` are closed by `fn try_finish(&mut self)` or `fn
finish(self)`, while `brotli::CompressorWriter` must be closed by `fn
into_inner(self)`.
We currently directly call those methods from specification steps. This
patch move those method calls into new structs `CompressionContext` and
`DecompressorContext`, to provide an abstraction layer between
specification steps and underlying logics of compression algorithms from
external libraries. This helps to separate the subtle difference in
compression algorithms away from specification steps.
Testing: Refactoring. Covered by tests in `tests/wpt/tests/compression/`
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Fixed that `WebView::animating` takes `self` instead of `&self` as
argument.
Testing: Unsure how this could be tested for, beyond creating a unit
test for each individual function as a sanity check that all parameters
are correct. This seems excessive.
Fixes: #44251
Signed-off-by: Java <javaderg@pm.me>
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>
When laying out an absolutely positioned box, if the layout results are
taken from the cache, and the resulting fragment would have the same
size and position, then use the fragment from the previous layout
instead.
Testing: Not needed, there shouldn't be any observable behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
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 "JSContextify"s part of DocumentEventHandler, namely the actions
from `handle_pending_input_events`.
Additionally, we also switch the MouseEvent and KeyboardEvent. This does
not change yet PointerEvent and some other events used to keep the diff
reasonable.
Testing: This is part of the JSContextify work that is fundamental and
tested by WPT.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.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>
The code was doing repetitive work by checking if `compiled_script` is
null and then assigning and expecting the same, combined and replaced
with condition based working
Testing: The flow remains the same no new tests needed
Fixes: #44210
Signed-off-by: Rover track <rishan.pgowda@gmail.com>
This introduces a `ScriptToEmbedderChan` property on `LayoutThread`,
which is used to send accessibility updates directly to the embedder.
Follow-up to https://github.com/servo/servo/pull/42338.
Testing: Covered by existing tests.
Signed-off-by: Alice Boxhall <alice@igalia.com>