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>
dblclick on text inputs was being dispatched to an internal element used
for the input, not to the <input> itself. As a result, page scripts
listening for dblclick on the input never received the event.
Testing: tested manually.
Fixes: #41303
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
All the new nodes will be `adopt`-ed inside the respective calls to
`Node::insert` anyways.
Testing: Hopefully no regressions?
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
I added error handling for handle_open_db but I also added it to
SqliteEngine::new and handle_sync_operation because we also open db
there, so I am not sure about these two.
part of #40983
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
Route console messages through the embedding API instead of printing
directly, giving embedders control over console output handling.
Testing: Should be covered by exsisting tests
Fixes: #41145
Signed-off-by: atbrakhi <atbrakhi@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>
Fix hashchange only queue when fragment actually changes
Testing: tested it manually for now.
Fixes: #41304
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
This is the first part of preparation for implementing the keepalive
flag for requests. It requires implementation of the concept of a task
group, which we already sort of have with `DocumentLoader`. Therefore,
we currently already cancel any loads, which should be updated to
ignored kept-alive requests.
However, termination also requires storing of deferred fetches, which
are also kept-alive. Therefore, to distinguish the two, we need to store
them separately as stated with the TODO.
In a follow-up, we can then skip canceling keep-alive requests for both
`navigator.sendBeacon` (which aren't deferred) and `fetchLater` (which
are deferred).
Part of #41230
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
add error messages for `encrypt_aes_ctr`, `encrypt_aes_cbc`, and
`decrypt_aes_cbc`
Related issue: #40756
For some of the messages I just used the `fmt::Display` of `UnpadError`,
but maybe these messages should be more specific?
---------
Signed-off-by: César Pedraza <cpedraza@unal.edu.co>
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>
Finish adding RSASSA-PKCS1-v1_5 support to WebCrypto API, by
implementing the sign and verify operations of RSASSA-PKCS1-v1_5.
Testing: Pass some WPT tests that were expected to fail.
Fixes: Part of #41113
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
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>
The import and export key operations of RSA algorithms have been
implemented. We actually don't need some helper functions for
RsaOtherPrimesInfo in JsonWebKey, for those operations. This patch
removes those unused helper functions.
Testing: Existing tests suffices.
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This PR fixes an issue where the Shadow DOM roots were incorrectly
identified as the document roots in scroll and dimension calculations.
The previous check `*self.root_element() == *self` returned true for
shadow roots which caused `scrollTop`, `scrollLeft`, `clientWidth` to
return viewport dimensions instead of actual dimensions. The previous
check was replaced with the already existing
`self.is_document_element()` to check for actual roots.
Testing:
- This causes `shadow-dom/scroll-restore-shadow.html` to start passing.
- It was also locally tested on the tests given by @rayguo17 (
[clientWidth
Test](https://github.com/servo/servo/issues/41002#issue-3684265503) and
[scrollTop
Test](https://github.com/servo/servo/issues/41002#issuecomment-3605214797)
)
Test results:
```
No build type specified so assuming `--dev`.
shadow_host_client_width: 300
shadow_root_element_client_width: 300
No build type specified so assuming `--dev`.
shadow host scrollTop: 0
shadow_root_element_scrollTop: 0
document root element scrollTop: 536
Button in shadow DOM clicked
```
Fixes: #41002
---------
Signed-off-by: zen-zap <pandaashutosh340@gmail.com>
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>
This patch implements export 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 a new sub-module `rsa_common`,
shared among the three RSA algorithms. An enum `RsaAlgorithm` is also
added to the sub-module `rsa_common`, in order to slightly differentiate
the behavior of the step (Step 3.4 of "jwk" format) that are different
among the three RSA algorithms.
Testing:
- Pass some WPT tests that were expected to fail.
- Some new FAIL expectations are added. They were skipped by WPT when
the export key operations of RSASSA-PKCS1-v1_5, RSA-PSS and RSA-OAEP had
not been implemented, and requires other not-yet-implemented operations
to pass.
Fixes: Part of #41113
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Start adding RSAS-OAEP support to WebCrypto API.
This patch implements import key operation of RSA-OAEP, 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-OAEP had not been implemented, and
requires other not-yet-implemented operations to pass.
Fixes: Part of #41113
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Co-authored-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Fixes the following warning:
```
warning[E0133]: call to unsafe function `js::jsapi::SetGCZeal` is unsafe and requires unsafe block
--> components/script/script_runtime.rs:1144:5
|
1144 | SetGCZeal(cx, level, frequency);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>
= note: consult the function's documentation for information on how to avoid undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
--> components/script/script_runtime.rs:1132:1
|
1132 | unsafe fn set_gc_zeal_options(cx: *mut RawJSContext) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(unsafe_op_in_unsafe_fn)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
```
Testing: Build-time only.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This change fixes a variety of build warnings on Android. In a related
change, the CA verifier preference allows using a list of certificate
overrides and the `rust-webpki` verifier regardless of platform. Whether
to use a list of certificate overrides and whether to use the platform
verifier are orthagonal, so this change unlinks those two and in the
process
fixes a build warning on Android.
Testing: This preference is untested (and quite hard to test honestly),
so this change
does not have tests. There should be no behavior change unless using a
combination
of forcing the webpki verifier and providing a list of CA overrides.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Fixes logging in to lichess.org, since our request body now matches what
other browsers send.
Testing: Newly passing WPT tests.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Use the algorithms introduced in #41109 in more places.
Follow more closely the spec when executing classic scripts, introducing
the concepts of rethrowing and muting errors.
Muting errors is not actually implemented, and will be done in a
followup.
Testing: More tests start passing
Fixes#34199Fixes#27260Fixes#15188
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
For a long time, the "Compositor" hasn't done any compositing. This is
handled by WebRender. In addition the "Compositor" does many other
tasks. This change renames `IOCompositor` to `Paint`.
`Paint` is Servo's paint subsystem and contains multiple `Painter`s.
This change does not rename the crate; that will be done in a
followup change.
Testing: This just renames types and updates comments, so no new tests
are necessary.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Start adding RSASSA-PKCS1-v1_5 support to WebCrypto API.
This patch implements import key operation of RSASSA-PKCS1-v1_5, 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 RSASSA-PKCS1-v1_5 had not been implemented,
and requires other not-yet-implemented operations to pass.
Fixes: Part of #41113
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Added new invocation struct `HTMLMediaElementEventHandler` that allows
to decouple ownership of the `HTMLMediaElement` from the IPC router
callback (break cyclic reference dependency) by replacing a `Trusted`
wrapper with more suitable `WeakRef`.
Note that `WeakRef` is not thread-safe and MUST be rooted and/or deleted
on the script thread.
Testing: Regressions in the following tests caused by overly aggressive
GC on document activity change to `Inactive` and will be follow up in
https://github.com/servo/servo/issues/41138
-
html/semantics/embedded-content/media-elements/autoplay-allowed-by-feature-policy.https.sub.html
-
html/semantics/embedded-content/media-elements/autoplay-default-feature-policy.https.sub.html
-
html/semantics/embedded-content/media-elements/autoplay-disabled-by-feature-policy.https.sub.html
Fixes: https://github.com/servo/servo/issues/40243
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This bug was closed a while ago, so we should also remove in in code
reference to it.
Testing: This just removes an out-of-date comment so no tests necessary.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
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>
This implements a GenericOneshot channel. The size in the crossbeam
channel is restricted while in the Ipc case we use the same
IpcChannel(for now).
We also use these channels in WebDriver to prove they work.
Testing: Unit Tests and compilation still works.
Fixes: https://github.com/servo/servo/issues/39019
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Switch the devtools part to GenericCallback and GenericSender.
To keep the diff small the names where not changes as a Sender almost
fills the same requirement as a callback.
Testing: As this is mostly type changes, the compilation is the test but
also devtools seem to work fine with these changes. ./mach try run is
here: https://github.com/Narfinger/servo/actions/runs/19931697694
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Small cleanup, avoid repeating some code, since in these cases we use
the defaults provided by `GlobalScope`
Testing: Covered by existing tests, no behaviour change.
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Changed some allow to expects and removed the unfulfilled expectations.
Testing: Refactor
Part of: #40383
Signed-off-by: anonmiraj <nabilmalek48@gmail.com>
It's important to check the media player's `paused` state to avoid
unnecessary changes to its internal state (via `play`, `pause`),
including configuration the `playback rate` and `volume` properties.
Depends on https://github.com/servo/media/pull/467
Testing: The expected test results are unchanged because it is the
implicit performance improvements of the media stack, with the exception
of the following test, which is affected by the `playback rate` state
caching mechanism (the `seek` position is not overridden for default
playback rate (1.0)).
- html/semantics/embedded-content/media-elements/preserves-pitch.html
See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
ServoLayoutElement::parent_element() method shouldn't cross shadow tree
boundary.
`inheritance_parent` uses `traversal_parent`
Testing:
`tests/wpt/meta/css/css-lists/counter-list-item-slot-order.html.ini`
`tests/wpt/meta/css/css-nesting/host-nesting-003.html.ini`
`tests/wpt/meta/css/selectors/is-where-shadow.html.ini`
and manual test in the below issue
The regression in
`tests/wpt/meta/html/rendering/the-details-element/details-blockification.html.ini`
has 1 more cause
https://github.com/servo/servo/pull/40977#issuecomment-3608471378
Fixes: [#40896](https://github.com/servo/servo/issues/40896)
cc: @xiaochengh
---------
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Moving IndexedDB to use the generic channel methods.
Of note is the change in 'IDBRequest::execute_async'. This method
previously added a channel that was constructed from the callsite in put
into the AsyncOperation. Now we do not take a function but take a
'FnOnce(GenericCallback<BackendResult<T>>) -> AsyncOperation'. With this
the callsite can construct the AsyncOperation to give in the
'IndexedDBThreadMsg::Async'.
The rest are mostly just type changes.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: WPT tests on the IndexedDB subset still pass.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
On Linux thread names are limited to 15 characters: that caused all the
script threads to be named 'ScriptScriptEve' and show up with the same
name in tooling.
That changes turns the name to 'Script#{script id}' instead.
Testing: No test coverage for that very internal detail.
Signed-off-by: webbeef <me@webbeef.org>
<!-- 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>
Error messages in the import/export key operations of ChaCha20-Poly1305
are missing. This patch adds those error messages.
Testing: No behavioral change. Existing tests suffice.
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>