Commit graph

66045 commits

Author SHA1 Message Date
sideshowbarker
50e7e9f58d LibWeb: Assign “dir”, “dd”, “dt” default ARIA roles per-spec
Also, import http://wpt.live/html-aam/dir-role.tentative.html (which
provides test/regression coverage for the “dir” change).
2024-12-12 05:13:45 -08:00
sideshowbarker
ccbc436e85 LibWeb: Support the “image” synonym for the “img” ARIA role
Additionally: For “img” elements with empty “alt” attributes, change the
default role to the newer, preferred “none” synonym for the older
“presentation” role; import https://wpt.fyi/results/html-aam/roles.html
(which provides test/regression coverage for these changes).
2024-12-12 05:13:45 -08:00
sideshowbarker
6e24f23aa0 LibWeb: Add support for the “mark” ARIA role 2024-12-12 05:13:45 -08:00
sideshowbarker
96540e9f89 LibWeb: Add support for the “suggestion” ARIA role 2024-12-12 08:53:20 +00:00
Timothy Flynn
68164aa7ec LibWeb: Run the object representation task when the active state changes
Currently, the following JS snippet will hang indefinitely:

    new DOMParser().parseFromString("<object>", "text/html");

Because the document into which the object is inserted is not active. So
the task queued to run the representation steps will never run.

This patch implements the spec steps to rerun the representation steps
when the active state changes, and avoid the hang when the object is
created in an inactive document.
2024-12-11 17:38:31 -07:00
Timothy Flynn
a2419b5f4e LibWeb: Add a document observer to be notified upon becoming active 2024-12-11 17:38:31 -07:00
Timothy Flynn
9a62e33517 LibWeb: Protect document observers from GC during observer invocation
We currently (sometimes) copy the observer map to a vector for iteration
to ensure we are not iterating over the map if the callback happens to
remove the observer. But that list was not protected from GC.

This patch ensures we protect that list, and makes all document observer
notifiers protected from removal during iteration.
2024-12-11 17:38:31 -07:00
sideshowbarker
afca902ea9 Docs: Explain how to do Debug builds without optimizations on
This change updates the (advanced) build docs to explain how to do a
Debug build with the CXX `-O0` option set — which tells the compiler to
build with no optimizations at all.

Otherwise, Debug builds use the `-Og` option — which, when trying to
check frame variables in a debugger can result in an error of this form:

> error: Couldn't look up symbols: __ZN2AK6Detail10StringBaseD2Ev
> Hint: The expression tried to call a function that is not present in
> the target, perhaps because it was optimized out by
> the compiler.
2024-12-11 17:31:52 -07:00
sideshowbarker
e49fe384d1 LibWeb: Align default “th” and “td” roles with HTML-AAM spec and tests
This change aligns the default roles for “th” and “td” elements with the
requirements in the HTML-AAM spec, and with the corresponding WPT tests
at https://wpt.fyi/results/html-aam/table-roles.html, and with the
behavior in other engines.

Otherwise, without this change, the default role values for “th” and
“td” elements in some cases don’t match the behavior in other engines,
and don’t match the expected results for the corresponding WPT tests.
2024-12-11 16:55:07 -07:00
sideshowbarker
2d638485a8 LibWeb: Assign “orphaned” li elements the default ARIA role “none”
This change makes Ladybird conform to the current requirements at
https://w3c.github.io/core-aam/#roleMappingComputedRole in the “Core
Accessibility API Mappings” spec for the case of “orphaned” li elements;
that is, any li element which doesn’t have a role=list ancestor.

The core-aam spec requires that in such cases, the li element must not
be assigned the “listitem” role but instead must be treated as if it had
no role at all.
2024-12-11 16:43:55 -07:00
Feng Yu
824e91ffdb LibWeb: Ensure Headers API can handle non-ascii characters
This patch ensure Headers object's associated header list
is ISO-8859-1 encoded when set using `Infra::isomorphic_encode`,
and correctly decoded using `Infra::isomorphic_decode`.

Follow-up of https://github.com/LadybirdBrowser/ladybird/pull/1893
2024-12-11 16:40:36 -07:00
Lucas CHOLLET
5e62f548db LibWeb/CSS: Serialize CSSColor without relying on RGB
This gives us 140 subtests pass in:
css/css-color/parsing/color-valid-color-function.html
2024-12-11 16:37:22 -07:00
Feng Yu
9c243caac4 LibWeb: Add statusText validation for Response constructor
Implemented validation to ensure `statusText` matches the
`reason-phrase` token production.

