Commit Graph

814 Commits

Author SHA1 Message Date
Tim Ledbetter
107ea0c79a LibWeb: Use [URL] extended attribute for HTMLVideoElement.poster
(cherry picked from commit 67d05b0104dab928fc5334fe63e46cd62d1e4e22)
2024-11-26 22:37:15 -05:00
Glenn Skrzypczak
4fce2cffb2 LibWeb/HTML: Implement cite attribute according to spec
Implements the cite attribute of `q`, `blockqoute`, `ins` and `del`
elements according to spec by returning a valid URL.

(cherry picked from commit 74645facae366d62ee4c44bd4a96d02df345a5d4)
2024-11-26 22:37:15 -05:00
Pavel Shliak
fcb45f4893 LibWeb: Fix extra validation for EasingStyleValue intervals
(cherry picked from commit b342758dbf8d1138353db89708964e75b9128400)
2024-11-25 12:19:48 -05:00
Tim Ledbetter
7e288e80fe LibWeb: Allow FormData entry list to be mutated within a FormDataEvent
Previously, the list was copied when constructing the FormData object,
then the original list was passed to the event, meaning any changes to
the list that happened within the event would not be reflected outside
of it.

(cherry picked from commit ea0e434d1d6b464ab0a56c4b7150950be78ae7d3)
2024-11-25 12:19:33 -05:00
Tim Ledbetter
6bf08818be LibWeb: Don't crash when parsing large floating point number values
Previously, attempting to parse a floating point number with an integer
part larger than `(2 ^ 31) - 1` would cause the browser to crash. We now
avoid this by converting the integer part of the number to a `double`
rather than an `i32`.

(cherry picked from commit 21a32e4b6dc594c2fe8dd3ee11c829c250a103ad)
2024-11-25 12:19:33 -05:00
Gingeh
be681da6a7 LibWeb: Use substrings instead of pointers when parsing unicode ranges
Fixes a segfault when parsing a wildcard-only unicode range

(cherry picked from commit a4b38dda5611e87987c855de8a6e06aa0351bd1b)
2024-11-25 09:21:14 -05:00
Sam Atkins
b6755e8189 LibWeb/CSS: Correct matching of calc() against <number-percentage>
This seems to have vanished from the spec, but in any case, we still
need it. Without this change we erroneously thought that calculations
that match <percentage> did not match <number-percentage>.

(cherry picked from commit 760943d584587899d2ba0390cad20797001e1b96)
2024-11-25 09:21:14 -05:00
Khaled Lakehal
438b568256 LibWeb: Implement HTML spec-compliant rules for floating-point parsing
Attempt to implement HTML specs for parsing floating-point number
https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values

(cherry picked from commit 14e1e55319b7c128d88f1b1f2752ffc9e34858f5;
amended to remove `std::` qualifiers))
2024-11-25 09:21:14 -05:00
Alan Kemp
ae8d143338 LibWeb: Pageshow event dispatched by the user agent should be trusted
The spec says that "isTrusted is a convenience that indicates whether
an event is dispatched by the user agent (as opposed to using
dispatchEvent())"

But when dispatching a pageshow event the flag was incorrectly set
to false.

This fixes https://wpt.fyi/results/html/syntax/parsing/the-end.html

(cherry picked from commit d2fbbabd893d84a6b8b68a8bc8034e4d6dc4da4a)
2024-11-25 09:21:14 -05:00
samu698
20a830ab66 LibWeb: Fixed IDL for HTMLInputElement
Use Enumerated for the form{Enctype, Method} attributes

(cherry picked from commit d08d3053999619aa90469c07ee758cd036298a2b)
2024-11-25 09:21:14 -05:00
samu698
da90fb81a6 LibWeb: Fixed IDL for HTMLButtonElement
Use Enumerated for the form{Enctype, Method} attributes

(cherry picked from commit ab04f6d422a0a328f2ded1e3d5bbcf614c95f07a)
2024-11-25 09:21:14 -05:00
samu698
31cc24feed LibWeb: Use correct IDL for HTTPFormElement's method attribute
Removed the custom getter and updated the idl so that the attribute
is Reflected and Enumerated.

