This enables console.* commands in javascript to be forwarded to the
logger and not just stdout.
The domain for this will be `script::dom::console` which seems
appropate.
Testing: Logs do not have any tests.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
To show the contents of inline scripts in the Sources panel, we need to
send the whole HTML file from script to devtools, not just the script
code. This is trickier than the external script case, but we can look to
[how Firefox does
it](https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Getting.20the.20original.20page.20HTML.20from.20script/near/524392861)
for some inspiration. The process is as follows:
- when we execute a script
- notify devtools to create the source actor
- if it’s an external script, send the script code to the devtools
server
- if it’s an inline script, don’t send any source contents yet
- devtools stores the contents in the source actor
- while loading a new document
- buffer the markup, so we can send it to devtools
- when we finish loading a new document
- send the buffered markup to the devtools server
- devtools stores the contents in any source actors with no contents yet
- when a source actor gets a `source` request
- if we have the contents, send those contents to the client
- if we don’t have the contents (inline script that loaded while
devtools was closed)
- FUTURE: try to fetch the markup out of cache
- otherwise send `<!-- not available; please reload! -->`
Testing: Several tests added to test the changes, also updates an
existing test with correct assertion
Fixes: https://github.com/servo/servo/issues/36874
---------
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
As discussed in w3c/trusted-types#468 the spec will be aligned to the
other browsers, which call the callback with undefined as this.
That also allows us to cleanup the JSContext arguments across a couple
of methods.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Implement whole spec of `resolve_module_specifier`. Servo can now
support script element with import map type!
Testing: `tests/wpt/tests/import-map`
Fixes: #37316#36394
---------
Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
This PR moves the `create_image_bitmap` method from `GlobalScope` to a
helper function within the `ImageBitmap` implementation in
`imagebitmap.rs`.
Moving this method improves code organization and maintainability. Given
that `globalscope.rs` is already quite large, relocating
`create_image_bitmap` to `imagebitmap.rs` places it closer to the
`ImageBitmap` struct it primarily operates on.
As mentioned in the issue description (No dedicated tests are required
for this change, as long as the project builds), which it does using
`./mach build`. Also ran `./mach fmt` and `./mach test-tidy` which both
didn't report any issue.
Closes#37348
Signed-off-by: Bhuwan Pandit <bhuwanpandit109@gmail.com>
Now that we are standardizing on the `_traits` crates becoming `_api`
and exposing the API of the crate that they get their name from [^1],
`script_layout_interface` becomes `layout_api` as it exposes the API for
`layout` that is used by `script` This brings the crate in line with the
naming of the other ones in `shared`.
[^1]:
https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Organizing.20*_traits.20crates/with/396893711
Testing: This should not change any behavior and thus is covered by
existing tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
1. The `shared` directory is for the "_traits" crates, which will likely
be moved out of this directly at some point and renamed "_api". These
crates expose the API of crates to avoid circular dependencies.
`Snapshot` isn't really this.
2. `Snapshot` is essentially a specialied kind of `Image` so it makes
sense that it is grouped with other image-related things in `pixels`.
Testing: This should not change any behavior so is covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Also renamed all "CSS" selector variants of `WebDriverScriptCommand` to
avoid confusion.
Testing: Mostly `./mach test-wpt -r
tests\wpt\tests\webdriver\tests\classic\find_*_from_shadow_root\find.py
--product servodriver`
But many other test also relies on finding element(s) from shadow root,
so I ran the entire test.
All deleted lines are from test expectations.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This is finishing some incomplete cleanup from #33044. Kitchen sink enum
types like IndexedDBThreadReturnType make code harder to read and
require ignoring variants that will never be sent in many cases.
Testing: No behaviour change; existing WPT tests suffice.
Fixes: part of #6963
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
No longer store scroll offsets for elements in the DOM. Instead
consistently get and set these in layout's `ScrollTree`. This more
consistently requires layout to run when querying scroll offsets, which
ensures that they are up-to-date and properly bounded by scrollable
overflow area.
Testing: This causes several WPT tests to start passing, and one to
start
failing. In the case of
`/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html`, I believe the
issue
is that we don't properly handle scrolling and shadow DOM elements.
Before, the
faulty scrolling was hiding this issue.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
IDBVersionChangeEvent is already used internally from non-Window
globals, but the constructor wasn't set up to expose the interface
object in worker globals.
Testing: The effort involved in adding a test for this does not seem
worthwhile—we get this for free once we enable the indexeddb preference
while our interfaces.worker.js test is running.
Fixes: part of #6963
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Global scopes have two creation URLs: one for itself and one for the
"top-level" scope. It's not immediately obvious what is considered
top-level here (it is not strictly defined in the specification).
In any case, reports need the creation URL of the scope itself, not the
top-level version. Therefore, propagate this information from all
scopes, where the worker and worklets remain to pass in `None` for their
top-level scope.
Part of #37328
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Follow to the HTML specification and support of Blob as
ImageBitmapSource
to able use it as intermediate instance in "fetch() -> Blob ->
ImageBitmap" execution sequence.
https://html.spec.whatwg.org/multipage/#imagebitmapsource
The specification says what these steps must run in parallel
(outside the createImageBitmap task), but currently loading bytes from
Blob
and later image decoding happen in synchronous order while
promise is fullfilled or rejected on bitmap task source.
https://html.spec.whatwg.org/multipage/#the-imagebitmap-interface:blob-4
Testing: Improvements in the following WPT tests
- html/canvas/element/compositing/2d.composite*
- html/canvas/element/drawing-images-to-the-canvas/2d.drawImage*
- html/canvas/element/manual/imagebitmap/createImageBitmap*
- html/canvas/offscreen/compositing/2d.composite
- html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage
- webgl/tests/conformance/textures/image_bitmap_from_blob/*
Fixes (partially): #34112
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
While this introduces many new crashes in the test results, that's
actually progress. Previously a huge number of tests were failing early
because we never persisted the load-bearing `result` value for
upgradeneeded events, so now we get to see much more interesting
failures in our IndexedDB implementation.
Testing: Existing WPT testsuite for IndexedDB.
Fixes: part of #6963
Depends on #37567.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
There were a lot of crashing IndexedDB tests caused by code in
DOMStringList that required a Window object despite being exposed to
non-Window globals.
Testing: Lots of existing tests no longer crash.
Fixes: part of #6963
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Instead of printing a Rust compilation warning, simply print a message
before every build (when using `mach`) that shows the build
configuration and whether or not `crown` is enabled.
Fixes#32597.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Testing: Observing the parsed poster URL is not possible by javascript
and would require the server to somehow tell the client which URL was
requested. I don't know how to do that in WPT and I don't think the
effort is worth it.
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Exclude CDATASection nodes from Node::normalize. I made it under the
assumption that CDATAs can't have children so we don't need to go into
the `else node.Normalize()` branch on line 3485 with them, hope this is
correct.
Testing: covered by `dom/nodes/Node-normalize.html`
Fixes: https://github.com/servo/servo/issues/37006
---------
Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
According to HTML specification the poster attribute determines the
element's poster frame
(regardless of the value of the element's show poster flag).
https://html.spec.whatwg.org/multipage/#poster-frame
So the poster frame and the show poster flag is orthogonal to each
other, the latest one only controls
when browser should display the poster frame and should do not block
accepting video frames
from media pipeline (e.g. on new_preroll callback from video sink).
During layout the video element should select the current frame which
will be presented
based on first matching condition from the list:
https://html.spec.whatwg.org/multipage/#the-video-element:the-video-element-7
Testing: Improvements in the following WPT tests
- html/canvas/element/manual/imagebitmap/createImageBitmap*
- html/semantics/embedded-content/the-canvas-element/*
Fixes: #37165
---------
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Fix wheel event, either dispatched from window or webdriver:
- Positive deltaY means scrolling down, negative deltaY means scrolling
up
- Positive deltaX means scrolling right, negative deltaX means scrolling
left
Tests: Many scrolling interaction test will depend on this.
Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
Implement "get a known shadow root" and reduce some duplication
This is still a preparation PR to ["find element(s) from shadow
root"](https://w3c.github.io/webdriver/#find-element-from-shadow-root)
Testing: No Behaviour change.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Adds indexeddb support to servo. At the moment heed is being used as the
backend, although this can be swapped out by implementing `KvsEngine`.
This PR adds a thread + a thread pool for Indexeddb related operations.
Also `database_access_task_source` is added for Indexeddb related
operations.
This is a partial rewrite of #25214. (Reopened due to branching issue)
Fixes#6963
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Rasmus Viitanen <rasviitanen@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
using abort signal and abortcontroller in
Writablestreamdefaultcontroller
Part of https://github.com/servo/servo/issues/34866
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
1. `get_known_element`: Refactor to follow same step of spec (which
reduces unnecessary search) and implement previously missing step 4.2:
If node is stale return error with error code stale element reference.
An element is stale if its node document is not the active document or
if it is not connected.
2. Refactor `find_node_by_unique_id_in_document` to make it not check
error and really return a `Option<DomRoot<Node>>` as the name suggests.
This will greatly reduce duplication when implement [get a known shadow
root](https://w3c.github.io/webdriver/#dfn-get-a-known-shadow-root) soon
Testing: All WebDriver Conformance test after removing two problematic
commits in #37520
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Currently, the hover state will stay when the mouse moves out of the
webview, this PR fixes it
Testing: Hover on the `About` on servo.org, and then move the mouse up
to the browser UI, see the hover state resets
Signed-off-by: Tony <legendmastertony@gmail.com>
- Register import map when preparing HTML script element
- Added `import_map` to `GlobalScope`
Testing: should pass existing WPT
Fixes: part of https://github.com/servo/servo/issues/37316
---------
Signed-off-by: Jason Tsai <git@pews.dev>
This PR fixes some mistakes introduced in
https://github.com/servo/servo/pull/37332. Where Binding.conf and
WeakReferenceable trait were used badly
Testing: No test introduces
Fixes: It fixes mistake introduced in the incrementally implementation
of #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
For example `div[count(//p)]` should count all `<p>` elements in the
document, not just the ones underneath the `<div>`.
Testing: WPT tests cover this, the fix makes two more test pass.
Signed-off-by: Ville Lindholm <ville@lindholm.dev>
Implement previously missing step 3 of [get a known
element](https://w3c.github.io/webdriver/#dfn-get-a-known-element): "If
node is not null and node does not implement Element, return error with
error code no such element"
Testing: All webdriver conformance test
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Previously, the Constellation would immediately ask the Compositor to
shut down a pipeline, even before the ScriptThread finished shutting it
down. This meant that the Compositor might remove a Pipeline and then
re-add it if the ScriptThread sent a Pipeline-related message (such as a
new display list) in the meantime.
This change makes it so that the Compositor waits for both the
Constellation and the ScriptThread to finish shutting down a Pipeline
before removing its data. In addition, the Constellation no longer
synchronously waits on the Compositor when shutting down Pipelines. This
was important when the Compositor would talk to the ScriptThread
directly, but isn't necessary any longer.
Testing: This is very hard to test, because it depends on the creation
and destruction of many iframes and the particular timing of of all
the messaging between Servo bits. That said, this was tested manually
by observing the completion of Speedometer 2.1.
Fixes: #37458.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Follow the ImageBitmap specification and use the global scope bitmap
task source
to fulfill resolved promise (asynchronously).
https://html.spec.whatwg.org/multipage/#bitmap-task-source
Any promise rejection must be done synchronously.
Testing: Improvements in the following WPT test
-
html/canvas/element/manual/imagebitmap/createImageBitmap-resolves-in-task.any.js
Fixes (partially): #34112
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Follow the ImageBitmap specification and make cropping of the bitmap
data to the source rectangle with formatting:
https://html.spec.whatwg.org/multipage/#cropped-to-the-source-rectangle-with-formatting
For now the next functionality not implemented:
- image orientation support (such as EXIF metadata)
- color space conversion (image, blob)
The convertion from ResizeQuality to "image" FilterType:
- pixelated/low/medium/high -> Nearest/Triangle/CatmullRom/Lanczos3
Other browsers use the following sample filtering:
- chromium (skia): Nearest/Linear/Linear/CatmullRom
- firefox (skia): Lanczos3
Testing: Improvements in the following WPT tests
- html/canvas/element/manual/imagebitmap/*
Fixes (partially): #34112
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
1. Properly report new types of errors for `find_element` and
`find_elements`. Previously never reported.
1.1. `InvalidSelector`
1.2. `NoSuchElement`
1.3. `InvalidArgument`
2. Get the visible text for `<a>` correctly in
`script::webdriver_handler` so that matching would work.
Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
webdriver/tests/classic/find_element/find.py
webdriver/tests/classic/find_elements/find.py --product servodriver`
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
A document's named getter collects elements with either matching name or
id's (varies per element type) and returns them .
We implement this the following way:
* Create an iterator with elements whose `name` attribute matches
* Create an iterator with elements whose `id` attribute matches
* Concatenate both
The spec then asks us if there is more than one element in the list,
which we implement by checking whether the iterator returns `None` after
we get the first element. However, the same element can appear in both
iterators if it is a `img` element and both it's name and id attribute
match. Therefore, we need to check if there are more elements *which are
not equal to the first one*.
Testing: New web platform tests pass
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
The check was incorrect, where it was never matching and always
discarding the element. Instead, we should check the owner document,
which is the shadow-including root of the node.
Part of #4577
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This avoids various conversions back and forth between DOMString and
String. By using DOMString consistently, we avoid these
double-conversions. The only caveat are the USVString which are
initially passed into
TrustedScriptURL.
Part of #36258
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Move all report structs into the same file, to
keep them consistent and reuse functions such as stripping
of the URL and serialization of disposition. This is part
of modularizing security_manager, which contained various
logic related to CSP.
Part of #4577
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Stop DedicatedWorker from handling remaining messages after closed
Testing: WPT workers/WorkerGlobalScope-close.html
Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
Fix `WebDriverScriptCommand::GetElementText` similar to
https://github.com/servo/servo/pull/37452#discussion_r2146350739, by
correctly retrieving rendered text.
Testing: `./mach test-wpt -r --log-raw "D:\servo test
log\gt_ele_txt.txt" webdriver/tests/classic/get_element_text --product
servodriver`
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Created a new method `HTMLElement::is_body_element` that replaces
`HTMLBodyElement::is_the_html_body_element`.
Testing: Existing WPT tests should pass.
Fixes: https://github.com/servo/servo/issues/37429
---------
Signed-off-by: iamlockon <xdddxyyyxzzz123@gmail.com>
Recently added WPT tests for this are now mostly passing. The remaining
tests fail on importmap support.
Part of #36258
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>