Commit Graph

2802 Commits

Author SHA1 Message Date
Timothy Flynn
cc4c7917d5 LibWeb: Move StructuredSerializeOptions to its own header
This largely reduces the number of files needed to be compiled when we
change the MessagePort header.

(cherry picked from commit 32a22c49e3e999e681e2d1de1ebabd092a7f9b47)
2024-11-21 09:41:42 -05:00
Julius Elshoff
15e1590def LibWeb: Rename 'cross-origin opener policy' to 'opener policy'
(cherry picked from commit de31ea5852e3fc0aca1e86e06c6bc019f27824de)
2024-11-21 07:32:56 -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
Andreas Kling
e1ba881587 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.

(cherry picked from commit 073bcfd3866852a4c4bcca2bd131bd65ae53541f)
2024-11-18 20:22:45 -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
Totto16
8987d773a1 LibWeb: Make HTMLVideoElement part of CanvasImageSource union
(cherry picked from commit abe1172d7097ddae2aff2ddd839b96ed90ba7a13)
2024-11-17 18:57:16 -05:00
Andreas Kling
abf9980ea1 LibWeb: Make SVGImageElement part of CanvasImageSource union
This is very janky at the moment but it also more correct. :^)

(cherry picked from commit cd0e4a49b8a758aca847ceaf57eec0a62cd7b687;
amended to add a missing include of LibGfx/ImmutableBitmap.h to
SVGImageElement.h that ladybird seems to get transitively somehow)
2024-11-17 16:48:43 -05:00
Andreas Kling
0b5719685d LibWeb+LibGfx: Serialize HTML canvas fill/strokeStyle colors correctly
Before this change we were serializing them in a bogus 8-digit hex color
format that isn't actually recognized by HTML.

This code will need more work when we start supporting color spaces
other than sRGB.

(cherry picked from commit 4590c081c2eb257232463ed660498a02f9bbe7b8;
amended expected output because serenity does not yet have
LadybirdBrowser/ladybird#1603)
2024-11-17 16:48:43 -05:00
Tim Ledbetter
790eadf2fc LibWeb: Don't discard PostedMessage tasks when closing a worker
The spec expects `postMessage()` to act as if it is invoked
immediately. Since `postMessage()` isn't actually invoked immediately,
keep tasks with source `PostedMessage` in the task queue, so that these
tasks are processed. Fixes a hang when `WorkerGlobalScope.close()` is
called immediately after `postMessage()`.

(cherry picked from commit fd8d350b4756817598ee49a11b9efc3b953dbb00)
2024-11-17 15:18:38 -05:00
Luke Wilde
a7b4b170ed LibWeb: Make MessageEvents from {Window,MessagePort}.postMessage trusted
The MessagePort one in particular is required by Cloudflare Turnstile,
as the method it takes to run JS in a worker is to `eval` the contents
of `MessageEvent.data`. However, it will only do this if
`MessageEvent.isTrusted` is true, `MessageEvent.origin` is the empty
string and `MessageEvent.source` is `null`.

The Window version is a quick fix whilst in the vicinity, as its
MessageEvent should also be trusted.

(cherry picked from commit 079c28d5e68ad983340c02f3d043acfdf2846d18)
2024-11-17 15:18:20 -05:00
Shannon Booth
0eab74d09e LibWeb: Change URL parsing sequence for window open steps
This adapts to the latest HTML spec which fixed the issue we had
reported of:

https://github.com/whatwg/html/commit/316b83
(cherry picked from commit ab309dcc586f15cb7d11d79e7eb916652edf5b60)
2024-11-17 14:44:11 -05:00
Jamie Mansfield
775db34d5e LibWeb/HTML: Update "can have its URL rewritten" for spec changes
This updates the spec comments and removes a FIXME. Functionally,
this doesn't change anything as a fix was already in place.

See:
 - https://github.com/whatwg/html/commit/89a387c
 - https://github.com/whatwg/html/issues/10551
(cherry picked from commit aac342bf7445a2ef9407c45ac66615ac3d0e97ce)
2024-11-17 14:44:11 -05:00
Shannon Booth
25e71eb01a LibWeb: Expose MessagePort.postMessage(message, transfer)
The overload resolution is no longer an issue, and we already had this
implemented :^)

(cherry picked from commit 2c5cfbb968113a5630a8cd580bb100852aadeb95)
2024-11-17 13:47:42 -05:00
Shannon Booth
424d5c7574 LibWeb: Use FIXME extended attribute for ServiceWorker.postMessage
The old FIXME is no longer relevant :^)

(cherry picked from commit 897ba19e0fa783c548281e8fee5d44ce9b5f6dca)
2024-11-17 13:47:42 -05:00
Shannon Booth
65d4b245bb LibWeb: Implement Worker.postMessage(message, transfer)
(cherry picked from commit bf81e2fd644b969976e9c5d96c22bb7e64c87ab7)
2024-11-17 13:47:42 -05:00
Shannon Booth
e93b0f1ce5 LibWeb: Implement DedicatedWorkerGlobalScope postMessage(msg, transfer)
Unfortunately the added test (which passes locally) is skipped as it is
based off other Worker tests which are also skipped due to being flakey
in CI.

