Commit Graph

2772 Commits

Author SHA1 Message Date
Sam Atkins
487ed33e2e LibWeb/HTML: Remove unused SyntaxHighlighter fields
(cherry picked from commit 2b961f145c545ea34227227062171a1b99191e4b)
2024-11-16 14:05:12 -05:00
Sam Atkins
6046f9d61f LibWeb: Add method for listing all style sheets on a page
This will be used by the inspector, for showing style sheet contents.

Identifying a specific style sheet is a bit tricky. Depending on where
it came from, a style sheet may have a URL, it might be associated with
a DOM element, both, or neither. This varied information is wrapped in
a new StyleSheetIdentifier struct.

(cherry picked from commit 51a426cc0562d12a6e8f7d1d1a38f9ecac77072a)
2024-11-15 23:10:03 -05:00
Sam Atkins
2c24635e63 LibWeb: Set the location URL for @import-ed/<link>-ed style sheets
The spec text had changed for the value of `<link>`'s location, so I've
updated that.

(cherry picked from commit 4e18fce3a586651894844c7ef0a06c774ce9eb2c)
2024-11-15 23:10:03 -05:00
Andreas Kling
3c2e4999f4 LibWeb: Let determine_the_origin() take an optional URL after all
I originally believed that this could never receive a null URL and the
spec was inaccurate, but it seems like it can indeed.

I don't have a distilled test, but this makes logging in with GitHub
work on https://v0.dev/

(cherry picked from commit 1a4b0ded1f802fdcc3ef9b919b5749b086471fc2;
amended to also cherry-pick LadybirdBrowser/ladybird#2358)
2024-11-15 10:19:53 -05:00
Gingeh
af93b65e26 LibWeb: Use Content-Type header to set document encoding
Co-authored-by: Shannon Booth <shannon@serenityos.org>
(cherry picked from commit 8e342e3e23f5c0d7e6df5b1bcc3cc4db31a9de2b)
2024-11-14 22:21:55 -05:00
0x4261756D
fcfe89e21d HTMLEncodingDetection: Use mime type in encoding sniffing
Also added proper spec comments.
Fixes at least one WPT test that was failing previously:
https://wpt.live/encoding/single-byte-decoder.window.html?document

(cherry picked from commit c1a14f66adf4b5e55a0e2a78068749e7d8b3ed98)
2024-11-14 21:38:52 -05:00
Daniel La Rocque
d84ef14a57 LibWeb: Assert navigationParams' request and response are not null
(cherry picked from commit db6ec2792a709d616b2f4aba8955a8c93837d9cb)
2024-11-14 17:46:06 -05:00
Daniel La Rocque
171a2ab2c0 LibWeb: Check if navigationParams is NullWithError
When we check whether navigationParams is null, we should check if it is
`NullWithError`, since `NullWithError` is equivalent to `Empty`, but is
used for error messages.

(cherry picked from commit 219cb04865fc02bfc05d39f048dd2a778714b7e1)
2024-11-14 17:46:06 -05:00
Shannon Booth
7babbf4b2e LibWeb: Fix spec typo in inner_navigate_event_firing_algorithm
(cherry picked from commit 329e9ed820ead326ed309f6cfb07f04695aa4c48)
2024-11-14 17:46:06 -05:00
Shannon Booth
fe69f62160 LibWeb: Fire traversable event during "apply the history step"
These steps were recently clarified by Andrew in:

https://github.com/whatwg/html/commit/12b0d582
(cherry picked from commit dc9861174b52a941b98b02b04231d77d94203628)
2024-11-14 17:46:06 -05:00
Shannon Booth
4ee6a305af LibWeb: Simplify populate_session_history_entry_document conditional
(cherry picked from commit bd3ffcdabb42f097bfb008ef1c02cfa8708e7a72)
2024-11-14 17:46:06 -05:00
sin-ack
e88ee18e6d LibWeb: Remove redundant DedicatedWorkerGlobalScope prototype setting
Now that the global object correctly sets the property, we don't need
to do it here.

(cherry picked from commit 711faa8280ac4147f68ed778ad67047428329c67)
2024-11-14 17:46:06 -05:00
Arhcout
0845de1018 LibWeb: Don't trigger onchange event when setting <select> value
(cherry picked from commit 5d00211a8605b0fab9f330082699f6f089961052)
2024-11-14 17:46:06 -05:00
Timothy Flynn
7e1d73b76d LibWeb: Spin the HTML event loop when awaiting a navigable fetch
Spinning the HTML event loop allows microtasks to run (i.e. Promise
completions).

(cherry picked from commit 6f31a19c5f0b7bcae89037ceb65c474b20482ca2)
2024-11-14 17:35:38 -05:00
Andrew Kaster
c7d4825b44 LibWeb: Prefix AK::Duration with AK Namespace
(cherry picked from commit b20a1d0fcddb999de372a49d213bec01bda24c10)
2024-11-14 17:35:38 -05:00
Luke Wilde
c1767b1964 LibWeb: Make iframe insertion steps check the shadow including root
The insertion steps for iframes were following an old version of the
spec, where it was checking if the iframe was "in a document tree",
which doesn't cross shadow root boundaries. The spec has since been
updated to check the shadow including root instead.

This is now needed for Cloudflare Turnstile iframe widgets to appear,
as they are now inserted into a shadow root.

(cherry picked from commit 4dd14d812f73377cb1efa5a8e8a114912a90b5af)
2024-11-13 19:32:02 -05:00
Kemal Zebari
5b244c69cd LibWeb/HTML: Add missing HTMLElement IDL autocorrect as a stub
This adds an IDL stub for the autocorrect HTMLElement attribute.

(cherry picked from commit 04d16a1ee3a4f8224417bbc5f8abe8ef4ffe5b88)
2024-11-13 10:17:34 -05:00
Benjamin Bjerken
6268e8f559 LibWeb: Fix CloseWatcher constructor for detached iframes
This fixes the last subtest in /close-watcher/frame-removal.html :)

