Implement the `getPublicKey` method of the `SubtleCrypto` interface.
This patch includes:
- Implementing the steps of the `getPublicKey` method.
- Adding the new "getPublicKey" operation to the internal object
`supportedAlgorithms`, for registering cryptographic algorithms that
support "getPublicKey" operation, and used by the `getPublicKey` method
to check whether the cryptographic algorithm supports "getPublicKey"
operation and perform the operation if it is supported.
- Implementing the "getPublicKey" operation of X25519 for demonstrating
and testing the functionality of the `getPublicKey` method.
Specification:
<https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-getPublicKey>
Testing: Pass WPT tests that were expected to fail.
Fixes: Part of #43072
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Moves the `Drop` logic for `GPURenderPipeline` into a dedicated helper
struct, `DroppableGPURenderPipeline`.
The associated `Bindings.conf` entry is
removed as direct `Drop` is no longer needed for this type.
Testing: WebGpu tests just cover its cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
The conversion of strings was wrong for `--foo` where it should become
`-Foo`. Instead, it was consuming both the `--` and then would encounter
a `f`.
This moves the relevant algorithms to DOMStringMap and adds
corresponding spec comments to explain what's going on.
This does make us closer to passing
`html/dom/elements/global-attributes/dataset-delete.html` but
unfortunately it still fails because of #12978
Prior to this fix, the value of `d.dataset['-foo']` wasn't undefined.
However, we now fail the assertion where the attribute should remain,
despite the call to delete.
That's because per `LegacyOverrideBuiltIns` we should be checking the
existence of which properties it can delete, before it actually deletes
the attribute. Right now, we do it regardless if it is a valid property
and thus we incorrectly delete the attribute.
Testing: No change in tests, since the test in question has more
assertions that require more fixes
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
This continues implementation of the delete command for
document.execCommand. Unfortunately, since these algorithms are vast
(30+ steps) and partial implementation leads to lots of issues, this PR
is "draw the rest of the owl".
I have tried to keep things manageable, by only implementing a couple of
extra steps in the delete command, so that we can focus on the "Delete
the selection" part.
To do that, several algorithms had to be implemented. Most of these
algorithms are required both by commands and by algorithms themselves,
which is why they are now exposed on a trait.
Additionally, all code now uses `cx`, to make sure it is up-to-date with
the ongoing migration and since some of the DOM API's it needs to call
already require `cx`.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Moves the `Drop` logic for `GPURenderPassEncoder` into a dedicated
helper struct, `DroppableGPURenderPassEncoder`. This ensures that DOM
types do not directly implement `Drop`, aligning with the policy for
resource management in the DOM. The associated `Bindings.conf` entry is
removed as direct `Drop` is no longer needed for this type.
Testing: WebGPU tests just cover its cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Bumps Stylo to https://github.com/servo/stylo/pull/314
In particular, we would now get a compile error because we were setting
`layout.flexbox.enabled` and `layout.css.transition-behavior.enabled`,
even if Stylo removed at some point. So stop setting them.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Moves the `Drop` logic for `GPURenderBundle` into a dedicated helper
struct, `DroppableGPURenderBundle`. This change ensures that
`GPURenderBundle` itself does not directly implement `Drop`, aligning
with the policy to prevent direct `Drop` implementations on DOM types.
Removes the `allowDropImpl` configuration for `GPURenderBundle` from
script bindings.
Testing: WebGPU tests cover all related cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Moves the `Drop` implementation for `GPUPipelineLayout` to a dedicated
private helper struct, `DroppableGPUPipelineLayout`. This ensures that
DOM types do not directly implement `Drop`, aligning with best practices
for resource management in the DOM. The associated `Bindings.conf` entry
is removed as direct `Drop` is no longer needed for this type.
Testing: WebGpu just coverages cases with proper tests
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
This is exposes the `tabIndex` property for `HTMLOrSVGElement` according
to the HTML specification. This is the first step toward implementation
of tab navigation in Servo.
Testing: This causes many WPT subtests to start passing, but causes a
few to
start failing. This is likely because we do not have a full
implementation of
the `delegatesFocus` parameter of `attachShadow` yet.
Fixes: This is part of #25001 and #32169.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Since `evaluate_js_on_global` called `enter_realm` and there were
already some callee that did it, I've actually passed `&mut
CurrentRealm`.
Also converted `Window::WebdriverException` to pass `&mut JSContext`
inside `javascript_error_info_from_error_info`.
Testing: A successful build is enough
Part of #40600
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Moves the `Drop` implementation for `GPUDevice` into a private
`DroppableGPUDevice` struct.
Also updates `Bindings.conf` to prevent the generation of `Drop`
implementations for `GPUDevice`.
Testing: WebGpu tests just cover the cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
This is part of replacing can_gc with the new &JSContext/&mut JSContext
method.
We modify CheckValidity and ReportValidity in various HTML Elements to
use the context instead of CanGc.
Testing: Compilation is the test as this is mostly mechanical.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
As mentioned in #40600 we will need this to properly handle &mut
JSContext (we cannot pass it to drop) and I think this wrappers are
preferred ways of doing this in rust as it is safe to forget (not call
drop) which is unsound in this case (due to realm stack at least).
Revieable per commits.
Testing: Just a refactor, but should be covered by WPT
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
I only wanted to get `&mut JSContext` in microtask chunk and checkpoint,
but this in turn needed `&mut JSContext` in servoparser, which then
caused need for even more changes in script.
I tried to limit the size by putting some `temp_cx` in:
- drops of `LoadBlocker`, `GenericAutoEntryScript`
- methods of `VirtualMethods`
- methods of `FetchResponseListener`
Testing: Just refactor, but should be covered by WPT tests.
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This patch changes the method of `Crypto` interface to use the new `&mut
JSContext`.
The method `crypto.subtle` calls `SubtleCrypto::new` to create an
instance of `SubtleCrypto` and the new `&mut JSContext` is passed to
`SubtleCrypto::new`. Therefore, the new `reflect_dom_object_with_cx`
method is also used in `SubtleCrypto::new`.
Testing: Refactoring. Existing tests suffice.
Fixes: Part of #42638
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Follow-up PR to #42720 (addressing nits by @sagudev)
Testing: It compiles without any errors
Fixes: Part of issue #42638 and PR #42720
Signed-off-by: TimurBora <timurborisov5561@gmail.com>
This introduces a new `ServoTestUtils` namespace with a `forceLayout()`
function. This `forceLayout()` function returns an object which
currently has an array of the phases ran by layout. Also moves
`panic()`, `crashHard()` and `advanceClock()` from `TestBinding` to this
new namespace. `TestBinding` is meant to test the bindings generation,
but these are more generic helpers for Servo-only tests.
Testing: This change adds a series of Servo-only tests that verify the
behavior of the new `forceLayout()` function. Tests that rely on the
moved interfaces are updated and should continue to pass.
Signed-off-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This patch changes the methods of `SubtleCrypto` to use the new `&mut
JSContext` and `&mut CurrentRealm`, Those methods are `Encrypt`,
`Decrypt`, `Sign`, `Verify`, `GenerateKey`, `DeriveKey`, `DeriveBits`,
`Digest`, `ImportKey`, `ExportKey`, `WrapKey`, `UnwrapKey`,
`EncapsulateKey`, `EncapsulateBits`, `DecapsulateKey`,
`DecapsulateBits`.
The change also propagate to the all internal methods within the
`subtlecrypto` module.
Testing: Refactoring. Existing tests suffice.
Fixes: Part of #42638
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Move from `InRealm` to `&mut CurrentRealm` and from `CanGc` to `&mut
js::context::JSContext`
Testing: `/mach build`, `/mach test-unit` and `/mach test-tidy`
Fixes: Part of #42638
Signed-off-by: TimurBora <timurborisov5561@gmail.com>
#42681 did not actually allowed using cx in Constructor, but it did most
heavy lifting. Now we need to pass cx to Constructor call (and skip
CanGc) if cx is requested in Bindings.conf. This PR also test this on
testbindings.
Also we now always use `let cx = &mut cx`, so we can always use just cx
(compiler will automatically deref it into &cx if needed). This is
important because codegen stuff is called from many places to it make
sense/easier to just unify this.
Testing: It compiles
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Moves the drop implementation for `GPUComputePipeline` to a separate
`DroppableGPUComputePipeline` struct.
Removes `allowDropImpl` from the bindings configuration.
Testing: No tests added because of webgpu tests existent coverage
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
The first step of `execCommand` commands is to figure out
if they are supported and enabled. Therefore, implement
these two pieces with only 1 command: delete.
The implementation of `delete` is currently mostly dummy,
to have at least something going. But the main part of
this change is to setup the infrastructure to figure out
when commands are supported and enabled.
For the first part, its simply the list of commands we
currently have implemented, which is only delete.
For the second part, we need to consider the active range
of the current selection and do various checks, as well as
check the presence of `contenteditable`.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This is required for `document.execCommand`, since it needs to check the
active range of the selection whether it has the attribute or not.
It also turns on the relevant WPT tests, with 1
pre-existing failure for absolute positioned pseudo elements. These
currently do not render correctly, regardless of the existence of
contenteditable.
Fixes#12776
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Moves the drop logic for `GPUComputePassEncoder` to a separate
`DroppableGPUComputePassEncoder` struct.
Testing: Tests that coverages webgpu just exist
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
This is a first step to compile scripts using `&mut JSContext`.
Testing: Refactor, covered by existing WPT tests.
Part of #40600
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Demonstrate how to change some methods:
- [from `InRealm` to `&mut
CurrentRealm`](0132fc0fbe)
- [from `CanGc` to `&mut
JSContext`](36e5b32ee1)
Testing: Just refactor, should be covered by WPT.
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
We should only do this for the `insertHTML` command.
All other commands are unaffected.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
In preparation of the actual implementation.
Also had to update the codegen to be able to handle default values for
DOMString.
Part of #25005
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
I just wanted to do abort signal, but then this happend.
Testing: Just refactor, should be covered by WPT tests
Part of #40600
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This is companion to https://github.com/servo/mozjs/pull/703 which makes
mozjs to use CStr(ing) in the API (where we would silently do conversion
in mozjs). This way we can avoid rust string -> c string allocations.
In the followup PR we should switch Error::Type and Error::Range to also
use CStrings internally, as they are converted to CString for throwing
JS exceptions (other get thrown as DomException object, which uses rust
string internally - although this gets converted to JSString somewhere).
Testing: It should be just refactor without any side effects so there
should be no changes to WPT results.
Try run: https://github.com/sagudev/servo/actions/runs/21328878448
Part of #42126
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Moves the `Drop` implementation for `GPUCommandBuffer` to a separate
struct, `DroppableGPUCommandBuffer`. Updates bindings config to remove
`allowDropImpl` which is no longer needed.
Testing: No tests added
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
The implementation of `attr()` in Stylo is not complete, but this way we
can start testing for it.
Bumps Stylo to https://github.com/servo/stylo/pull/306
Testing: Various tests pass, also a few failures. No impact on users,
even with experimental features enabled.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Implements `createIndex` and `deleteIndex`, they have already been
implemented in the backend.
Testing: WPT
Fixes: Partially #38100
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Replace `crate::script_runtime::JSContext` with `js::context::JSContext`
in `BroadcastChannel::PostMessage` and update interface binding.
Testing: Builds and runs locally.
Part of: https://github.com/servo/servo/issues/42347
---------
Signed-off-by: BryanSmith00 <bryansmith8023@tuta.com>
when generating rust bindings for webidl typedef, the `<D>` generic Type
would not be added for record<Key, DomInterface> because
`containsDomInterface` does not take record into account. This change
add the is_Record check in `containsDomInterface`, so `typedef
record<Key, DomInterface>` can be successfully build.
Testing: Manually tested with
https://github.com/servo/servo/issues/42362, and building from scratch
with `./mach build` is successful.
Fixes: https://github.com/servo/servo/issues/42362
---------
Signed-off-by: rayguo17 <rayguo17@gmail.com>
Switch `PostMessage` of `Worker`, `DedicatedWorkerGlobalScope` and
`ServiceWoker` to use `&mut JSContext`, propagating it to
`post_message_impl`.
Testing: A successful build is enough
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
User activation is a concept used to prevents annoying usage of specific
API (Fullscreen API, Virtual Keyboard) to the user by states that the
API needs to have in order to process. This PR implements the
`UserActivation` interface and keep track of the last user interaction.
Each `Window` will keep track the [last activation time
stamp](https://html.spec.whatwg.org/multipage/interaction.html#last-activation-timestamp),
which will be set if there are a triggering input event firing in the
`Window` and propagating across the browsing contexts ancestors and
descendants. These timestamp could be consumed, and the timestamp will
be set to negative infinite.
It is then used to gate some APIs within browser that is determined as
transient activation consuming-gated APIs, which needs transient
activation to be true and consumes the activation. For the purpose of
testing, this PR would implement this behavior on fullscreen API which
is used to test activation consuming behavior.
Spec:
https://html.spec.whatwg.org/multipage/interaction.html#the-useractivation-interface
Testing: Existing WPT
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>