(cherry picked from commit 755b63132b72cb25bd358415bf2fdf2be3c14c47)
2024-11-17 13:47:42 -05:00
Andrew Kaster
eac6c59e68 LibWeb: Add ServiceWorker job registration and execution
Now we can register jobs and they will be executed on the event loop
"later". This doesn't feel like the right place to execute them, but
the spec needs some updates in this regard anyway.

(cherry picked from commit 29416befe640eae7bf44b72e3f4ad42a1e397701)
2024-11-17 13:47:42 -05:00
Andreas Kling
2c5f7ad8e4 LibWeb: Use a HashTable when querying SessionHistoryTraversalQueue
Instead of asking "do you have an entry not in this Vector", let's ask
"do you have an entry not in this HashTable".

(cherry picked from commit 861d46be3e69aeb1ca4a9e75029b4ce653bbcf47)
2024-11-17 13:47:42 -05:00
Andreas Kling
23fd706ea9 LibWeb: Fire navigation event as required in History.pushState()
(cherry picked from commit a1519e67fb7a47755d12ff1e8ce2a7de28087933)
2024-11-17 13:47:42 -05:00
Andreas Kling
3e5f37f983 LibWeb: Allow changing the query of file:// URL via history.pushState()
The spec didn't match how other browsers behave, and we dutifully did
what the spec said. A spec bug has been filed, so let's fix this locally
for now with a FIXME.

(cherry picked from commit e3408c4a7f2fe2ce2435d34e816e9b5b7e58f4af)
2024-11-17 13:47:42 -05:00
Andrew Kaster
84972616d7 LibWeb: Start implementing serviceWorker.register
This is mostly the fun boilerplate. Actually creating the Job queue
to do the heavy lifting is next.

(cherry picked from commit c77d9a2732b9325079bca713e4c97d75a0f6a54d)
2024-11-17 11:03:57 -05:00
Andrew Kaster
c9166acffa LibWeb: Use proper enums in WorkerOptions dictionary
(cherry picked from commit 1d43d5b086107a8039ae37df19ad56b4e73959da)
2024-11-17 11:03:57 -05:00
Andrew Kaster
98663d09c6 LibWeb: Add stub of ServiceWorker interface
(cherry picked from commit a0c07d1bb27cdab33a12e1b1ad03a9452750503a)
2024-11-17 11:03:57 -05:00
Shannon Booth
345143a5d0 LibWeb+LibURL: Use URL paths directly for comparison
This matches the text of the spec a little more closely in many cases
and is also more efficient than serializing the URL path.

(cherry picked from commit ffe070d7f9164ff51644f8d912b580a0b291e26a)
2024-11-17 11:03:57 -05:00
Andrew Kaster
875159d0f8 LibWeb: Add ServiceWorker discarded flag to ESO
Looking at the spec it doesn't seem like there's a chance for a service
worker client to be an environment but not an environment settings
object. In the case that that changes in the implementation, we can
move it.

(cherry picked from commit 237bcbff360d5000ab45da2ca63f196064ab5210)
2024-11-16 14:12:55 -05:00
Andrew Kaster
1fe27532b2 LibWeb: Add service worker client to ServiceWorkerContainer
(cherry picked from commit 0ece40c466dbd6c43fc9b0707d32b3d5d42fe751)
2024-11-16 14:12:55 -05:00
Andrew Kaster
7e5cbf8d3e LibWeb: Add oncontrollerchange to ServiceWorkerContainer
(cherry picked from commit 4df280689b5c7f4df53cdcb1c61cb3fed99461c6)
2024-11-16 14:12:55 -05:00
Andrew Kaster
a3abd26d2e LibWeb: Add WorkerNavigator.serviceWorker API
This simply adds a ServiceWorkerContainer object to the WorkerNavigator.

(cherry picked from commit 2667726b74ae374be2907552795cf56639c4d57f)
2024-11-16 14:12:55 -05:00
Sam Atkins
d3cb52dc3f LibWeb/HTML: Expose HTML syntax highlighter's token kinds
This will be used for outputting the highlighted document as HTML.

(cherry picked from commit a231435321b232d8873a65bd859152ce98e892a5)
2024-11-16 14:05:12 -05:00
Sam Atkins
73b2383313 LibWeb/HTML: Use unique offsets for nested highlighters' tokens
The code previously ensured that JS/CSS tokens did not share values with
the HTML tokens, but still let them share values with each other. The
numbers chosen (1000 and 2000) are somewhat arbitrary, but give us
plenty of room to avoid overlaps.

(cherry picked from commit 07f0d9209a49fa349ce3763dd7ab8835b78edf85)
2024-11-16 14:05:12 -05:00
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