(cherry picked from commit 63d9ed9d8c4fafd569e042e0698bd5dc844a1b29)
2024-11-13 10:17:34 -05:00
sin-ack
3e29a1975a LibWeb: Obtain basename before passing base_url to ClassicScript::create
This would previously crash because it depended on a specific order for
evaluating function arguments, which is undefined.

(cherry picked from commit 27b1d94e04386fd46c2c9148b9555c841595e2d3)
2024-11-12 22:26:21 -05:00
Jelle Raaijmakers
8c714769f3 LibWeb: Implement navigator.deviceMemory
Fixes at least 2 subtests in wpt/device-memory.

(cherry picked from commit 69f11fc1c657603b189015fd620f96e32adfb9fd)
2024-11-12 22:26:21 -05:00
Tim Ledbetter
05e8835555 LibWeb: Follow spec steps to set the selectionDirection attribute value
(cherry picked from commit d0b97873d421d092eb41e3b7a7d8959347b3b436)
2024-11-12 22:26:21 -05:00
sin-ack
b7dea19a3f 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".

(cherry picked from commit f1cab5de7a071fe76eae10d36603f6cf34fa989e)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
be7110a3a4 LibWeb: Map dimension attributes for table elements
(cherry picked from commit 140dc95e6769a41542f98abef333d5bc32b86e39)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
ea8914aeac LibWeb: Map embedded content element attributes to dimension properties
(cherry picked from commit 728236f4d20b4dbabfe0936b79a2f63ac80f4da3)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
8dee6b9ebd Libweb: Map marquee attributes to dimension properties
(cherry picked from commit baca0e5e5568b1b9b301cefa7d6cc8312b39be28)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
7e456212c7 LibWeb: Map hr width attribute to the width dimension property
(cherry picked from commit 4c3101e021e323b487e8ab10026a14fdf40fa2f0)
2024-11-12 19:57:55 -05:00
Mohamed amine Bounya
7c91d38332 LibWeb/HTML: Select html input elements with selectable text
only select input elements that select applies to and has a
selectable text.

