Commit graph

64032 commits

Author SHA1 Message Date
Timothy Flynn
598fabbdd3 LibWebView: Increase the open file limit in a more central location
We don't create a ChromeProcess in headless-browser, so it is currently
not increasing it's open file limit. This is causing crashes on macOS,
which has a very low default limit.
2024-10-07 14:03:03 -04:00
Ali Mohammad Pur
cb4b2ca681 Meta: Avoid messing with the system python in CI
This uses the setup-python action in the setup action to install python
3.12, and removes the --break-system-packages hack that the system pip
requires.
2024-10-07 11:45:21 -06:00
Aliaksandr Kalenik
97066f09f4 LibWeb: Use PaintableBox::is_scrollable() while dispatching wheel event
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
With this change we use the same function to determine whether to render
scroll thumb and whether box wants to accept scroll UI events.
2024-10-07 18:35:24 +02:00
Aliaksandr Kalenik
a46c2a0887 LibWeb: Forbid scrolling of viewport if overflow=hidden
Before this change viewport was allowed to be scrolled whenever it has a
scrollable overflow, which is not correct when overflow is specified to
be hidden.
2024-10-07 18:35:24 +02:00
Khaled Lakehal
77761e123d LibWeb/CSS: Add support for unicode-bidi property 2024-10-07 14:57:15 +01:00
Gingeh
16f2f6aa42 LibWeb: Make empty media query lists evaluate to true 2024-10-07 14:50:57 +01:00
Shannon Booth
30377e6e35 LibWeb: Do not spin the event loop on processing iframe attributes
Partially reverting a3149c1ce9

Spinning the event loop was causing a crash on:

https://wpt.live/url/percent-encoding.window.html

As it was turning what is meant to be a synchronous operation into an
asynchronous one.

The sequence demonstrated by the reproducing test is as follows:
  * A src attribute is changed for the iframe
  * process_the_iframe_attributes entered with valid content navigable
  * Event loop is spun, allowing the queued iframe removal to execute
  * process_the_iframe_attributes continues with null content navigable
  * 💥
2024-10-07 15:10:41 +02:00
Timothy Flynn
62e732e5ad Revert "WebContent+WebDriver: Inform WebDriver when a window is closed"
This reverts commit 556a0936dd.

This was causing a large slow down in WPT, and a crash on macOS during
session shutdown when running WebDriver manually.
2024-10-07 07:40:22 -04:00
Carwyn Nelson
30f59cfe1a LibWeb: Skip transitions for pseudo elements
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Transitions are currently not implemented for pseudo elements which
causes the transition to be applied to the "real"/"parent" element. When
a transition adjusts width/height on a pseudo element this causes the
real elements layout to break.

As a quick fix we just skip doing transitions when they are against
pseudo elements.
2024-10-07 09:31:40 +02:00
Andreas Kling
2fdf2b9215 LibWeb: Allow SVG root elements to have visible overflow
We were overly aggressive in clipping SVG roots, which effectively made
them behave as if they always had `overflow: hidden`.

This fixes incorrect clipping of the logo on https://basecamp.com/
2024-10-07 09:31:25 +02:00
Shannon Booth
f2134dc1e9 LibWeb: Throw exception for invalid URL before creating traversable
Which fixes the following WPT test from failing due to issues stemming
from all of the windows which have been opened.

https://wpt.live/url/failure.html

This will give us 1205 new subtests passing in WPT.
2024-10-06 22:54:27 -06:00
Neil Viloria
1e29a3ae13 Documentation: Update command for regenerating test expectations 2024-10-06 22:48:13 -06:00
Timothy Flynn
dfabdb7fed headless-browser: Support running LibWeb tests concurrently
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
We currently create a single WebView and run all 1400+ LibWeb tests in
serial over that WebView. Instead, let's create as many WebViews as
there are processes on the system, and run LibWeb tests concurrently
over those views.

To do this performantly requires that we never block the main thread of
the headless-browser process once the tests are running. Doing so will
effectively pause execution of all other tests. So test execution is now
Promise-based.

On my machine (with a hardware concurrency of 32), this reduces the run
time of LibWeb tests from 31.382s to 3.640s. CPU utilization increases
from 5% to 67%.
2024-10-06 19:24:25 +02:00
Timothy Flynn
49a53a6194 headless-browser: Move completion handlers for dump/ref tests to lambdas
No functional difference here, and this probably seems a bit silly, but
the purpose is to make the diff of a future patch much easier to read.
2024-10-06 19:24:25 +02:00
Timothy Flynn
08426efebc headless-browser: Define the test-related structures earlier
And re-order the Test fields to have the test mode first.