(cherry picked from commit 68924827551fc3169c1b9b59c0d7e8bc999a390c)
2024-11-25 09:21:14 -05:00
thislooksfun
271f3c9bdd LibWeb/CSS: Evaluate media queries in shadow roots
This fixes a rendering issue on https://prodengi.kz/ that someone on
Discord reported. :^)

(cherry picked from commit 0b775da7c72a85c099f35d8caf2e7b66721a4483)
2024-11-25 08:50:54 -05:00
David Smith
2acb11dfc5 LibWeb: Layout all math elements using InternalDummy context
Always create a new formatting context for <math> elements. Previously
that didn't happen if they only had inline children, e.g. mtable.

This fixes a crash in the WPT MathML test
mathml/crashtests/children-with-negative-block-sizes.html

(cherry picked from commit e7c209820d29cb422668ac0b142d030080aa7767)
2024-11-25 08:50:54 -05:00
ronak69
72c61c0cf0 LibWeb: Only return HTML elements from getElementsByName()
Fixes two WPT tests:
document.getElementsByName-namespace-xhtml.xhtml and
document.getElementsByName-namespace.html

(cherry picked from commit 917a2a3c8625b1d78d3f8d597f32a304d5996740)
2024-11-25 08:50:54 -05:00
Taylor Mapes
06d58ae78c LibWeb: Implement CanvasRenderingContext2D.createImageData(ImageData)
Fixes at least one WPT test.
https://wpt.live/html/canvas/element/pixel-manipulation/2d.imageData.create1.basic.html

(cherry picked from commit 0522e514a92e6534311a33890780b877b6353979)
2024-11-25 08:50:54 -05:00
Cory Virok
e5339b7e0b LibWeb: Implemented the CanvasRenderingContext2D::createImageData() spec
The only real change here is to use the absolute magnitude of the
width/height when creating the ImageData.

This fixes the crash on this WPT test:
https://wpt.fyi/results/html/canvas/element/pixel-manipulation/2d.imageData.create2.double.html?label=master&product=ladybird

(cherry picked from commit 560c3824b95b3130f05dbceeebff23fbfc7f69ad)
2024-11-25 08:50:54 -05:00
John Diamond
754c287b45 LibWeb: Use correct boundary point comparison in Selection.extend
Previously Selection.extend() used only the relative node order to decide which
direction to extend the selection. This leads to incorrect behaviour if
both the existing and new boundary points are within the same DOM node
and the selection direction is reversed.

This change fixes all the failing subtests in the WPT extend-* test
suites.

(cherry picked from commit 18ade57ae96da05c845582ab03b588c55c1e6633)
2024-11-25 08:50:54 -05:00
John Diamond
f22b32652e LibWeb: Compare anchor/focus offsets in selection.isCollapsed
The "isCollapsed" attribute on a selection must "return true if and only
if the anchor and focus are the same".

In addition to checking that the anchor and focus belonged to the same
DOM node, we now also check that they refer to the same position within
the node.

With this change Ladybird passes all the subtests in the "isCollapsed"
WPT suite.

https://wpt.live/selection/isCollapsed.html
(cherry picked from commit fadb14d31d0d3127e80121ac695fe839908efaa1)
2024-11-25 08:50:54 -05:00
Fernando Kiotheka
a269e28cfa LibWeb: Implement activation behavior on input[type=reset]
This fixes WPT html/semantics/forms/resetting-a-form/reset-form.html.
I added a test based on the WPT test, but simpler.

(cherry picked from commit caf74e7ed69c6f64fc2f770d03fe61bc60cdc08b)
2024-11-25 08:50:54 -05:00
Shannon Booth
d1c0fa3245 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
  * 💥

(cherry picked from commit 30377e6e3500049c5442fac9d242d3b795861116)
2024-11-25 08:50:54 -05:00
scorpion-26
7feff7ff87 LibWeb: Preserve order of HTMLCollection property names
The supported property names should be ordered in "tree order", though
m_cached_name_to_element_mappings doesn't preserve this ordering, which
breaks Object.getOwnPropertyNames.

