Commit graph

64247 commits

Author SHA1 Message Date
Andreas Kling
fa1c5a3e85 LibWeb: Make XMLHttpRequests functions related to MimeType infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
600cb5ccba LibWeb: Make MimeSniff::Resource::sniff() infallible
Everyone was already using this API as if it were infallible anyway.
2024-10-14 20:47:35 +02:00
Andreas Kling
5c20bc2afc LibWeb: Make MimeSniff::MimeType::parse() infallible
It already returns an empty Optional for failures, so there's no need to
wrap it in an ErrorOr as well.
2024-10-14 20:47:35 +02:00
Andreas Kling
88e7688940 LibWeb: Make more MimeSniff::MimeType APIs infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
9a8db40a23 LibWeb: Make MimeSniff::MimeType::create() infallible 2024-10-14 20:47:35 +02:00
Andreas Kling
073bcfd386 AK+LibWeb: Add {Fly,}String::to_ascii_{upper,lower}_case()
These don't have to worry about the input not being valid UTF-8 and
so can be infallible (and can even return self if no changes needed.)

We use this instead of Infra::to_ascii_{upper,lower}_case in LibWeb.
2024-10-14 20:47:35 +02:00
Andreas Kling
dd419b5a8d AK: Make String::number() infallible
This API will always succeed in creating a String representing the
provided number in base-10.
2024-10-14 20:47:35 +02:00
Edward Banner
03569fc509 LibWeb: Fix table overflow issues
- Include vertical border spacing in row group offset calculation so
  that they are axis-aligned with child row/cell elements. This makes it
  so there isn't horizontal and vertical overflow caused by child
  row/cell elements.
- Include horizontal border spacing in tr width calculations. This makes
  it so tr elements don't have overflow anymore when there are multiple
  columns.
- Apply vertical caption offset to row group top offset.
- Don't double-count top padding when calculating vertical offset for
  tr and row groups.
2024-10-14 17:30:17 +01:00
Jelle Raaijmakers
70b3936188 LibMedia: Handle EOF as end of stream in FFmpegLoader
We were dealing with EOF by returning a generic I/O error, but
Audio::Loader requires us to return empty chunks at the end of stream.
2024-10-14 11:59:23 -04:00
Jelle Raaijmakers
c6d0075796 LibWeb: Report audio decoding errors to debug console 2024-10-14 11:59:23 -04:00
ronak69
917a2a3c86 LibWeb: Only return HTML elements from getElementsByName()
Fixes two WPT tests:
document.getElementsByName-namespace-xhtml.xhtml and
document.getElementsByName-namespace.html
2024-10-14 17:59:00 +02:00
Jelle Raaijmakers
d5fd29adb7 LibWeb: Update DOM IDL specs
I noticed some of these were running behind the upstream spec.
2024-10-14 11:57:58 -04:00
Sam Atkins
c79f261bec LibWeb/CSS: Mark grid-[gap, column-gap, row-gap] properties as aliases
These are legacy name aliases for the properties without the 'grid-'
prefix. See https://drafts.csswg.org/css-align-3/#gap-legacy
2024-10-14 17:57:34 +02:00
Sam Atkins
6114e69a53 headless-browser: Early-out with an error if no tests are found
Previously this would just hang - I assume because the
`all_tests_complete` promise could never get resolved without any tests
running.
2024-10-14 11:55:44 -04:00
Bastian Neumann
64308c8c06 LibWeb: Test for parseFromString parsererror
This tests if the parsed xml string gets tagged with a parsererror.
2024-10-14 16:20:57 +01:00
Bastian Neumann
b3fdeef5d7 LibWeb: Do not accept malformed xml namespace
This runs wpt domparsing/DOMParser-parseFromString-xml-parsererror.html
that previously crashed because of a malformed XML namespace in the
test.
2024-10-14 16:20:57 +01:00
Shannon Booth
cde3545a51 LibWeb: Correct some faulty logic in 'apply the history step'
We were checking if the parent was _not_ null, and not checking for an
auxiliary browsing context at all.
2024-10-14 13:45:34 +01:00
ronak69
592cf556a1 LibWeb/CSS: Don't serialize empty rules in CSSStyleRule
This is a recent spec change:
https://github.com/w3c/csswg-drafts/pull/10974
2024-10-14 13:43:16 +01:00
ronak69
8003d63ff9 LibWeb/CSS: Don't serialize empty rules in CSSMediaRule
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
This is a recent spec change:
https://github.com/w3c/csswg-drafts/pull/10981
2024-10-14 09:50:41 +01:00
Taylor Mapes
0522e514a9 LibWeb: Implement CanvasRenderingContext2D.createImageData(ImageData)
Fixes at least one WPT test.
https://wpt.live/html/canvas/element/pixel-manipulation/2d.imageData.create1.basic.html
2024-10-14 09:33:49 +01:00
Taylor Mapes
6ffe83c9da LibWeb: Correct spec link for CanvasImageData 2024-10-14 09:33:49 +01:00
Andreas Kling
5b060da4f4 LibJS: Cache symbolicated stack frames on ExecutionContext
Instead of re-symbolicating entire stacks from scratch every time
we want a JS VM backtrace, we now use the ExecutionContext object as
cache storage via a new CachedSourceRange object.

