Reviewable per commit. First commit adds `&mut JSContext` to
`call_default_constructor`. Second commit adds `&mut JSContext` to
Interface, which in unfortunately required many changes (a lot of
passing `&mut JSContext` down).
Testing: Just a refactor, but should be covered by WPT
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Refactors the `CookieStore` to use a separate `DroppableCookieStore`
struct for handling the drop logic.
Testing: No tests added
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
This change is reviewable per commits:
In first commit we added `&mut JSContext` to `run_box` (it is very hard
to bring `&mut JSContext` to `remove_script_and_layout_blocker`).
In second commit we pass `&mut JSContext` to `run_once`.
In third commit we added support for accepting `&mut JSContext` in
closures of `task!` macro and lastly we demo new macro invocations (to
ensure they actually compile)
Testing: Just refactor, but should be covered by WPT
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Refactors the WebGLRenderingContext to manage resource cleanup via a
dedicated `DroppableWebGLRenderingContext` struct.
Testing: This task is only a refactor, no tests added
Fixes: partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
With keep-alive requests implemented, this feature is now fully working.
Some tests still fail on
header parsing, which is #36801Fixes#38302
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Changed most #[allow]s to #[expect]s, mainly for
clippy::too_many_arguments
Removed unfulfilled expectations
This is my first opensource contribution, so please let me know if
anything should
be done differently.
Testing: Refactor
Part of: #40838
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: TimurBora <timurborisov5561@gmail.com>
Co-authored-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Replace `allow` with `expect` lints for `unused`, `unsafe_code`,
`dead_code`, and `non_upper_case_globals`.
Testing: So far just check it compiled on `x86_64-linux` on NixOS. Need
to use the module `system.fontconfig.enable = true;` I think in my NixOS
config.
Part of: #40383
Searching `allow\(.*\)` for `.rs` files shows the following. for
(total_results:total_files) went from `707:386` to `675:368`, a
reduction of `32:18`.
How many files is too many files per PR? I feel like the 20-30 I have is
too big.
---------
Signed-off-by: Wayne Van Son <waynevanson@gmail.com>
At the start of the script we create first (and only[^1]) safe
`JSContext`, from where we should pass it down to every code that needs
the cx. This PR brings it all the way down to message handlers. There is
clear separation between functions that use new model `&mut JSContext`
and the ones that use the old model (usually they take can_gc).
[^1]: Another place of construction are SM hooks (that pass us down raw
JSContext), but to reach that point we already needed to call another
function that takes `&mut JSContext`, so one can look at this case as
reentering/reborrowing (we derive new shorter `&mut JSContext` from the
old one).
Testing: This is just refactor, but should covered by WPT tests.
Part of #40600
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Start adding ML-KEM support to WebCrypto API.
Specification: https://wicg.github.io/webcrypto-modern-algos/#ml-kem
This patch implements import key operation of ML-KEM, with `ml-kem`
crate.
Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #41473
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This PR adds support for using new JSContext/CurrentRealm to promise and
adds some more helpers that will ease migration to new context model.
Second commit has another demo.
Testing: Covered by WPT
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This moves the Unicode offset types to the `base` crate and makes them
generally more usable throughout the Servo codebase. In addition, they
are renamed to use Rust naming and to be a bit more consistent:
- `UTF8Bytes` -> `Utf8CodeUnitLength`
- `UTF16CodeUnits` -> `Utf16CodeUnitLength`
There is also a bit more documentation explaining their use.
This is preparation for fixing issues with UTF-16 offsets in editable
text fields.
Testing: This does not change behavior so existing WPT tests should
suffice.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
`malloc_size_of` depends on `tendril` having the `encoding_rs` feature
turned on, but this was only turned on transitively via `html5ever` and
`script`/ `script_bindings` `tendril` dependencies. This change makes it
so that `malloc_size_of` depends directly on `tendril` and moves this
dependency to the root `Cargo.toml`.
Testing: This just fixes a particular build configuration.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Moves the concept of databases closer to the 3.0 spec, by implementing
the delete functionality, and the method returning current databases to
script.
Testing: WPT tests with new passes
Fixes: The "Implement databases deletion and `databases`" item of
https://github.com/servo/servo/issues/40983
---------
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Add placeholder implementation of DOM `VisualViewport` according to the
spec https://drafts.csswg.org/cssom-view/#visualviewport. This is the
first step of implementing the interface and syncing it with the
`PinchZoom` struct that we had in the `Embedder`.
Since this interface's is not accurate and couldn't fulfill it's
purpose, it would be gated behind a preference
`dom_visual_viewport_enabled` and would be open after the interface had
been integrated with `PinchZoom`, viewport resizing, and viewport
scroll.
Testing: Existing WPT Test.
Part of: #41341
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Put the Gamepad API and its supporting infrastructure behind a `gamepad`
feature flag. This allows embedders to opt-out of gamepad support at
compile time to save on binary size and reduce dependencies.
Testing:
1. `./mach build -d` (Gamepad enabled by default)
2. `cargo build -p servoshell --no-default-features --features
"libservo/clipboard,js_jit,max_log_level,webgpu"` (Gamepad Disabled)
3. `cargo build -p servoshell --features "gamepad,webxr,..."` (Gamepad &
WebXR Enabled)
Fixes: #40897
Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
This method now allows you to pass in a custom registry. The registry
isn't used yet for callers, since we don't support scoped registries.
However, as we now pass in the registry to `Node::clone`, we set the
registry when creating elements and cloning them.
As such, various tests start passing where we set the registry. Some
tests started failing, but they rely on scoped registries which we don't
support yet. These tests thus flipped: those that were erroneously
failing are now passing and vice versa.
Part of #34319
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This implements the required plumbing for the keep-alive flag on
requests. The flag already exists on the request object, but now also
exists on the builder itself.
The flag is then passed into a canceller. While we could make canceller
optional, in many cases it isn't and would require a whole lot more
changes. To follow the spec more closely, opted to put the keep_alive
flag on the canceller as well.
Note that this doesn't pass any extra fetch-later tests since we are not
correctly unloading iframe documents. That will be fixed in a follow-up
PR.
Part of #41230
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This changes updates to the latest version of stylo which includes
vendor-prefixed properties such as `-moz-transform` and
`-webkit-transform`. This allows more web content to render properly.
Note: Unitless perspective is not supported as part of this yet, but
will be once https://phabricator.services.mozilla.com/D274128 is part
of our downstream version of Stylo.
Testing: There are tests for this change.
Fixes: #17635.
Fixes: #14941.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Finish adding RSA-OAEP support to WebCrypto API, by implementing the
encrypt and decrypt operations of RSA-OAEP.
Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #41113
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Finish adding RSA-PSS support to WebCrypto API, by implementing the sign
and verify operations of RSA-PSS.
Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #41113
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This patch implements generate key operations of three RSA algorithms
(RSASSA-PKCS1-v1_5, RSA-OAEP, RSA-OAEP), with `rsa` crate.
The three operations are very similar to each other, so we can implement
them as a single function, located at the sub-module `rsa_common`,
shared among the three RSA algorithms. The enum `RsaAlgorithm` is used
differentiate the behavior of a few steps (Step 1, 5, 13 and 18) that
are slightly different among the three RSA algorithms.
Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #41113
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
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>
Start adding RSA-PSS support to WebCrypto API.
This patch implements import key operation of RSA-PSS, with `rsa` crate.
Testing:
- Pass some WPT tests that were expected to fail.
- Some new FAIL expectations are added. They were skipped by WPT when
the import key operation of RSA-PSS had not been implemented, and
requires other not-yet-implemented operations to pass.
Fixes: #34362, and part of #41113
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
The handwritten Drop implementation was removed in #37622, so we can now
remove the exception for it.
Testing: Compile-time generated code can't be meaningfully tested.
Fixes: part of #26488
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Changed some allow to expects and removed the unfulfilled expectations.
Testing: Refactor
Part of: #40383
Signed-off-by: anonmiraj <nabilmalek48@gmail.com>
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix#35678
<!-- Either: -->
All stream tee tests are passing now.
<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->
<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
Finish adding ChaCha20-Poly1305 support to WebCrypto API.
This patch implements encrypt operation and decrypt operation of
ChaCha20-Poly1305, using the crate `chacha20poly1305` to support the
cryptographic calculation. The get key length operation of
ChaCha20-Poly1305 is also included in this patch.
Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #40687
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Finish adding Argon2 support to WebCrypto API, using the crate `argon2`
to support the cryptographic calculation.
This patch implements "derive bits" operation and the "get key length"
operation of Argon2. Actual error messages are also provided for the
existing "import key" operation of Argon2.
Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #40687
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
The specification of Modern Algorithms in the Web Cryptography API
(https://wicg.github.io/webcrypto-modern-algos/) adds new key formats
and key usages to support modern cryptographic algorithms.
This patch adds those new key formats and key usages, preparing for the
implementation of the new algorithms.
Testing: No behavioral changes in existing cryptographic algorithms.
Existing tests suffice.
Fixes: Part of #40687
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This implements the solution from #26488 that prevents implementing Drop
manually for DOM interfaces, which is very easy to write in a way that
can cause memory safety errors during JS runtime teardown. Since we have
a bunch of pre-existing implementations that we are working on removing,
this PR adds an opt-out mechanism that those interfaces use.
Testing: Compile-time code generation; not possible to test.
Fixes: part of #26488
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
The media session is allowed to control the state of the media element
(play, pause) and is holding DOM reference, so the latest registered
media element is not be able to be GCed, so let's use the weak reference
to break this dependency.
Note that `weakReference` property was added to interfaces
- HTMLMediaElement: The `Mutable/WeakRef` requires T to be bound by
`WeakReferenceable`
- HTMLAudio/VideoElement: The `DOM_WEAK_SLOT` must be reserved by
concrete DOM JS class
Testing: No expected testing results changes
The media session UI functionality is implemented for Android and didn't
test due lack of testing sample.
Fixes: https://github.com/servo/servo/issues/40854
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
script: add CanGc as argument to methods in HTMLOptionElement
Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
Implement brotli support for CompressionStream and DecompressionStream
Testing: brotli test should pass
Fixes: #40831
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
The MediaSession `setPositionState` method should only update the
position state and propagate it to the platform media session UI
controller and shouldn't change somehow the properties of the media
element directly (duration, playback rate or position).
See
https://w3c.github.io/mediasession/#dom-mediasession-setpositionstate
Testing: Improvements in the following tests
- /mediasession/positionstate.html
The media session UI functionality is implemented for Android and didn't
test due lack of testing sample.
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Add CommandEvent
This is behind the new dom_command_invokers_enabled pref.
Testing: Existing WPTs
---------
Signed-off-by: Luke Warlow <lwarlow@igalia.com>