Fixes at least the following WPT tests:
 - https://wpt.live/dom/nodes/Element-children.html
 - https://wpt.live/dom/collections/HTMLCollection-live-mutations.window.html
 - https://wpt.live/dom/collections/HTMLCollection-supported-property-names.html

(cherry picked from commit d00adabc3c13f18ca46e9c8ab329551fdc3fdef3)
2024-11-25 08:50:54 -05:00
Andreas Kling
48d994839c LibWeb: Don't swallow args when forwarding cross-origin WindowProxy call
Fixes at least one WPT test that was previously timing out:
- html/semantics/document-metadata/the-base-element/base_target_does_not_affect_iframe_src_navigation.html

(cherry picked from commit 0b403d30d765ab8e5db3b7443ebeca7f85c3acf2)
2024-11-25 08:50:54 -05:00
Timothy Flynn
1322fed4c8 LibWeb+WebContent: Do not include DOM HTML in text test expectations
For example, in the following abbreviated test HTML:

    <span>some text</span>
    <script>println("whf")</script>

We would have to craft the expectation file to include the "some text"
segment, usually with some leading whitespace. This is a bit annoying,
and makes it difficult to manually craft expectation files.

So instead of comparing the expectation against the entire DOM inner
text, we now send the inner text of just the <pre> element containing
the test output when we invoke `internals.signalTextTestIsDone`.

(cherry picked from commit bf668696de9a68bbcd6adfeaac809a475da015dc;
amended a bit but not as much as one might think -- see PR for details)
2024-11-24 22:42:15 -05:00
Timothy Flynn
6bc2b81a9f LibWeb: Wait for the correct condition in Stream tests
We were signaling that the test is complete too early in some Stream
tests.

(cherry picked from commit f3f7f77dbc5a32f19069ef347b3ce5dc36525351)
2024-11-24 22:42:15 -05:00
Timothy Flynn
0446c98053 LibWeb: Convert some sync tests to be async
The events tested here are decidedly async. We also can't really write
sync tests of the form "test(async () => {})". Nothing will await the
async callback.

(cherry picked from commit c9cbaeb59d6f699b33bf3924688987b3ca917fee)
2024-11-24 22:42:15 -05:00
Timothy Flynn
8b4b8d914c LibWeb: Port some manually async tests to use asyncTest
These tests were mostly async tests written in a manual way. This ports
them to use the standard asyncTest() infrastructure.

This is mostly just to reduce calls to internals.signalTextTestIsDone,
which will have a required parameter in an upcoming test.

(cherry picked from commit 96082d6ae127832eb9b644d2abee892284317b6a)
2024-11-24 22:42:15 -05:00
Timothy Flynn
6cbfce87bd LibWeb+LibWebView: Set the default path for invalid cookie Path values
We were missing this spec step when parsing the Path attribute.

(cherry picked from commit e74d2b17620b1d68d66d51a13831ee1657154a1c)
2024-11-24 21:30:22 -05:00
Timothy Flynn
8ada1255c3 LibWeb: Support cookie Max-Age attributes that exceed i64 limits
Attributes have a max value length of 1024. So we theoretically need to
support values in the range -${"9".repeat(1023)} to ${"9".repeat(1024)}.
These obviously do not fit in an i64, so we were previously failing to
parse the attribute.

We will now cap the parsed value to the numeric limits of an i64, after
ensuring that the attribute value is indeed a number.

(cherry picked from commit ba1189cd1c47ab0593e0c3d7eee85e7aafc3462d)
2024-11-24 21:30:22 -05:00
Timothy Flynn
bd845f87a1 LibWeb+LibWebView: Implement the latest cookie draft RFC
We currently implement the official cookie RFC, which was last updated
in 2011. Unfortunately, web reality conflicts with the RFC. For example,
all of the major browsers allow nameless cookies, which the RFC forbids.

There has since been draft versions of the RFC published to address such
issues. This patch implements the latest draft.

Major differences include:
* Allowing nameless or valueless (but not both) cookies
* Formal cookie length limits
* Formal same-site rules (not fully implemented here)
* More rules around cookie domains

