Commit graph

34789 commits

Author SHA1 Message Date
Tim Ledbetter c61262684b LibWeb: Return empty string if object element data URL is invalid 2024-08-15 09:44:35 +02:00
Tim Ledbetter 4f7a4d9c57 LibWeb: Return empty string if image element currentSrc URL is invalid 2024-08-15 09:44:35 +02:00
Jamie Mansfield bab086694a LibWeb: Support SRI for import maps
See:
- https://github.com/whatwg/html/commit/b2fdca1
2024-08-14 21:06:25 +01:00
Jelle Raaijmakers 124779a376 LibWeb: Implement the "fire a focus event" spec
We weren't setting the focus event's composed flag and view field
correctly.
2024-08-14 20:53:33 +01:00
Jamie Mansfield 9c4e80a3ec LibWeb/SVG: Implement default_tab_index_value for a element
Another FIXME bites the dust :^)
2024-08-14 20:39:35 +01:00
Aliaksandr Kalenik 9c13644cde LibWeb: Simplify ViewportPaintable::refresh_clip_state()
Removes code that accounts for clip frame's own overflow clip, because
it happens anyway on a first iteration of a loop through containing
blocks chain.
2024-08-14 21:04:46 +02:00
Aliaksandr Kalenik f9f39477a4 LibWeb: Fix clip for boxes nested into a stacking context with transform
Modifies a loop that collects clip rectangles to stop once a box with a
CSS transform is encountered, as its clip still needs to be considered.
2024-08-14 21:04:46 +02:00
sideshowbarker 23da1752b5 LibWeb/Fetch: Set HTTP status code on cached responses
This change causes HTTP status codes to be set on cached HTTP responses.

Otherwise, without this change, no status codes at all are set on cached
HTTP responses — which causes all cached responses to default to being
loaded/served with a 200 status code. And as a result of that, if the
cached response is from a 30x redirect, then without this change, when
that cached 30x response is loaded, we don’t follow the redirect —
because we see a 200 status, rather than the expected/original 30x.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/863