This change fixes a WPT subtest which I have imported.
2024-12-11 16:34:10 -07:00
Tim Ledbetter
93a1c45eb2 Meta: Don't halt if importing a test fails in WPT.sh 2024-12-11 16:30:20 -07:00
Tim Ledbetter
cb8a1f6bb6 Meta: Add the ability to import entire test directories with WPT.sh
This uses the `WPT.sh list-tests` command to find which tests are in
each given path.
2024-12-11 16:30:20 -07:00
Tim Ledbetter
a4f1838798 Meta: Add a list-tests command to WPT.sh
This outputs a list of all the tests that would be run in the given
test directories.
2024-12-11 16:30:20 -07:00
Pavel Shliak
d5cdda0b40 LibWeb: Load external scripts in SVG 2024-12-11 16:29:42 -07:00
Lucas CHOLLET
dd283768a8 LibWeb/CSS: Allow none values in the color() function 2024-12-11 22:38:14 +00:00
Simek
e7ef8da7f3 LibWeb/ARIA: Add missing structure roles 2024-12-11 10:32:40 -08:00
Jelle Raaijmakers
d14fd8a6c8 LibWeb: Update spec steps in Selection
Resolves two FIXMEs in `::collapse()` and `::select_all_children()`.
2024-12-11 19:11:13 +01:00
Timothy Flynn
943ec820fc LibWeb: Avoid dereferencing an empty optional URL
Here, "null" means the empty optional. We don't need to also check if
the URL is valid; the url will be null if it was originally invalid.
2024-12-11 09:33:46 -08:00
Timothy Flynn
0bc55424c8 LibJS: Fix variable reference in CreateDateTimeFormat
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/8acd353
2024-12-11 08:43:54 -08:00
Timothy Flynn
002b0ea7c7 LibJS: Remove dead code from ZonedDateTime.prototype.toLocaleString
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/065cf94
2024-12-11 08:43:54 -08:00
Timothy Flynn
b9ac4557d6 LibJS: Change variable name of parsed time zone offset
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/30d17d3
2024-12-11 08:43:54 -08:00
Shannon Booth
99073c0561 LibWeb: Move ad hoc CallbackType helper method to CallbackType header
Abstract operations of a stream does not seem like the correct home for
this function.
2024-12-11 15:11:21 +01:00
Shannon Booth
93f258deb7 LibWeb/Streams: Do not expose some non-standard functions in header
These are non-standard and only needed internally as implementation
details in the implementation of AbstractOperations, so let's keep them
at a file-local level.
2024-12-11 15:11:21 +01:00
Shannon Booth
19bbfb023a LibWeb/Streams: Move "set up transform stream" to TransformStream
This is not marked as an AO in the spec, and is a publically exported
API exposed on TransformStream.
2024-12-11 15:11:21 +01:00
Shannon Booth
3f572d9ab7 LibWeb/Streams: Move ReadableStream functions out of AbstractOperations
These are not defined in the abstract operations section of the spec and
are the publically exported Stream APIs exposed on ReadableStream.
2024-12-11 15:11:21 +01:00
Shannon Booth
c6d0f87bb7 LibWeb/Streams: Put algorithm definitions in a separate header file
To solve a future cyclic dependency problem.
2024-12-11 15:11:21 +01:00
Shannon Booth
f110edebd1 LibWeb/HTML: Encoding parse a URL when setting a href URL
Fixes many WPT encoding regression tests which regressed in
fe891727dc.
2024-12-11 09:48:17 +01:00
Tim Ledbetter
a536ee6f31 Tests: Add vendor-specific testdriver send_keys() function
This uses the `Internals.sendText()` function.
2024-12-10 17:16:29 -08:00
Tim Ledbetter
1bd10a5443 Tests: Add vendor-specific testdriver click() function
This uses `Internals.click()` which doesn't do as much as the
equivalent WebDriver method, but should be enough to satify most tests
that use it.
2024-12-10 17:16:29 -08:00
Tim Ledbetter
1ff556a2bd Tests: Move Ladybird specific testdriver code to testdriver-vendor.js 2024-12-10 17:16:29 -08:00
Shannon Booth
4b069344e0 LibWeb/HTML: Fix crash in window open steps on empty URL string 2024-12-10 17:16:07 -08:00
rmg-x
e4fb25bf63 LibGfx: Redirect PNG errors and warnings to our own logging functions
Before, libpng would use its own internal logging mechanism to print
non-fatal errors and warnings to stdout/stderr. This made it confusing
when trying to search the Ladybird codebase for those messages as they
didn't exist.