(cherry picked from commit fce003a8f581a49d1c6e6472e33b8250052530db)
2024-11-24 17:29:26 -05:00
Bastian Neumann
f3f4bc0cc9 LibWeb: Test for parseFromString parsererror
This tests if the parsed xml string gets tagged with a parsererror.

(cherry picked from commit 64308c8c065206e129a9642b73bee813239a916b)
2024-11-24 10:27:54 -05:00
Timothy Flynn
1d11a0b1a7 LibWeb: Begin implementing FontFaceSet.prototype.load
This implementation is incomplete in that we do not fully implement the
steps to match the given font against the fonts in the set.

This is used by fonts.google.com to load the fonts used for sample text.

(cherry picked from commit 9bdf2e928c448585a6349bef36d7cb98ccc0607b)
2024-11-24 10:27:41 -05:00
stelar7
aa56fce597 LibWeb: Implement RSAOAEP.encrypt()
(cherry picked from commit 48bd094712189c5235d33c976176bd8c9a23e682)
2024-11-24 10:27:27 -05:00
Andrew Kaster
363edceabe LibWeb: Add most of ServiceWorker Update algorithm
This misses the final, most important part of actually creating a
service worker object and sending the script over to it in a WebWorker
process.

(cherry picked from commit 85541f1e763f2db63a235f57a29026331138a29e)
2024-11-24 10:27:27 -05:00
Luke Wilde
ca09ed4b37 LibWeb: Make CSSStyleDeclaration a legacy platform object with indices
CSSStyleDeclaration has an indexed property getter, which returns
properties associated with the object in the order they were specified
in.

(cherry picked from commit a94282e0e8dd344bcf94c1d098378bd46151ce47)
2024-11-23 22:07:22 -05:00
Luke Wilde
772be9dec0 LibWeb: Generate IDL attributes for all supported CSS properties
The CSSOM spec tells us to potentially add up to three different IDL
attributes to CSSStyleDeclaration for every CSS property we support:
- A camelCased attribute, where a dash indicates the next character
  should be uppercase
- A camelCased attribute for every -webkit- prefixed property, with the
  first letter always being lowercase
- A dashed-attribute for every property with a dash in it.

Additionally, every attribute must have the CEReactions and
LegacyNullToEmptyString extended attributes specified on it.

Since we specify every property we support with Properties.json, we can
use that file to generate the IDL file and it's implementation.

We import it from the Build directory with the help of multiple import
base paths. Then, we add it to CSSStyleDeclaration via the mixin
functionality and inheriting the generated class in
CSSStyleDeclaration.

(cherry picked from commit aacf9b08ed8c4286c84145b52fa70f399ed0bdff;
amended to fix tiny conflict in libweb_generators.cmake, and to change
the default value of all gap-related properties from 'auto' to 'normal'
since serenity does not yet have LadybirdBrowser/ladybird#2253 and
cherry-picking that has a pretty long dependency tree. It's easy to
update the test once that is cherry-picked)
2024-11-23 22:07:22 -05:00
Luke Wilde
8ff9aa177f LibWeb: Fix OBOE in bounds check of ResolvedCSSStyleDeclaration#item
Without this, it would return "(invalid CSS::PropertyID)" when
requesting item(decl.length).

(cherry picked from commit 5aacb053a3fa0cf0e2a825c63dd3a4ebd916eda4)
2024-11-23 22:07:22 -05:00
Aliaksandr Kalenik
ff4c99ec0a Meta+Tests: Substitute Ahem font path in import-wpt-test.py
(cherry picked from commit 3833049fc8680d4e6349511cf566f27a25225ada)
2024-11-21 22:16:48 -05:00
Andreas Kling
57b3a20bd0 Tests: Import LICENSE.md from WPT
(cherry picked from commit d78c81a9fdcd065c1a4905bd5f0176c3cb640d9e)
2024-11-21 22:16:48 -05:00
Shannon Booth
2e8585b193 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.

