Commit graph

12018 commits

Author SHA1 Message Date
Martin Robinson
55d094a871
script: Make stylesheets loaded via <link> elements block the rendering (#39536)
Stylesheets loaded via the `<link>` element should block the rendering
of the page according to the HTML specification [1]. This change makes
it so that they do this and, in addition, we do not take reftest
screenshots until all no element is blocking the rendering.

This change does not add support for the `blocking` attribute of
`<link>`, but that can be added in a follow change. In addition to
fixing a few tests, this change likely makes other tests no longer
intermittent. We will need to watch CI runs after this lands in order to
verify that though.

Testing: This change fixes at least two WPT tests.
Fixes: #26424.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-27 13:32:26 +00:00
Martin Robinson
5f5f2abc0f
script: Rename StylesheetLoader to ElementStylesheetLoader (#39537)
`StylesheetLoader` implements the `StylesheetLoader` trait from Stylo.
This is pretty confusing as the names are the same. This change renames
the Servo version to `ElementStyleSheet` loader so that it's clearer
from reading the code what each of these things are.

Testing: This change just makes a few renames so shouldn't change test
results.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-27 13:04:46 +00:00
Tim van der Lippe
4c25039d35
Fully implement request constructor body handling (#39514)
This aligns the implementation with the spec, where both input body and
init body are now set. In doing so, it fixes a fetch abort test, since
the stream was missing for the input body.

It also introduces the `unusable` method, as that's the one the spec
uses. The other two getters no longer exist in the spec.

Fixes #39448

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-27 01:52:01 +00:00
Narfinger
18a1da0d80
Script: Remove last instances of Deref<str> and DerefMut<str> used for DOMString (#39504)
This removes the last instances of Deref<str> and DerefMut<str> used for
DOMString.
The goal is outlined in https://github.com/servo/servo/issues/39479.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: Compilation is the test as it just changes function names
essentially.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-27 01:48:24 +00:00
Oriol Brufau
89293995f0
script: Chain up scrollIntoView() scrolling to parent <iframe>s (#39475)
Calling `scrollIntoView()` on an element within an `<iframe>` will now
scroll scrolling boxes from the parent document(s), as long as they have
the same origin.

Testing: One existing subtest passes, and adding a new test.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-26 22:12:37 +00:00
Tim van der Lippe
b38bf3e606
Avoid crash when non-trusted-script object is passed into Function constructor (#39451)
It is possible to pass in objects that are not trusted scripts into the
Function constructor. Rather than crashing, we now treat these as
untrusted. `can_compile_string_with_trusted_type` doesn't need to know
the contents of a string, as it always marks it as untrusted.

We can make the same optimization in the string case, where we no longer
need to convert the string.

Testing: This change adds a WPT crash test.
Fixes #39436

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-26 18:33:56 +00:00
Tim van der Lippe
0ed853102a
Move Request constructor to impl (#39490)
Doing so allows us to change the type of `init` to take a deref, so that
we can also call it when
implementing `FetchLater` which takes a
`RootedTraceableBox<DeferredRequestInit>`

For more information, see this Zulip thread:

https://servo.zulipchat.com/#narrow/channel/263398-general/topic/How.20to.20upcast.20.60RootedTraceableBox.3CDeferredRequestInit.3E.60/with/540672042

Part of #39448

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-25 19:30:58 +00:00
Narfinger
a4c8ffe753
Script: Change script/dom/{bluetooth,canvas,html} to not rely on Deref<str> for DOMString (#39480)
This is part of the future work of implementing LazyDOMString as
outlined in https://github.com/servo/servo/issues/39479.

We use str() method or direct implementations on DOMString for these
methods. We also change some types.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>


Testing: This is essentially just renaming a method and a type and
should not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-25 15:53:21 +00:00
Narfinger
1e471b9b41
Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481)
This is part of the future work of implementing LazyDOMString as
outlined in issue #39479.

We use str() method or direct implementations on DOMString for these
methods. We also change some types.
This is independent of https://github.com/servo/servo/pull/39480

Signed-off-by: Narfinger Narfinger@users.noreply.github.com

Testing: This is essentially just renaming a method and a type and
should not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-25 12:27:42 +00:00
Rodion Borovyk
9713bb9e1b
script: Add message to NotFoundError (#39394)
Adding an optional message to be attached to a NotFoundError.

Testing: Just a refactor
Part of #39053

---------

Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2025-09-25 12:16:50 +00:00
Martin Robinson
ffdb7d3663
script: Chain up keyboard scrolling to parent <iframe>s (#39469)
When an `<iframe>` cannot scroll because the size of the frame is
greater than or
equal to the size of page contents, chain up the keyboard scroll
operation to the parent frame.

Testing: A new Servo-only WPT tests is added, though needs to be
manually
run with `--product servodriver`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-09-25 11:16:41 +00:00
Gae24
75e32ba5a4
script: implement ClipboardItem getType and supports (#39296)
Implement ClipboardItem's getType and supports

Testing: covered by existing tests

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-09-25 08:05:01 +00:00
Kingsley Yung
c15495b3e7
script: Refactoring of algorithm normalization in SubtleCrypto (#39431)
In our current implementation, we have multiple functions such as
`normalize_algoirthm_for_encrypt_or_decrypt` and
`normalize_algorithm_for_sign_or_verify` to normalize an algorithm, and
each of them works slightly differently. However, the spec defines a
single normalization procedure to handle all normalization.

This patch tries to consolidate our functions into a single
spec-compliant normalization function named `normalize_algorithm`.

The refactoring involves many existing code, so this patch only
introduces the new infrastructure without touching the existing. When
this patch gets approved and merged, we can then start migrating the
existing to the new infrastructure. (Note that SHA's digestion and
AES_CTR's encryption are also copied to the new infrastructure as
demonstration.)

More details about the refactoring can be found in the comment:
https://github.com/servo/servo/issues/39368#issuecomment-3316943206

Testing: The new code is not in used right now. No test is needed.
Fixes: Part of #39368

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-24 17:05:34 +00:00
Simon Wülker
2ccaf86ff6
Invalidate iterator over elements of a XPathResult when the document changes (#39411)
Also includes a fix to not throw a type error in
`XPathResult.invalidIteratorState`.

Testing: Includes a new web platform test
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-24 16:39:38 +00:00
Kingsley Yung
9d7b438d6b
script: Enable crypto task source at task manager (#39453)
The Web Cryptography API has the "crypto task source"
(https://w3c.github.io/webcrypto/#dfn-crypto-task-source-0) to queue
tasks to resolve or reject promises created in response to calls to
methods of `SubtleCrypto`.

This patch enables this task source at the script task manager, and
queue tasks on this task source from existing steps.

A few WPT error expectations are also added to WPT meta. The related
cryptographic algorithms have not yet implemented, so the errors are
expected. I don't know why WPT test did not capture them before.

Testing: Existing tests suffice.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-24 16:21:03 +00:00
Andrei Volykhin
f91dc33350
html: Add the reflected 'sizes' IDL attribute for <image> (#39466)
Add the reflected 'sizes' IDL attribute for <image> element's DOM
interface which defines image sizes for different page layouts.

See https://html.spec.whatwg.org/multipage/#dom-img-sizes

Testing: Improvements in the following tests
- custom-elements/reactions/customized-builtins/HTMLImageElement.html
- html/dom/idlharness.https.html
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-24 09:29:44 +00:00
Simon Wülker
72555de341
Never disconnect shadow roots from their hosts (#39459)
Regular shadow roots can never be detached once they are created.
However we were specifically detaching shadow roots from media elements
when they were disconnected. This is actually one of the very few
aspects of shadow roots that predate the implementation work I did
earlier this year.

I'm not sure why we ever did this. Maybe its for efficiency reasons,
because keeping the shadow tree around is not necessary when the media
element is not connected. But I can't imagine this yields any benefits,
especially since you would have to reconstruct the shadow tree when the
media element is re-connected (as is the case in the crash we observe).

For simplicities sake, I have completely removed this functionality.
Doing so ends up simplifying the code quite a bit.

Testing: This change adds a new crashtest
Fixes https://github.com/servo/servo/issues/36722

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-24 08:04:56 +00:00
Simon Wülker
206dcff080
Assert that style element has an owner in parse_own_css (#39458)
The existing `assert!(node.is_connected())` is wrong. What it *wants* to
assert is that the style element has an owner, which is either a
Document or a ShadowRoot that the element is a descendant of. However,
if the element is descendant of a ShadowRoot which is itself not
connected to a document then the assertion would fail.

Instead, we use `node.is_in_a_document_tree() ||
node.is_in_a_shadow_tree()`, which more accurately reflects the intent.

Testing: This change adds the test case from
https://github.com/servo/servo/issues/37781 as a crashtest
Fixes https://github.com/servo/servo/issues/39457
Fixes https://github.com/servo/servo/issues/37781

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-23 23:00:11 +00:00
Simon Wülker
dd8e4f231c
script: Remove dead code in xpath implementation (#39454)
Testing: Verified by the fact that the code still compiles, and existing
web platform tests of course
Part of https://github.com/servo/servo/issues/34527

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-23 21:58:17 +00:00
shuppy
ac8895c3ae
script: Move keyboard scrolling to script (#39371)
Instead of having every single embedder implement keyboard scrolling,
handle it in script in the default key event handler. This allows
properly targeting the scroll events to their scroll containers as well
as appropriately sizing "page up" and "page down" scroll deltas.

This change means that when you use the keyboard to scroll, the focused
or most recently clicked `<iframe>` or overflow scroll container is
scrolled, rather than the main frame.

In addition, when a particular scroll frame is larger than its content
in the axis of the scroll, the scrolling operation is chained to
the parent (as in other browsers). One exception is for `<iframe>`s,
which will be implemented in a followup change.

Testing: automated tests runnable locally with `mach test-wpt --product
servodriver`

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-23 20:35:08 +00:00
Andrei Volykhin
99fbd36b5d
html: Properly count <image>/<source> insertion/removal steps as the relevant mutations (#39452)
Follow the HTML specification and take into account that the HTML
`<image>/<source>` element inserting/removal steps should only be
counted as relevant mutations for `<image>` element if the parent of the
inclusive ancestor that was inserted/removed is the parent `<picture>`
element.

See <https://html.spec.whatwg.org/multipage/#relevant-mutations>.

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-23 12:40:03 +00:00
Martin Robinson
c63311af02
script: Remove absolute positioning workaround from scrollIntoView implementation (#39441)
This isn't needed as the border box query already takes into account the
containing block chain. Instead, consistently calculate the new
scroll position for a scroller relative to its current scroll offset.

In addition, fix a small bug where the border of a scroll container was
considered part of scrollport.

Testing: A new WPT test is added.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-09-23 10:10:00 +00:00
Ashwin Naren
f766b66a97
storage: Move shared functionality to base (#39419)
Part of #39418. See that PR for a full description.

Moves:
- `read_json_from_file`
- `write_json_to_file`
- `IpcSendResult`
- `IpcSend`

Renames:
- `CoreResourceThreadPool` to `ThreadPool` (shorter and more
descriptive, as we use it for more than the core resource thread now)

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-22 13:59:36 +00:00
Tim van der Lippe
02aab33987
Add AbortSignal support for event listeners (#39406)
Also fixes several issues with code generation when a dom type is part
of a dictionary.

Part of #34866
Fixes #39398

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-21 18:57:10 +00:00
Tim van der Lippe
7abc813fc3
Abort fetch controller when signal is aborted (#39374)
Does not all tests pass because of a mismatch in microtask timing. The
promises are resolved/rejected in the wrong order.

Part of #34866

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-21 12:33:03 +00:00
Simon Wülker
2c8533f38e
Parse qualified names with non-alpha characters in xpath (#39409)
The existing parsing rules are too strict and only allow alpha and
alphanumeric characters. Instead, we should follow the production
defined in https://www.w3.org/TR/REC-xml-names/#NT-NCName.

Testing: New tests start to pass
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-21 03:45:04 +00:00
Simon Wülker
bbceb0faa4
Allow whitespace around path expressions in xpath (#39410)
Previously servo would allow whitespace in between components of an
xpath expression, but not around it.

Testing: New web platform tests start to pass 
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-20 22:38:24 +00:00
Martin Robinson
629b7dba3d
script: Reduce code duplication in the implementation of scrollIntoView (#39407)
- Expose a couple helpers on `ScrollingBox` that will also be used for
  keyboard scrolling.
- Calculate `scrollIntoView` positions using points rather than doing
  things by axis components. This greatly reduces the amount of code in
  the implementation.

Testing: This is just a refactor so shouldn't change any tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-20 13:40:58 +00:00
Simon Wülker
bdf630563c
script: Don't try to evaluate xpath variable references (#39395)
Variables in xpath via the javascript bindings are a bit mysterious, as
there is no way that a variable can be specified. We currently panic
when encountering a variable, which is not good. Instead we now throw an
error.

We keep parsing the variables because the code is already there and it
seems realistic that their behaviour will be specified in the future.
I'm fine with removing them too if that is preferred.

Testing: This behaviour is unspecified and different browser produce
different results. There is no "correct" way to do this, but we should
not crash
Part of: https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-20 12:36:54 +00:00
Mukilan Thiyagarajan
e2241a93fe
script: switch to Element::create in HTMLSelectElement (#39390)
This file was missed in 07b2ff5d60
(#39325). See that commit for the motivation.

Testing: Covered by existing web platform tests.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-09-20 11:51:31 +00:00
Martin Robinson
715818cf73
script: Have HyperlinkElementTraits::update_href take a &ServoUrl (#39396)
This reduces code duplication in the callers.

Testing: This is a just a refactor, so no tests are needed.
Fixes: #11280.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-20 08:40:36 +00:00
Ashwin Naren
8a59c2cf56
Implement indexeddb array conversion (#38288)
Implement conversion from js arrays into rust.

Testing: WPT
Fixes: None

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-09-20 06:33:16 +00:00
Alex Touchet
5a0332f57e
Cargo.toml cleanup (#39403)
Cargo.toml cleanups. Mostly ordering fixes.

Testing: No tests for Cargo.toml edits.

---------

Signed-off-by: Alex Touchet <26315797+atouchet@users.noreply.github.com>
2025-09-20 03:09:37 +00:00
Oriol Brufau
994d767ae5
script: Return None for offsetParent on root <html> and all <body> elements (#39397)
We were returning null for all `<html>` elements, but now we will check
for the root element instead.

We were also returning null for "the body element", now we will return
null for all `<body>` elements even if they aren't "the body element".
This part diverges from the spec, but matches what all browsers do.
https://github.com/w3c/csswg-drafts/issues/12834

Testing: Adding new test
Fixes: #10521

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-19 19:38:12 +00:00
Andrei Volykhin
c017420ee7
html: Check the <source> MIME type on the source set updating (#39353)
Follow the HTML specification and check if the source element's MIME
type
('type' attribute) is supported while updating the source set of the
image element (step 5.8)
https://html.spec.whatwg.org/multipage/#update-the-source-set

Also add the missing descriptions for steps for the old and new methods:
- selecting an image source
- creating a source set from attributes
- updating the source set
- normalizing the source densities

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/update-the-source-set.html
- resource-timing/initiator-type/picture.html

Fixes: #36675

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-19 18:34:37 +00:00
Simon Wülker
84577c9fd4
script: Allow reusing results from xpath queries (#39392)
This behaviour is optional, but observable. Other browsers implement it,
so we should do it too.

Testing: There are no WPT tests for this, which is fair since the spec
explicitly states implementors may choose to not reuse the result.
Fixes: Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-19 17:19:04 +00:00
Ritoban Dutta
a5c584f72a
script: Replace DomRefCell<bool> with Cell<bool> for Response::redirected (#39351)
Replace DomRefCell<bool> with Cell<bool> for Response::redirected field.

Changed redirected field from DomRefCell<bool> to Cell<bool> and updated
all related methods:
- Struct field: redirected: DomRefCell<bool> → redirected: Cell<bool>
- Constructor: DomRefCell::new(false) → Cell::new(false)
- Getter method: *self.redirected.borrow() → self.redirected.get()
- Setter method: *self.redirected.borrow_mut() = value →
self.redirected.set(value)

Testing: As noted in the issue, compilation is sufficient for this
change.

Fixes: #39288

Signed-off-by: ritoban23 <ankudutt101@gmail.com>
2025-09-18 15:12:55 +00:00
Euclid Ye
af7de5ccf1
script: Avoid panic when scrolling area of window is larger than viewport (#39367)
Sometimes, the computed scrolling area of window is larger than
viewport. This causes panics in `Window.scroll` with `f32::clamp(0.0,
some negative number)`.

Eventually, we should find out why "computed scrolling area of window is
larger than viewport". But let's avoid the panics first.

Testing: This avoids panic, so definitely not covered by existing tests.
But it would be hard to write a automated test for this in headless
mode.
Fixes: #39346

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-18 07:51:53 +00:00
Euclid Ye
f508b1e5af
webdriver: Remove TODO comments of focusing steps (#39366)
Our current implementation already gets the "TODO" done for focusing
steps.


https://searchfox.org/firefox-main/source/dom/html/nsGenericHTMLElement.cpp#3491-3497

Testing: No. Just updating comments

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-18 06:54:49 +00:00
Jonathan Schwender
666b17a9a1
canvas: Port CanvasMsg channel to generic channel (#39348)
Additionally also improve the warning message if the routed receiver
disconnects and exit the thread.
If the routed receiver disconnects, we can't receive any canvas messages
anymore, and any control messages can't remedy that, so we might as well
exit.

Testing: Channel changes are covered by existing tests. Exiting the
canvas thread if the routed thread disconnects is not tested, and needs
reviewer attention.
Part of https://github.com/servo/servo/issues/38912

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-09-18 00:06:08 +00:00
Tim van der Lippe
6cba44e0e3
script: Do not start Fetch operations if they have been aborted by the AbortController (#39295)
The first step for aborting fetch calls. It only
has the case where the signal was already aborted
prior to fetch starting.

Part of #34866

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-17 08:49:27 +00:00
Euclid Ye
8c50c44942
script: Do not call "scroll into view" when handling element clicks (#39326)
Previously, when we click any element, it would trigger "scroll into
view". What's worse, for an anchor `<a>`, clicking it would "scroll into
view" instead of navigating to the url until you retry the click. The
reason is that we built `scrollIntoView` into the focus transaction
system with default option. However, the default `preventScroll` for
`FocusOption` is false according to spec, which triggers "scroll into
view" by default with focus triggered by interaction.

This PR
1. Adds spec document for those which really expects "scroll into view",
i.e. `<form>` when validating data.
2. Make sure when we begin focus transaction, we prevent "scroll into
view".
3. `Focus` method of element/document stays unchanged, which by default
scroll into view if no parameter provided according to spec.


Testing: Manually tested on `servo.org` and other websites, and examples
with `<form>` still correctly scroll into view when validation fails.
Fixes: #38616

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-17 02:23:14 +00:00
Tim van der Lippe
22fbb3458b
Add signal to request (#39290)
The signal taken from the requestinit is now passed into
the request object with the relevant steps. I added all
spec comments to this method, as I had trouble figuring
out which steps I had to add.

This required implementing the algorithm to create
dependent signals, which is used in the `any()` method.
So that's now implemented as well.

All of that required the machinery to have dependent and
source signals on an AbortSignal. It uses an IndexSet
as the spec requires it to be an ordered set.

Part of #34866

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-16 20:41:12 +00:00
Simon Wülker
1898a740a8
script: Use xpath ns resolver to resolve namespace prefixes (#39321)
The xpath resolver is a function provided by the user to resolve
namespace prefixes. Previously, we were ignoring the argument.

Testing: New web platform tests start to pass
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-16 17:25:45 +00:00
Kingsley Yung
f3d5617349
script: Check whether the generated crypto key has empty usages (#39328)
The WebCryptoAPI spec requires that when we generate crypto keys by the
generateKey method of SubtleCrypto interface we have to check whether
the usages is empty. If the usages is empty, throw a SyntaxError.

FYI, Step 9 of
https://w3c.github.io/webcrypto/#SubtleCrypto-method-generateKey

We have not yet implemented this logic, and this patch implements it.

Testing: Pass WPT tests that were expected to fail.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-16 17:23:42 +00:00
Kingsley Yung
64115c6197
script: Remove redundant step in UnwrapKey method of SubtleCrypto (#39323)
In Step 15, we are given the unwrapped key as bytes. If the format is
"jwk", we execute parse-a-JWK algorithm to parse it (and deserialize it
to a JsonWebKey dictionary).

In next step, we perform the import key operation on the unwrapped key.
In our current implementation, we serialize the JsonWebKey dictionary
(when format is "jwk") back to bytes, in order to perform the import key
operation.

In fact, this serialization step is redundant since we have already been
given the unwrapped key as bytes in Step 15. We can directly use it for
perform the import key operation. This patch remove this redundant step
of re-serializing the JsonWebKey dictionary.

Testing: Refactoring only. No change in tests.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-16 15:23:36 +00:00
Mukilan Thiyagarajan
07b2ff5d60
script: use Element::create instead of DOM struct constructors (#39325)
Creating elements by directly calling their interface constructors leads
to some state not being intialized correctly (see #39285). It is also
not in line with the specifications as many of them refer to the
[`create an element`][1] algorithm when an element needs to be created,
which directly maps to `Element::create` in the script crate.

So, switch all such places where elements are created by script to use
`Element::create`.

[1]: https://dom.spec.whatwg.org/#concept-create-element

Testing: Existing WPT tests.

Fixes: #39285

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-09-16 09:26:42 +00:00
Narfinger
22dcc8a49d
Get the Rc to the custom_reaction_stack outside the loop instead of using the thread_local inside. (#39310)
This uses the ScriptThread::custom_element_reaction_stack to call the
enqueue_callback_reaction on the Rc instead of in the loop.
Potentially saving access to thread_local variables.


Testing: Should not change functionality and should be covered by wpt
tests.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-16 01:51:13 +00:00
Andrei Volykhin
8c3acaaec9
html: Validate descriptors tokens on 'srcset' attribute parsing (#39317)
Follow the specification and validate tokens of the "x/w/h" descriptors
before applying the rules for parsing float-pointing numbers or
non-negative integers.
https://html.spec.whatwg.org/multipage/#parsing-a-srcset-attribute (step
13)

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-15 17:34:56 +00:00
Jo Steven Novaryo
b1ab72e589
Set composed flag for TouchEvent (#39138)
Following the definition of `TouchEvent` in
https://w3c.github.io/touch-events/#list-of-touchevent-types, all
`TouchEvent` should have its `composed` flag set to be able to propagate
past a shadow root layer.

Part of #35997
Testing: Would require a testdriver.

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
2025-09-15 08:50:16 +00:00