No functional change - this is just to reduce diff noise a bit in an
upcoming patch.
2024-10-06 19:24:25 +02:00
Timothy Flynn
e6975ec76a headless-browser: Make taking screenshots during tests more asynchronous
This will be necessary to run tests concurrently, otherwise taking a
screenshot for one test will block all tests from executing.
2024-10-06 19:24:25 +02:00
Timothy Flynn
642a611418 headless-browser: Do not track the current test path
Instead, just log the view's current URL when the WebView crashes. It
won't make any sense to track the executing test this way once there are
many tests running concurrently.
2024-10-06 19:24:25 +02:00
Timothy Flynn
adfe120d1e headless-browser: Migrate service management to the browser Application
We currently run all tests in a single WebView instance. That instance
owns the process-wide RequestClient / ImageDecoderClient, so if we were
to create a second instance, we'd run into trouble.

This migrates ownership of these services to the Application class, and
makes the Application own the WebView. In the future, this will let the
Application own a list of views.
2024-10-06 19:24:25 +02:00
Timothy Flynn
377d1f22ae headless-browser: Make the browser Application more accessible
We currently pass around the individual fields of the Application class
to a bunch of free functions. This makes adding a new field, and passing
it all the way to e.g. run_dump_test pretty annoying, as we have to go
through about 5 function calls.

This will get much worse in an upcoming patch to run LibWeb tests
concurrently. There, we will have to further pass these flags around as
async lambda value captures.

To make this nicer, just access the flags from Application::the(), which
is how the "real" UIs access their application objects as well.
2024-10-06 19:24:25 +02:00
Timothy Flynn
b1718f5691 LibWeb: Disable remaining Worker tests for now
These time out on macOS CI.
2024-10-06 19:24:25 +02:00
Aliaksandr Kalenik
d0463bf652 LibWeb: Simplify static position calculation for block-level boxes
There is no need to save vertical offset in UsedValues to use later,
when static position could be assigned directly upon encountering
abspos box.
2024-10-06 18:51:16 +02:00
Aliaksandr Kalenik
7225087fa2 LibWeb: Replaced remaining usage and delete Size::resolved() 2024-10-06 18:51:03 +02:00
Timothy Flynn
76152845fd LibWeb: Remove debug spam from Navigator methods
These are logged ~1000 times on fast.com.
2024-10-06 18:50:44 +02:00
Aliaksandr Kalenik
908455ab06 LibWeb: Skip queuing a rendering task if task queue already contains it
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
If, by the time we need to schedule rendering of the next frame, the
previous one is still not processed, we could skip it instead of growing
task queue.

Should help with https://github.com/LadybirdBrowser/ladybird/issues/1647
2024-10-06 16:25:33 +02:00
Shannon Booth
ea971792b5 LibWeb: Throw a SyntaxError on invalid URL for Location href setter
Aligning with a spec update, fixing 195 tests for:

https://wpt.live/url/failure.html
2024-10-06 10:06:26 -04:00
Andreas Kling
59ed823724 LibWeb: Resolve flex item % main size to 0 during min-content sizing
When the flex container is sized under a min-content constraint in the
main axis, any flex items with a percentage main size should collapse
to zero width, not take up their own intrinsic min-content size.

This is not in the spec, but matches how other browsers behave.

Fixes an issue where the cartoons on https://basecamp.com/ were way
too large. :^)
2024-10-06 16:04:00 +02:00
Aliaksandr Kalenik
1a78edb8c9 LibWeb: Define static position calculation separately for each FC
Static position of a box is defined by formatting context type it
belongs to, so let's define this algorithm separately for each FC
instead of assuming FormattingContext::calculate_static_position_rect()
understands how to handle all of them.

Also with this change calculate_static_position_rect() is no longer
virtual function.
2024-10-06 15:45:08 +02:00
Timothy Flynn
6ee1c4c634 CI: Install pyyaml from pip
Homebrew has disabled the pyyaml package for some reason.
2024-10-06 09:42:35 -04:00
Timothy Flynn
5056bda043 LibCore: Ensure shared memory file names on macOS are unique
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
At least on my mac, clock_gettime only provides millisecond resolution.
So if many WebContent processes are opened at once, it is not unlikely
that they will all create their backing stores within the same ms. When
that happens, all but the first will fail (and crash).

To prevent this, generate the shared memory file name based on the PID
and a static counter.
2024-10-06 07:44:06 +02:00
Timothy Flynn
aa1df95b31 LibWeb: Implement window.close and window.closed 2024-10-06 01:42:24 +01:00
Timothy Flynn
ae130822a0 headless-browser: Allow popups for LibWeb testing 2024-10-06 01:42:24 +01:00
Timothy Flynn
ce11a90726 WebContent+WebDriver: Handle when new windows are immediately closed
This happens when window.close() is invoked immediately upon a window
being opened.
2024-10-06 01:42:24 +01:00
Timothy Flynn
556a0936dd WebContent+WebDriver: Inform WebDriver when a window is closed from JS
This hooks into the same PageClient method that closes the UI tab after
an invocation to window.close().
2024-10-06 01:42:24 +01:00
Timothy Flynn
84df1bf585 LibWeb: Mark a BC's navigable as destroyed if it does not exist 2024-10-06 01:42:24 +01:00
Timothy Flynn
5aa50bff8b LibWeb+WebDriver+WebContent: Implement the Element Click endpoint 2024-10-06 01:42:24 +01:00
Timothy Flynn
95bf6c9877 WebContent: Do not wait for navigations on BCs that have no navigable
This avoids a crash seen in WPT when a click event is fired on a BC that
has been removed from the document.
2024-10-06 01:42:24 +01:00
Timothy Flynn
ab3cfd9bbb WebContent: Separately store the WebDriver parent and top-level BCs
We are currently trying to access the current parent and top-level
browsing contexts from the current BC itself. However, if the current BC
is closed, its association to the parent and top-level BCs is lost, and
we are no longer able to handle WebDriver endpoints involving those BCs.