This commit uses `png_set_error_fn` from libpng to redirect those
messages to our own custom logging functions instead.
2024-12-10 11:58:58 -07:00
Timothy Flynn
d835a00bee LibWeb: Use Fetch to retrieve HTMLObjectElement data URLs
This eliminates the use of ResourceLoader in HTMLObjectElement. The spec
steps around fetching have been slightly updated since we've last looked
at this, so those are updated here.

Regarding the text test change: we cannot rely on the data: URL being
fetched synchronously. It will occur on a deferred task now. This does
match the behavior of other browsers, as they also will not have run the
fallback representation steps as of DOMContentLoaded.
2024-12-10 10:37:01 -08:00
Timothy Flynn
fe891727dc LibWeb: Use correct URL parsing methods throughout LibWeb
There are essentially 3 URL parsing AOs defined by the spec:
1. Parse a URL
2. Encoding parse a URL
3. Encoding parse a URL and serialize the result

Further, these are replicated between the Document and the ESO.

This patch defines these methods in accordance with the spec and updates
existing users to invoke the correct method. In places where the correct
method is ambiguous, we use the encoding parser to preserve existing ad-
hoc behavior.
2024-12-10 10:37:01 -08:00
mkljczk
0b2fe008a3 Docs: Add perl-lib to build prerequisites for Fedora 2024-12-10 10:36:29 -08:00
Jelle Raaijmakers
495006ddb5 LibWeb: Implement document.execCommand('insertLinebreak') 2024-12-10 19:34:38 +01:00
Tim Ledbetter
ae53059816 Tests: Don't display imported WPT test output if browser is headless
Previously, imported WPT tests didn't display any output if the
internals object was exposed. This change adds the condition that the
browser must also be running headlessly for test output to not be
displayed.
2024-12-10 10:31:47 -08:00
Tim Ledbetter
a44b18236c LibWeb: Add an Internals.headless attribute
This returns true if the browser is running in headless mode.
2024-12-10 10:31:47 -08:00
Tim Ledbetter
e764df15eb LibWebView+WebContent: Inform WebContent process if browser is headless 2024-12-10 10:31:47 -08:00
Timothy Flynn
520bf6c9be LibWeb: Return a better error message for invalid byte strings
We are currently returning LibJS's invalid code point message, but not
formatting it with the bad value. So we get something like:

    Unhandled JavaScript exception: [TypeError] Invalid code point {},
    must be an integer no less than 0 and no greater than 0x10FFFF

So not only is the error unformatted, but it's inaccurate; in this case,
the byte cannot be larger than 255.
2024-12-10 10:30:14 -08:00
Simek
a64432ec13 LibWeb/ARIA: Add missing menuitemradio widget role 2024-12-10 07:41:10 -08:00
Luke Wilde
d2acf32aae LibWeb: Register Wasm memory grow hook in constructor of Memory objects
Previously it would only register the hook for JavaScript constructed
Memory objects. This allows Ruffle to load again.
2024-12-10 15:54:20 +01:00
Feng Yu
f2eaf3381f LibWeb: Throw TypeError for new Headers(null)
The WebIDL for the `Headers` constructor specifies that the `init`
parameter is optional and must be of type `HeadersInit`. While the
parameter can be omitted (or explicitly set to `undefined`),
`null` is not a valid value.

This change fixes at least 2 "Create headers with null should throw"
WPT subtests which I have imported in this patch.
2024-12-10 06:46:31 -08:00
Luke Wilde
023c3aa5b0 LibWeb: Respect subarrays in Crypto#getRandomBytes
It is the responsibility of code that deals with TypedArrays to apply
the byte offset and byte length. Not doing this caused Unity Web to
crash, as they call getRandomValues with views into their full main
memory. Previously, it would fill their entire memory of about 33.5 MB
with random bytes.
2024-12-10 06:44:00 -08:00
Jelle Raaijmakers
30ec8c1d4d LibWeb: Implement "delete the selection" for the editing API 2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
fd949ee3dd LibWeb: Only set selection focus if an associated DOM node was found
The relation from a paintable to a DOM node is not always set.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
15e3db5932 LibWeb: Add internals.mouseDown(x, y)
This triggers a mouse button press without the up event, allowing us to
e.g. simulate a selection by moving the mouse while keeping the button
depressed.
2024-12-10 14:54:19 +01:00