(cherry picked from commit 6fe43e9f736160f3437958a407ce1554c371f1a5)
2024-11-12 19:57:55 -05:00
Gingeh
3b9064089a LibWeb: Don't move focus when setting input value
(cherry picked from commit 1d9c404b8cb898b351ee3c69840bf943e97d499c)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
bb798071a0 LibWeb: Treat dates and times with repeated separators as invalid
These would previously be treated as valid by the value sanitization
algorithm.

(cherry picked from commit f9282f65d3a4daf7df2c6033b03c70a56130aa72)
2024-11-12 19:57:55 -05:00
Sam Atkins
dea1b7700a LibWeb/HTML: Dispatch toggle and beforetoggle events from dialogs
Corresponds to https://github.com/whatwg/html/pull/10091

(cherry picked from commit 36f8dfaed02a967de620a7e2abc8bd254cd7f9a5)
2024-11-12 10:45:53 -05:00
Sam Atkins
0a38d163dd LibWeb/HTML: Update legacy color parsing steps to match spec
(cherry picked from commit f80fca2deeb2b0ea5ffd0af714bcd79b3ad729dd)
2024-11-12 10:45:53 -05:00
Tim Ledbetter
c7a699ed73 LibWeb: Make input type state change handling specification compliant
This change ensures that the value sanitization algorithm is run and
the text cursor is set to the correct position when the type attribute
of an input is changed.

(cherry picked from commit 1b74104c17726018788034f2ad66201889ce6225)
2024-11-12 10:45:53 -05:00
Tim Ledbetter
f24a625eb0 LibWeb: Don't crash when normalizing a local datetime with a T separator
(cherry picked from commit 2d7547921b98747153ae9d9dda3d5479d4e9036f)
2024-11-12 10:45:53 -05:00
Tim Ledbetter
6db07d132f LibWeb: Use correct value when parsing datetime-local input type
(cherry picked from commit eb4e40bc49d2ad78335d0e95482a9c702764a8c9)
2024-11-12 10:45:53 -05:00
Tim Ledbetter
22cd5b3263 LibWeb: Ensure value sanitization algorithm trims whitespace if needed
Previously, the value sanitization algorithm would not trim whitespace
for inputs of type URL or email, if they didn't also contain any
newlines.

(cherry picked from commit c4b82318f41ecc0a3e24fe5c8ca0a3f02816c3b1)
2024-11-12 10:45:53 -05:00
Tim Ledbetter
a77b65d46a LibWeb: Don't attempt to set selection if control has no selectable text
(cherry picked from commit 2c8fb4957871bca5694fc9e9f8932c9769967bd1)
2024-11-12 10:45:53 -05:00
Jonne Ransijn
5d6ef182f4 LibJS+LibWeb: Prevent double invocation of [[GetOwnProperty]]
The `[[GetOwnProperty]]` internal method invocation in
`OrdinarySetWithOwnDescriptor` was being invocated again with the same
parameters in the `[[DefineOwnProperty]]` internal method that is also
later called in `OrdinarySetWithOwnDescriptor`.

The `PlatformObject.[[DefineOwnProperty]]` has similair logic.

This change adds an optional parameter to the `[[DefineOwnProperty]]`
internal method so the results of the previous `[[GetOwnProperty]]`
internal method invocation can be re-used.

(cherry picked from commit 69f96122b6150c22d1e8dc848c097cead2d2ae3f)
2024-11-12 07:14:25 -05:00
Sam Atkins
b7d8202814 LibWeb: Update spec comments using "Type(Foo)" -> "is a Foo"
(cherry picked from commit f31c18756bfdc6449f01a144e1ef2dfbf8acab22)
2024-11-12 07:14:25 -05:00
Sam Atkins
e20a2718fc LibWeb/HTML: Guard showModal() with fully active check
This corresponds to this spec change:
https://github.com/whatwg/html/pull/10705