This means that once a stack frame has been symbolicated, we don't
have to resymbolicate it again (unless the program counter moves
within that stack frame).

This drastically reduces time spent in symbolication in some WPT tests.
2024-10-14 09:51:13 +02:00
Andreas Kling
797902229c AK: Make the main Utf8View workhorse methods inline
The call overhead of these functions was actually showing up quite
hot in profiles on macOS.
2024-10-14 09:51:13 +02:00
Timothy Flynn
e070ed5658 LibWeb+LibWebView: Add an internal API to expire cookies with an offset
Cookies have a minimum expiry resolution of 1 second. So to test cookie
expiration, the test had to idle for at least a second, which is quite a
noticeable delay now that LibWeb tests are parallelized.

Instead, we can add an internal API to expire cookies with a time offset
to avoid this idle delay.
2024-10-14 08:25:41 +02:00
Timothy Flynn
6ce473af72 LibIPC: Pass AK::Duration by value over IPC
AK::Duration is simply an integer, and does not need to be passed by
reference.
2024-10-14 08:25:41 +02:00
Timothy Flynn
7bb9d0131c headless-browser: Add a flag to log the slowest 10 LibWeb tests
Useful for finding tests that take a long time to execute.

As of this commit, on macOS, we have:

Text/input/cookie.html: 1228ms
Text/input/css/transition-basics.html: 1060ms
Text/input/HTML/DedicatedWorkerGlobalScope-instanceof.html: 182ms
Text/input/WebAnimations/misc/animation-events-basic.html: 148ms
Text/input/Crypto/SubtleCrypto-deriveBits.html: 130ms
Text/input/IntersectionObserver/observe-box-inside-container-with-scrollable-overflow.html: 117ms
Text/input/navigation/attempt-navigating-object-without-a-document.html: 109ms
Text/input/css/getComputedStyle-print-all.html: 71ms
Text/input/WebAnimations/misc/animation-single-iteration-no-repeat.html: 61ms
Text/input/WebAnimations/animation-methods/updatePlaybackRate.html: 55ms

And on Linux:

Text/input/cookie.html: 1326ms
Text/input/css/transition-basics.html: 1155ms
Screenshot/text-shadow.html: 772ms
Screenshot/css-background-repeat.html: 622ms
Screenshot/object-fit-position.html: 541ms
Screenshot/css-background-position.html: 456ms
Screenshot/css-gradients.html: 451ms
Screenshot/border-radius.html: 400ms
Screenshot/svg-radialGradient.html: 398ms
Text/input/css/getComputedStyle-print-all.html: 325ms
2024-10-14 08:25:41 +02:00
Cory Virok
560c3824b9 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
2024-10-14 08:25:19 +02:00
Cory Virok
01301c374b LibWeb: Wrap negative dims for getImageData()
Given negative width or height values for CanvasRenderingContext2D
getImageData(), translate the source rect.

I wasn't able to find this in the spec, but WPT tests for it and MDN
defines this behavior.

Fixes this WPT test:
https://wpt.live/html/canvas/element/pixel-manipulation/2d.imageData.get.source.negative.html

Described in MDN here:
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData#sw

getImageData() spec:
https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata
2024-10-14 08:24:36 +02:00
Cory Virok
d71887e48c LibWeb: Use abs() dimensions for canvas getImageData()
Similar to https://github.com/LadybirdBrowser/ladybird/pull/1774

