Trims leading and trailing spaces and tabs for names and values in
Get/GetAll/Set. The specification does this in the query/set cookie
methods but those functions are split across the script, resource
thread, and cookie storage. Instead I'm normalize the values at the API
entry points so we have the normalized values everywhere.
Testing: Cookiestore WPT tests cover this
Signed-off-by: Sebastian C <sebsebmc@gmail.com>
Implement steps 1. and 2. of the websocket constructor to resolve the
url against the current settings API base URL.
Testing: Some WPT tests are now passing
Signed-off-by: webbeef <me@webbeef.org>
The import key operations of
- RSASSA-PKCS1-v1_5 (`rsassa_pkcs1_v1_5_operation::import_key`)
- RSA-PSS (`rsa_pss::import_key`)
- RSA_OAEP (`rsa_oaep::import_key`)
only differ from each other by a few steps. This patch combines them
into a single function (`rsa_common::import_key`) shared among them.
The enum variant `RsaAlgorithm::RsaSsaPkcs1v15` is also renamed as
`RsaAlgorithm::RsassaPkcs1v1_5` for clarity.
Testing: Refactoring. Existing tests suffice.
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Start with implementing the new algorithms per the spec. This fixes the
case where the load event should be fired, but only if a src exists and
it is about:blank and it is connected for the very first time.
Part of #31973
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Also fixes propagating expiry clamping to underlying cookie object. This
matters when attempting to inspect expiry time from a retrieved cookie.
According to the WPT tests, setting max-age in a cookie string is
supposed to be visible in the retrieved expiry.
Testing: cookiestore WPT tests cover this behavior
Signed-off-by: Sebastian C <sebsebmc@gmail.com>
This was the last failure in this directory. To fix it, I had to spelunk
into a couple of places:
1. We shouldn't use the `base_element()` of the document, but select the
first base element, regardless if it has an empty href or not
2. We didn't implement target checking for elements. Only some values
are valid and an empty target (which the test also confusingly uses) is
not valid. Hence, it should fallback to the base element
3. We weren't sanitizing the value in case it contains an ASCII tab or
newline + U+003C. This is true for both the form target as well as for
other link elements.
All in all, added a lot more specification text to figure out what was
going on.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This change merges http://github.com/servo/media into this repository.
It is only used by Servo and version upgrades are complicated by having
two repositories. In addition, this avoids the need to refer to
individual commit hashes in the Servo `Cargo.toml`. The hope is that
merging these two repositories will lead to better code organization /
simplification like we have seen with the WebXR support. Initiailly, the
idea was that this media support could be shared with the wider Rust
ecosystem, but I think that hasn't worked out as planned due to the fact
that it is difficult to use the various media packaes outside of the
Servo project and the fact that no one seems to be doing this.
Some changes were made when importing the code:
- The second commit in this PR addresses new clippy warnings from the
imported code.
- GStreamer Packages are no longer renamed in the media code, so that
they are named the same as they are currently in Servo.
- Some examples are not ported as they require being run interactively
and depend on older version of important libraries like winit.
Having these dependencies in the core part of Servo isn't very
convenient. Removed examples:
- `audio_decoder.rs`: This is meant to be run interactively with a
file so isn't very useful for testing.
- Depended on winit GUI (`player` subdirectory):
- `media_element_source_node.rs`
- `play_media_stream.rs`
- `simple_player.rs`
- `muted_player.rs`
- `siple_webrtc.rs`: Depended on `webrtc` library:
Testing: This is covered by existing tests. In addition, the job which
runs
the media examples is added to the unit test workflow.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
When a `<link>` element loads a stylesheet then it calls
`ElementStylesheetLoader::new`, followed immediately by
calling `load` on the new loader. This is the only place where these
functions are used, so we can coalesce them together and avoid an
unreachable assertion in the process.
This should have no impact on the end user, it's just a cleanup.
Testing: Regressions should be covered by existing tests
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Previous IntersectionObserver had only connect_to_owner_unchecked
method. We replace this with a checked method to not add the same
IntersectionObserver to the same document multiple times.
This should improve performance as the same IntersectionObserver was
tested multiple times.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: Compilation and println statements to see if we do not add us
again to the document.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Instead of immediately looking for the top-level browsing context's
`Document` in the `ScriptThread`, check whether `Window` is top-level
beforehand. This is a small optimization.
Testing: Existing WPTs (no behavior changes)
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Profiling a speedometer run showed significant time spent in some layout
function in vector allocations. The main change is to switch the result
of `query_box_areas()` from a Vec<T> to and iterator.
Testing: refactoring with no expected test changes
Signed-off-by: webbeef <me@webbeef.org>
The patch adds the following functionality to the per-WebView
`UserContentManager` API.
- Removing a `UserScript` at that was previously added.
- Adding a new `UserStyleSheet` representing a user-origin style sheet.
allow removing user script
- Removing a previously added `UserStyleSheet`.
There might be scope for some improvements in the API:
- `UserScript` and `UserStyleSheet` have different ways of representing
the source location - a `PathBuf` and `Url` respectively. This is due to
how those values are used by the underlying evaluation APIs in script
and stylo. More investigation is needed here and could be addressed in
future patches.
Testing: New unit tests are added for the user stylesheet APIs. Existing
tests have been updated to test the removal of user scripts.
Leaving the entries sitting around both unnecessarily increases memory
usage and breaks code that looks up window proxies by name and reuses
names for iframes within the same page.
Testing: Newly-passing tests.
Fixes: #15258
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
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>
In addition, clean-up the UA stylesheet for dialogs.
Stylo PR: servo/stylo#301
Testing: change causes several WPT tests to start passing.
Signed-off-by: Luke Warlow <lwarlow@igalia.com>
This change organizes the rest of the media-related interfaces by moving
the WebVTT-related[^1] interfaces into their own directory and two more
media-related interfaces into the `media` directory.
Testing: This just moves source files around, so a successful build
should be a good enough test.
Fixes: This is part of #38901.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Move some common/similar steps of the import key operations of AES-CTR,
AES-CBC, AES-GCM, AES-KW and AES-OCB to the shared module `aes_common`.
Some comments are also added to the shared module `aes_common` to
explain the small difference in the specification of AES-OCB operations.
Testing: Refactoring. Existing tests suffice.
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Start using `&mut JSContext` and wrappers2 functions for module script
code.
Testing: A successful build should be 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>
Support `errorCallback` in geolocation position request functions and
throw the necessary errors.
Testing: Passes 3 more WPT tests
Fixes: Partially #38903
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
We weren't removing stylesheets when we should be doing so. This most
notably happens when the stylesheet no longer has a href or its "rel"
changes.
The crash is also fixed, since the issue was that we were passing the
value of the attribute that was changed as if it were an href. However,
if we set the type attribute, then that's not the href.
To fix that, we now retrieve the href inside the method so we always
have the correct value.
Fixes#42259
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
A template element should set the host of a DocumentFragment. However,
it didn't have a host yet. That's because ShadowRoot declares a host
attribute which returns Element, but its property is declared on
DocumentFragment.
Therefore, define the host on DocumentFragment instead and use it in all
relevant points for shadow roots. Then, update the pre-insert validity
check to use the correct host-including variant of inclusive ancestors.
Lastly, set the host of the template to wire it all up.
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This change adds support for the `colorspace` attribute on color inputs
and implements serialization of the input value accordingly.
The color picker from servoshell doesn't yet support non-rgb colorspaces
(and neither does the embedding API), so we convert to and from rgb when
communicating with the embedder.
Testing: New tests start to pass
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Implement the full connection lifecycle, from opening and potentially
upgrading a database, waiting on existing connections to close, firing
the versionchange and blocked events, and updating pending open requests
when connections close.
Testing: WPT
Fixes: Part of https://github.com/servo/servo/issues/40983
---------
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Servo doesn't have a pdf viewer, so we simply set the property to
`false`.
Testing: New tests start to pass
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Reviewable per commits:
As noted in
https://github.com/servo/servo/pull/42180#discussion_r2749861902
transmuting `&Reflector<AssociatedMemory>` to `&Reflector<()>` will
ignore AssociatedMemory information and thus it will not remove extra
associated memory. By returning `&Reflector<Self::ReflectorType>` from
`DomObject::reflector()` we will preserve this information and thus
correctly handle cases with associated memory. We also do not need
`overrideMemoryUsage` in bindings.conf anymore. 🎉
Instead of removing associated memory in drop code we should do it as
part of finalizers, otherwise we have problems in nested (inherited)
structs, where drop is run for both parent and child, but we only added
associated memory for child (on init_reflector) which already included
size of parent. The only exception here is promise, because it is RCed
and not finalized.
Testing: Tested locally that it fixes speedometer.
Fixes#42269
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This change fixes a crash in options collections due to the fact that a
`<select>` element was being considered an ancestor of itself. This
regression likely introduced in #40776.
This change also fills in the specification text for
`HTMLOptionCollect::Add`.
Testing: This change adds a WPT crash test.
Fixes: #41080.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Make it runs at the correct time and then also performs checks for its
scheme. The CSP check is left for a follow-up PR.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
With import attributes enabled we can now support non javascript
modules, for now we are limited to json ones.
Switch `GlobalScope` `modulemap` to be keyed by the tuple url and
module's type.
Testing: Enabled a new directory, new tests should pass
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
We can avoid doing 2 traversals and stop at the first matching child we
find. This ensures we are never doing the longest iteration.
Testing: covered by WPT
Signed-off-by: webbeef <me@webbeef.org>
By reporting memory usage of rust objects back to SM it can trigger GC
sooner and release more memory (I hope that we could use this to avoid
OOB in webgpu in the future).
Currently we use simple `size_of::<DomStruct>() +
size_of::<Box<DomStruct>>()` but it's possible to override reported
memory with `update_memory_size(self, nbytes);` on reflector. This is
mostly useful for canvases and buffers which usually have large
associated data.
Testing: None, but I am wondering if we can connect this to
`about:memory`.
Fixes: #42168
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This changes 3 occurences of HashSet to FxHashSet for speed
improvements:
- dom/notifications::pending_request_ids: Pending Request ids are
Uuid::new_v4, hence, not user assignable.
- script_thread: painters_generating_frames: These are pipeline ids and,
hence, ideal for FxHash.
- script_thread:: docs_with_no_blocking_loads: These are Dom<Document>
and their hash is the ptr address, so ideal for FxHash.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: These do not change functionality.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Because of the deprecation of bincode we are switching to postcard
(which will already be used by ipc-channel).
This changes all usages to postcard.
Sadly there are still some dependencies using bincode, so we are
probably increasing the binary size.
Currently we do not modify the deny.toml because we have dependencies
that depend on bincode.
Testing: Compilation should be enough for test.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Added calls to download web font from stylesheet when stylesheets are
added to shadow root.
Testing: Manual testing. Added a new WPT testcase
---------
Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Moves the `Drop` implementation for `GPUCanvasContext` to a new
`DroppableGPUCanvasContext` struct.
This ensures the context destruction logic is correctly handled, as the
`GPUCanvasContext` struct itself is a DOM struct and should not have a
drop implementation. This change aligns with the requirement that DOM
types should not implement Drop.
Testing: No tests added
Fixes: #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Add support for `:open` pseudo-class. This is supported on dialog,
details and select elements.
Stylo PR: servo/stylo#297
Testing: WPTs but also
`data:text/html,<select><option>123</option></select><style>:open {
background-color: red; }</style>`. There are some tests that now error,
these previously failed due to missing `:open` and now make it further
along hitting test_driver.send_keys() which causes them to error
Fixes: #41277.
---------
Signed-off-by: Luke Warlow <lwarlow@igalia.com>
When a node has `attachShadow()` successfully called on it, its
descendants are no longer in the flat tree. This change makes it so that
the layout data of these descendants is cleared during `attachShadow()`
so that the node is no longer considered to have a layout box.
Testing: This change includes a new WPT crash test.
Fixes: #42215.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
When doing operations on `RopeIndex` that need to make slices of lines,
this change makes it so that the resulting index does not intersect a
character. This is important because Rust will panic if you attempt to
slice a string that way.
Testing: This change adds a WPT crash test and a `Rope` unit test.
Fixes: #42217.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Ensure that the UA shadow DOM for `<textarea>` is initialized when we
are binding to a tree.
Testing: New WPT.
Fixes: #42231
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>