(We don't implement showPopover() yet.)

(cherry picked from commit 00e613c7df7ac26ba28e11d172207c045d35a542)
2024-11-12 07:14:25 -05:00
Chase Knowlden
5be3121822 LibWeb/HTML: Start implementing the download attribute
(cherry picked from commit 20376adbc3040104d0f80a0147c373b83a401a23)
2024-11-12 07:14:25 -05:00
Simek
88637f6ed3 LibWeb: Correct default ARIA Roles for few tags
(cherry picked from commit c9c67a6f24682512b88d41b3663aea8e4e97065d)
2024-11-12 07:14:25 -05:00
Timothy Flynn
6cef8e5bfd LibWeb: Remove range-count filter from selection change handlers
The implementation of setBaseAndExtent will create a new range.

(cherry picked from commit 96ad310643ff90af557b9ca71db450ebd4d37ba5)
2024-11-12 07:13:58 -05:00
Timothy Flynn
af3222b686 LibWeb: Update the document cursor position when the selection changes
Otherwise, it looks a bit awkward where the cursor position does not
update while the selection is elsewhere.

Note that this requires passing along the raw selection positions from
`set the selection range` to the elements. Otherwise, consider what will
happen if we set the selection start and end to the same value. By going
through the API accessor, we hit the case where the start and end are
the same value, and return the document cursor position. This would mean
the cursor position would not be updated.

The test changes here more closely match what Firefox produces now. It
is not a 100% match; the `select event fired` test case isn't right. The
problem is the event fires for the input element, but we most recently
focused the textarea element. Thus, when we retrieve the selection from
the input element, we return the document's cursor position, which is
actually in the textarea element. The fix will ultimately be to fully
implement the following:

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-cursor

That is, each input / textarea element should separately track its own
text cursor position.

(cherry picked from commit fd289deb44e0fc26f54a133c637c136bf0716cd5)
2024-11-12 07:13:58 -05:00
Shannon Booth
001db03171 LibWeb: Ensure fully active document before appending to an iframe
(cherry picked from commit 15c15116dd3d62c5a9ee17f6c80e1782cd2a1a96)
2024-11-12 04:24:21 -05:00
Piotr
850692f6c1 LibWeb: Set textarea rows and cols default value if 0
The cols and rows attributes are limited to only positive numbers with
fallback. The cols IDL attribute's default value is 20. The rows IDL
attribute's default value is 2.

The default value was returned only for the negative number. I added an
additional check for the case when the attribute is 0 to match the
specification.

(cherry picked from commit 205155a7abb9b9754cd0917901cfc04d86291820)
2024-11-12 04:24:21 -05:00
Totto16
c1b0ac6376 LibWeb: Reject Promise in createImageBitmap for Not Implemented Types
If we don't reject the Promise, it lasts forever,
so rejecting non implemented Promises is essential,
to not timeout in e.g. WPT tests

(cherry picked from commit aab5a9e944f8b1c1a9de321047556bbcaa282a56)
2024-11-11 19:54:09 -05:00
Tim Ledbetter
c8319c9166 LibWeb: Don't print messages from workers to the console twice
Previously, any message logged to the console within a worker with a
log level greater than trace was printed twice.

(cherry picked from commit d0008ae5e0100984f3188c32a67008a03c05bea8)
2024-11-11 19:54:09 -05:00
Timothy Flynn
85c6ca8417 LibWeb: Remove debug spam from Navigator methods
These are logged ~1000 times on fast.com.

(cherry picked from commit 76152845fdb74d4881c6d8e43790146780fbe7b3)
2024-11-11 19:54:09 -05:00
Shannon Booth
191b686699 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.

(cherry picked from commit f2134dc1e960cb1d0c743b375509fe165885ddbe)
2024-11-11 17:22:42 -05:00
Shannon Booth
9150241db9 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
(cherry picked from commit ea971792b5da5f10cadb4f88f49c9722d88b32f6)
2024-11-11 17:22:42 -05:00