Note that this change also reverts the temporary workaround added in
https://github.com/LadybirdBrowser/ladybird/commit/f735c464d3f
(https://github.com/LadybirdBrowser/ladybird/pull/899).
2024-08-14 14:49:04 +02:00
Timothy Flynn 50dfaf8581 LibJS: Disallow grouping separators in formatted duration fields
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/68b00f3
2024-08-14 11:48:08 +02:00
Timothy Flynn 72f61396cd LibJS: Correctly display a negative sign on negative durations
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/adfc4a1
2024-08-14 11:48:08 +02:00
Timothy Flynn 300f8d3dbb LibJS: Impose limits on a valid duration
This is a normative change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/1104cad
https://github.com/tc39/proposal-temporal/commit/45462c4

Although our Temporal implementation is wildly out of date, this AO and
the changes to it are relied on in Intl.DurationFormat.
2024-08-14 11:48:08 +02:00
Timothy Flynn 78328ab83c LibJS: Disallow U+2212 MINUS SIGN in time zone offset strings
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/e7f1e5d
2024-08-14 11:48:08 +02:00
Bastiaan van der Plaat 517b1a2690 LibWeb: Add autocomplete property 2024-08-13 22:53:55 +01:00
Jelle Raaijmakers e7984a7711 LibWeb: Check presence of WWW-Authenticate header in fetch response
If a HTTP 401 response we get does not contain a `WWW-Authenticate`
header, we should not trigger the logic to ask the user for credentials
and retry the request.

This part is hinted at in a TODO / 'Needs testing' remark in the spec
but needs to be fleshed out. Raised an upstream issue to do so:

  https://github.com/whatwg/fetch/issues/1766

This fixes login forms triggering an infinite fetch loop when providing
incorrect credentials.

Co-Authored-By: Victor Tran <vicr12345@gmail.com>
2024-08-13 16:01:48 +01:00
BenJilks 1537d589ca LibWeb: Add start and end values to text-align
The `start` and `end` value set the text alignment based on the computed
value of `direction`. The default value of `text-align` is now `start`
instead of `left`.
2024-08-13 15:19:51 +01:00
BenJilks 82989554ab LibWeb: Use reverse direction on flex containers with rtl direction
If a flex container has `direction: rtl` set, reverse the row direction.
2024-08-13 15:19:51 +01:00
Colin Reeder c6975a1680 LibWeb: Use base URL for link loading 2024-08-13 14:34:15 +01:00
Shannon Booth ff71d8f2c9 LibURL+LibWeb: Pass a mutable reference URL to URL parser
If given, the spec expects the input URL to be manipulated on the fly
as it is being parsed, and may ignore any errors thrown by the URL
parser.

Previously, we were not exactly following the specs assumption here
which resulted in us needed to make awkward copies of the URL in these
situations.

For most cases this is not an issue. But it does cause problems for
situations where URL parsing would result in a failure (which is
ignored by the caller), and the URL is _partially_ updated
while parsing.

Such a situation can occur when setting the host of an href alongside a
port number which is not valid. It is expected that this situation will
result in the host being updates - but not the port number.

Adjust the URL parser API so that it mutates the URL given (if any), and
adjust the callers accordingly.

Fixes two tests on https://wpt.live/url/url-setters-a-area.window.html
2024-08-13 14:14:34 +02:00
Colin Reeder 00f75648e5 LibWeb: Update stylesheet media value when changing link media attribute 2024-08-13 14:12:55 +02:00
Colin Reeder b92abe5c26 LibWeb: Avoid calling matches before evaluate 2024-08-13 14:12:55 +02:00
Timothy Flynn f7fcde7f60 LibTest: Define test expectation macros without copying the input values
Currently, the following test case will actually copy both `a` and `b`
when the test macro is expanded:

    ByteBuffer a = { some large buffer };
    ByteBuffer b = { some other buffer };
    EXPECT_EQ(a, b);

This patch redefines the expectation macros to avoid copying.
2024-08-13 14:11:05 +02:00
Bastiaan van der Plaat e0c8a14fab LibWeb: Fix HTMLFrameElement noresize obsolete property typo 2024-08-13 14:08:34 +02:00
Bastiaan van der Plaat 4712f53dd7 LibWeb: Add HTMLImageElement lowsrc obsolete property 2024-08-13 14:08:34 +02:00
Bastiaan van der Plaat d1fad9869b LibWeb: Add HTMLObjectElement codebase obsolete property 2024-08-13 14:08:34 +02:00
Jelle Raaijmakers fe933b2057 LibWeb: Implement HTMLMediaElement.preload attribute
This implements the `preload` reflected attribute. No actual preloading
is going on yet.
2024-08-13 14:08:03 +02:00
Jamie Mansfield 77a30bad9f LibWeb/HTML: Implement HTMLImageElement.longDesc 2024-08-13 11:49:19 +01:00
Jamie Mansfield 45c2b1f62c LibWeb/HTML: Implement HTMLIFrameElement.longDesc 2024-08-13 11:49:19 +01:00
Shannon Booth d755a83c09 LibWeb: Actually set empty serialized query to OptionalNone
Because the type returned by to_string is a String, _not_ an
Optional<String>, the following code:

if (serialized_query.is_empty())
    serialized_query = {};

Was achieving nothing at all! Make sure that the type is an
Optional<String> so that we're not just setting an empty string to an
empty string.
2024-08-12 23:01:29 +01:00
Shannon Booth 1ba6dbd86c LibWeb: Use a stable sort for searching URLSearchParams
Quick sort is not a stable sort. This meant we had a subtle issue
implementing this portion of the spec comment:

 > The relative order between name-value pairs with equal names must
 > be preserved.

Switch to insertion sort which is a stable sort, and properly handles
keys which are the same.

Fixes 8 tests on  https://wpt.live/url/urlsearchparams-sort.any.html
2024-08-12 23:01:29 +01:00
Shannon Booth df4739d7ce LibWeb: Don't propogate small OOMs from URLSearchParams
Made easier now that URL percent encode after encoding is also not
throwing any errors. This simplfies a bunch of error handling.
2024-08-12 23:01:29 +01:00
Shannon Booth 4bb211ba88 LibURL: Make percent_encode_after_encoding infallible 2024-08-12 23:01:29 +01:00
Shannon Booth 264b5160c2 LibWeb: Implement value argument of URLSearchParams.has 2024-08-12 23:01:29 +01:00
Shannon Booth 5637dc43b2 LibWeb: Implement value argument of URLSearchParams.delete 2024-08-12 23:01:29 +01:00
Gasim Gasimzada 4a42c97f4d LibJS: Set empty prototype for console object 2024-08-12 17:21:01 +01:00
Aliaksandr Kalenik d0da377767 LibWeb: Make AddClipRect display list item account for scroll offset
Before this change AddClipRect was a "special" because it didn't respect
scroll frame offset and was meant to be recorded using viewport-relative
coordinates. The motivation behind this was to record a "final" clip
rectangle computed by intersecting all clip rectangles used by a clip
frame. The disadvantage of this approach is that it blocks us from
implementing an optimisation to reuse display list if the only change is
in the scroll offset, because any scroll offset change leads to
invalidating all AddClipRect items within a list.

This change aligns AddClipRect with the rest of display list items by
making it account for scroll frame offset. It required discontinuing
the recording of the intersection of all clip rectangles within a clip
frame and instead producing an AddClipRect for each of them.

A nice side effect is the removal of code that shifts clip rectangle by
`enclosing_scroll_offset()` in a bunch of places, because now it happens
automatically in `DisplayList::apply_scroll_offsets()`.
2024-08-12 18:20:13 +02:00
Shannon Booth 0b864bef60 LibTextCodec: Implement UTF8Decoder::to_utf8 using AK::String
String::from_utf8_with_replacement_character is equivalent to
https://encoding.spec.whatwg.org/#utf-8-decode from the encoding spec,
so we can simply call through to it.
2024-08-12 06:38:58 -04:00
Shannon Booth b3bf5c4ea8 AK: Add BOM handling to String::from_utf8_with_replacement_character 2024-08-12 06:38:58 -04:00
Maks Verver c68b8b5bda RequestServer: Fix compiling with -DREQUESTSERVER_DEBUG=ON 2024-08-12 02:27:48 +02:00
Jamie Mansfield 17c1e99ce4 LibWeb: Use keepalive maximum size in NavigatorBeacon
This is defined as 64 KiB in the fetch spec.

See:
 - https://wpt.live/beacon/beacon-basic.https.window.html
2024-08-11 20:07:10 +01:00
Jamie Mansfield 35047de1d8 LibWeb/Fetch: Add a constant for the keepalive maximum size 2024-08-11 20:07:10 +01:00
Gasim Gasimzada c5b8e75204 LibJS: Set configurable toStringTag property for console 2024-08-11 20:06:27 +01:00
Aliaksandr Kalenik dd8c693725 LibWeb: Unify scroll handling between viewport and scrollable boxes
This change causes the viewport to be treated as a "scroll frame,"
similar to how it already works for boxes with "overflow: scroll."
This means that, instead of encoding the viewport translation into a
display list, the items will be assigned the scroll frame id of the
viewport and then shifted by the scroll offset before execution. In the
future it will allow us to reuse a display list for repainting if only
scroll offset has changed.

As a side effect, it also removes the need for special handling of
"position: fixed" because compensating for the viewport offset while
painting or hit-testing is no longer necessary. Instead, anything
contained within a "position: fixed" element is simply not assigned
a scroll frame id, which means it is not shifted by the scroll offset.
2024-08-11 07:53:21 +02:00
Tim Ledbetter 5b09430c5e WebContent: Actually start WebDriver timeout timers
The timers added previously in #1021 had no effect, as they were never
started.
2024-08-10 23:18:08 +01:00
Alisson Lauffer d38b28b57b LibWeb: Replace "+" in value with a space while decoding search params 2024-08-10 10:39:43 +02:00
Shannon Booth 9c72fc9642 LibWeb: Actually run UTF-8 decode without BOM
This fixes a crash using URLSearchParams when provided a percent encoded
string which does not percent decode to valid UTF-8.

Fixes a crash running https://wpt.live/url/urlencoded-parser.any.html
2024-08-10 10:39:43 +02:00
Shannon Booth 84a09476ba LibURL: Update spec comment for validation error in authority state
See: https://github.com/whatwg/url/commit/3e8cd02bb
2024-08-10 10:39:43 +02:00
Shannon Booth 84a7fead0e LibURL: Make percent_encode return a String
This simplifies a bunch of places which were needing to error check and
convert from a ByteString to String.
2024-08-10 10:39:43 +02:00
Diego Frias c58665332e LibWasm: Ensure correct section ordering when parsing binary modules
There are (currently) no spec-tests ensuring that section ordering is
enforced, but it _is_ a part of the spec. A pull request to add this to
the specification testsuite has been opened at WebAssembly/spec#1775.
2024-08-10 10:39:10 +02:00
Aliaksandr Kalenik ea8d0304e9 LibWeb: Create clip and scroll frame trees separately for each navigable
While introducing clip and scroll frame trees, I made a mistake by
assuming that the paintable tree includes boxes from nested navigables.
Therefore, this comment in the code was incorrect, and clip/scroll
frames were simply not assigned for iframes:
// NOTE: We only need to refresh the scroll state for traversables
//       because they are responsible for tracking the state of all
//       nested navigables.

As a result, anything with "overflow: scroll" is currently not
scrollable inside an iframe

This change fixes that by ensuring clip and scroll frames are assigned
and refreshed for each navigable. To achieve this, I had to modify the
display list building process to record a separate display list for each
navigable. This is necessary because scroll frame ids are local to a
navigable, making it impossible to call
`DisplayList::apply_scroll_offsets()` on a display list that contains
ids from multiple navigables.
2024-08-10 10:38:12 +02:00
Tim Ledbetter 1b2f35c3af WebContent: Add timeouts to WebDriver window state modification methods 2024-08-10 10:37:43 +02:00