Instead, let's store the parent and top-level BCs separately, and update
them in accordance with the spec.
2024-10-06 01:42:24 +01:00
Timothy Flynn
969361abdb WebDriver: Allow deleting sessions with an invalid window handle
This case was missed in commit b5aa8f65b1.
2024-10-06 01:42:24 +01:00
Andreas Kling
077bc68a4c LibWeb: Allow intrinsic width layout to see definite heights
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
We were already allowing intrinsic height layout to see definite widths,
and I can't think of a reason *not* to allow it the other way around.

More importantly, this fixes an issue where things with an aspect ratio
didn't have a height to resolve against before.

Makes the logo show up on https://basecamp.com/ :^)
2024-10-05 19:24:20 +02:00
Neil Viloria
4bda65c8b3 LibWeb/Layout: Implement justify-content for column spacing in grid 2024-10-05 19:21:49 +02:00
Andreas Kling
aae191aa33 LibWeb: Bail from various navigable operations when no active window
Some checks are pending
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
If we end up in a situation where the navigable no longer has an active
window, we can't perform navigation or many other navigable operations.

These are all ad-hoc, since the navigables spec is basically all written
as if there's always an active window. Unfortunately, the active window
comes from the active document's browsing context, which is a nullable
concept even in the spec, so we do need to deal with null here.

This removes all the locally reproducible crashes when running WPT over
the legacy Japanese encoding directory on my computer.

Yes, this is a bit of a monkey patch, but it should be harmless since
we're (as I understand it) dealing with navigables that are still
hanging around with related tasks queued on them. Once all these tasks
have been completed, the navigables will go away anyway.
2024-10-05 16:24:10 +02:00
Shannon Booth
088b659abd LibURL: Do not treat port of 0 as a null port in Origin
It is not treated as the same thing in the specification, or by us in
other places too. This fixes 8 more origin related URL tests on WPT.
2024-10-05 10:46:30 +02:00
Shannon Booth
501f92b54e LibWeb+LibURL: Consolidate Origin parsing and serialization into LibURL
Because of the previous awkward factoring of Origin we had two
implementations of Origin serializing and creation. Move the
implementation of DOMURL::url_origin into URL::origin, and
instead use the implemenation of URL::Origin::serialize for
serialization (replacing URL::serialize_origin).

This happens to fix 8 URL subtests as the two implemenations had
diverged, and URL::serialize_origin was previously missing the spec
changes of: whatwg/url@eee49fd and whatwg/url@fff33c3
2024-10-05 10:46:30 +02:00
Shannon Booth
12ea470417 LibWeb+LibURL: Get blob's environments origin from URL's blob entry
This closer matches specification - and removes any dependency on
LibWeb in the implementation of DOMURL::url_origin.

It is also one step closer to moving BlobURLRegistry to a singleton
process to match LibWeb's multiprocess Worker architecture.
2024-10-05 10:46:30 +02:00
Shannon Booth
43973f2d0a LibURL: Define Origin methods depending on URL::Parser out of line
This is also in an effort towards resolving a future circular dependency
between Origin.h and URL.h
2024-10-05 10:46:30 +02:00
Shannon Booth
53ad982bb7 LibURL: Factor Host into a standalone header file
This will help solve a future circular dependency between URL.h
and Origin.h
2024-10-05 10:46:30 +02:00
Shannon Booth
dc401f49ea LibWeb+LibURL: Move HTML::Origin to URL::Origin
While Origin is defined in the HTML spec - this leaves us with quite an
awkward relationship as the URL spec makes use of AO's from what is
defined in the HTML spec.

To simplify this factoring, relocate Origin into LibURL.
2024-10-05 10:46:30 +02:00
Shannon Booth
e9dd05b2b5 LibWeb: Correct attributes on IDL interface 'operations'
This fixes four tests for the IDL harness for URL under:

https://wpt.live/url/idlharness.any.html
and https://wpt.live/url/idlharness.any.worker.html

But probably some tests in other places too :^)
2024-10-05 10:46:30 +02:00
Shannon Booth
fb2b78620d LibWeb: Factor out function to define the 'operations' on an interface 2024-10-05 10:46:30 +02:00
Totto16
abe1172d70 LibWeb: Make HTMLVideoElement part of CanvasImageSource union
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
2024-10-05 09:20:58 +02:00