(cherry picked from commit 088b659abd123e0462bca7a6a9b534c0d89c668a;
amended to add leading whitespace to expectation due to serenity not
yet having LadybirdBrowser/ladybird#1603)
2024-11-21 22:16:27 -05:00
Shannon Booth
8c3cb23384 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

(cherry picked from commit 501f92b54eee7bcf7b60621aa4238fcbdc610d99;
amended to add leading whitespace to expectation due to serenity not
yet having LadybirdBrowser/ladybird#1603)
2024-11-21 22:16:27 -05:00
Shannon Booth
d6d8ce68c8 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 :^)

(cherry picked from commit e9dd05b2b52aa6363b5c5e2e90099b8e1c28e868)
2024-11-21 22:16:27 -05:00
Shannon Booth
65f4aae1d8 LibURL+Everywhere: Only percent decode URL paths when actually needed
Web specs do not return through javascript percent decoded URL path
components - but we were doing this in a number of places due to the
default behaviour of URL::serialize_path.

Since percent encoded URL paths may not contain valid UTF-8 - this was
resulting in us crashing in these places.

For example - on an HTMLAnchorElement when retrieving the pathname for
the URL of:

http://ladybird.org/foo%C2%91%91

To fix this make the URL class only return the percent encoded
serialized path, matching the URL spec. When the decoded path is
required instead explicitly call URL::percent_decode.

This fixes a crash running WPT URL tests for the anchor element on:

https://wpt.live/url/a-element.html
(cherry picked from commit cc557323326ba55514ef2a8a6e0efd7f09330f06;
amended heavily to call `URL::percent_decode()` on all results of
`url.serialize_path()` in the rest of serenity -- except in
LibGemini, where it looked incorrect, and in LibHTTP, where
LadybirdBrowser/ladybird#983 will add it.)
2024-11-21 17:47:14 -05:00
Andreas Kling
a65b5cb135 LibWeb: Mark image elements for layout before firing their load event
This removes a long-standing source of flakiness seen for example in
WPT's /referrer-policy/ tests.

(cherry picked from commit 063cd68bf472061ec35cf9b8970aa6e614632c9b)
2024-11-20 22:51:34 -05:00
Luke Wilde
27c1ce5299 LibWeb: Make default document readiness be "complete"
This is required by mini Cloudflare invisible challenges, as it will
only run if the readyState is not "loading". If it is "loading", then
it waits for readystatechange to check that it's not "loading" anymore.

Initial about:blank iframes do not go through the full navigation and
thus don't go through HTMLParser::the_end, which sets the ready state
to something other than "loading". Therefore, the challenge would never
run, as readyState would never change.

Seen on https://discord.com/login

(cherry picked from commit f638f84185938c74a47f5691e8d7c5e1d4dca07c)
2024-11-20 22:51:34 -05:00
Tim Ledbetter
4dd2c42239 LibWeb: Use correct specifier to pad font language override value
(cherry picked from commit 7fe110225b7de2177e3463424ab437ffd9d7d5cd)
2024-11-20 22:51:34 -05:00
Psychpsyo
459f13ee74 LibWeb: Prevent checkboxes from firing change events when losing focus
This is because toggling the checkbox is committing the value.

(cherry picked from commit 3856dd946b94b61be2ddac80c8cf60278fcc56ab;
amended to add spaces to expected output due to serenity not yet
having LadybirdBrowser/ladybird#1603, and to add a trailing newline
to the test input file)
2024-11-18 13:21:10 -05:00
Sam Atkins
b961998c1f LibWeb/CSS: Insert whitespace between tokens in serialized UnresolvedSV
Otherwise, `margin: var(--foo) var(--bar)` would be wrongly serialized
as `margin: var(--foo)var(--bar)`

(cherry picked from commit 6e68e8f3c9d74893e46ab0514169b950866457b4)
2024-11-17 23:31:49 -05:00
Sam Atkins
76b13f210d LibWeb: Add a CSS parsing test for selectors containing ':' in @media
While updating the parser to the latest spec algorithms, this started
parsing incorrectly as a declaration, and we had no tests covering it.

(cherry picked from commit 9241f37823f227ae94461a494c6f7ab4b6cd0e4e)
2024-11-17 22:08:57 -05:00
Totto16
8987d773a1 LibWeb: Make HTMLVideoElement part of CanvasImageSource union
(cherry picked from commit abe1172d7097ddae2aff2ddd839b96ed90ba7a13)
2024-11-17 18:57:16 -05:00