Fixes the crash in the WPT test:
https://wpt.fyi/results/html/canvas/element/pixel-manipulation/2d.imageData.get.double.html?label=master&product=ladybird
2024-10-14 08:24:36 +02:00
Sam Atkins
e0be17e4fb LibWeb/CSS: Rewrite CSS Parser core methods according to new spec
CSS Syntax 3 (https://drafts.csswg.org/css-syntax) has changed
significantly since we implemented it a couple of years ago. Just about
every parsing algorithm has been rewritten in terms of the new token
stream concept, and to support nested styles. As all of those
algorithms call into each other, this is an unfortunately chonky diff.

As part of this, the transitory types (Declaration, Function, AtRule...)
have been rewritten. That's both because we have new requirements of
what they should be and contain, and also because the spec asks us to
create and then gradually modify them in place, which is easier if they
are plain structs.
2024-10-14 08:08:37 +02:00
Sam Atkins
f11c0e6cc0 LibWeb/CSS: Implement "is a custom property name string" to spec
This will be needed in the Parser soon, so for lack of a better place,
it's going in a separate header.
2024-10-14 08:08:37 +02:00
Sam Atkins
7723873016 LibWeb/CSS: Make CSSStyleRule be a CSSGroupingRule
As part of this, we can now fill in the missing serialization steps.

The parsing is a stub for now, and will be filled out in a subsequent
commit.
2024-10-14 08:08:37 +02:00
Sam Atkins
9241f37823 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.
2024-10-14 08:08:37 +02:00
Andreas Kling
ac48222ed7 LibWeb: Recompute targetStep during "apply the history step"
This is an ad-hoc change to account for the fact that we may run
arbitrary code while waiting for the tasks in this function to complete.

I don't have a way to reproduce it, but I've seen trouble caused by
navigables disappearing, which causes the history step numbers to be
disturbed.
2024-10-14 07:45:19 +02:00
ronak69
3ff6137121 LibWeb: Insert title as first child on setting title of svg document
Before, the new title element got appended instead of prepended, as
nullptr was passed as the "child" argument to the insert_before()
function.

This change makes two WPT tests pass in:
http://wpt.live/html/dom/documents/dom-tree-accessors/document.title-09.html
2024-10-14 07:13:58 +02:00
Aliaksandr Kalenik
910f9c2c09 LibWeb: Remove BrowsingContext pointer from Layout::Node
It's no longer needed.
2024-10-14 07:12:36 +02:00
justus2510
55f0dc823f LibWeb: Handle unpaired surrogates in USVStrings
Some checks are pending
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, 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
This should fix (at least) the last two remaining WPT test failures in
FileAPI/unicode.html.
2024-10-13 22:24:28 +01:00
Aliaksandr Kalenik
5559a3dc6e LibWeb: Remove BrowsingContext pointer from Paintable
It's no longer needed.
2024-10-13 22:11:04 +01:00
John Diamond
18ade57ae9 LibWeb: Use correct boundary point comparison in Selection.extend
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
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.
2024-10-13 15:11:49 +02:00
Shannon Booth
ee35e93eb2 LibJS: Early return from Date string parsing on empty string
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
Loading Ladybird on Github results in 37 debug logs about being unable
to parse an empty Date string. This log is intended to catch Date
formats we do not support to detect web compatability problems, which
makes this case not particuarly useful to log.

Instead of trying to parse all of the different date formats and
logging that the string is not valid, let's just return NAN immediately.
2024-10-13 10:12:56 +02:00
Gingeh
f41cbfa2a9 LibWeb: Set both start and end in Selection::extend 2024-10-13 09:47:07 +02:00
Gingeh
93927d8243 LibWeb: Set direction to forwards in addRange 2024-10-13 09:47:07 +02:00
Gingeh
a7953f5e09 LibWeb: Implement Selection::direction 2024-10-13 09:47:07 +02:00
Sebastian-Webster
eec2602424 LibWebView: Add Startpage search engine 2024-10-13 08:36:49 +01:00
sin-ack
f1cab5de7a LibWeb: Compare navigable active_url with fragments included
This was previously negated due to a misread of
https://url.spec.whatwg.org/#concept-url-equals. This change fixes a
bunch of WPT crashes such as
"/html/browsers/history/the-history-interface/001".
2024-10-13 06:47:43 +02:00
Glenn Skrzypczak
3804c4dea1 LibWeb: Don't crash when encountering a resolution in a calculation
calc() seems to support resolutions by now.

The change allows us to pass this WPT test:
http://wpt.live/css/css-values/round-mod-rem-invalid.html
2024-10-12 22:23:03 -06:00
Glenn Skrzypczak
7ed08a401f LibWeb: Support the 'x' resolution unit identifier
The 'x' unit is the same as 'dppx', but was previously not considered
when parsing resolutions.
2024-10-12 22:23:03 -06:00
thislooksfun
ef65694ac0 CMake: Fix codesigning error on Intel macOS
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
Without this fix trying to build a Debug build on x86_64 macOS failed
with "Build/ladybird-debug/bin/Ladybird.app: code object is not signed
at all"
2024-10-12 17:01:14 -06:00
Ali Mohammad Pur
24c2ad059b LibWeb+LibXML: Cache the result of parsing the XHTML DTD and reuse it
There's no reason to parse this again and again every time we parse an
XHTML document.
2024-10-13 00:24:44 +02:00
Cory Virok
6a5bca1302 LibWeb: Added tests for missing xmlns during XHMTL parsing
The main culprit for the following WPT test failure is that we
weren't using the HTML namespace for XHTML docs unless one was
explicitly provided.
2024-10-13 00:24:25 +02:00