Commit Graph

72528 Commits

Author SHA1 Message Date
ayeteadoe
5e529fc603 LibCore: Use WinSock2 closesocket() in PosixSocketHelper::close()
Our Core::System::is_socket() helper is not very robust, as it was
incorrectly marking m_fd as a non-socket fd. This meant we were trying
to call CLoseHandle() on a socket which fails. We can just call
closesocket() directly given we are in an explicit socket-only context.
2025-10-29 21:07:52 -06:00
ayeteadoe
7683f1285f AK: Expose helpers to invoke Windows runtime config directly in main()
When shutting down helper processes, PosixSocketHelper::close() in
SocketWindows when trying to close the socket fd with
WSANOTINITIALISED. This was due to us initiating WinSock2 during static
initialization and presumably also not terminating WinSock2 properly.

Similar to WinSock2 initiation, calling CRT during static
initialization is considered dangerous given the CRT DLL itself may not
yet be initialized.

Because of the above, we move to perform this Windows-specific
runtime setup/teardown calls into the main() functions.
2025-10-29 21:07:52 -06:00
ayeteadoe
643f0de422 RequestServer: Instruct curl to use Windows CA cert store
This is required for supporting HTTPS requests. Otherwise we fail with
CURLE_PEER_FAILED_VERIFICATION.
2025-10-29 21:07:52 -06:00
ayeteadoe
95f239a357 CMake: Add Windows executable helper function
The function currently has 2 purposes: (1) To copy dependent dlls for
executables to output binary directory. This ensures that these helper
processes can be ran after a build given not all DLLs from vcpkg libs
get implicitly copied to the bin folder. (2) Allow fully background
and/or GUI processes to use the Windows Subsystem. This prevents
unnecessarily launching a console for the process, as we either require
no user interaction or the user interaction is all handled in the GUI.
2025-10-29 21:07:52 -06:00
ayeteadoe
20f9510687 CMake: Output helper process binaries to bin instead of libexec
libexec is not a standard convention on Windows. Everything should go
into bin
2025-10-29 21:07:52 -06:00
ayeteadoe
6261c433a3 LibWebView: Implement stubbed out BrowserProcess methods on Windows 2025-10-29 21:07:52 -06:00
ayeteadoe
231336f137 LibWebView: Implement stubbed out Process methods on Windows 2025-10-29 21:07:52 -06:00
ayeteadoe
d299df24ac LibRequests: Create ReadStream abstraction for reading request data
Given the RequestServer created the request fd with socketpair() on
Windows and pipe2() on Unix, this abstraction avoids inlined ifdef soup
by hiding the details of how the AK::Stream and Core::Notifier are
created.
2025-10-29 17:47:02 -04:00
ayeteadoe
11ec7c9cea RequestServer: Create RequestPipe abstraction for request data transfer
The Win32 API equivalent to pipe2() is CreatePipe(), which creates read
and write anonymous pipe handles that we can set to non-blocking via
SetNamedPipeHandleState(); however, this initial approach caused issues
as our Windows infrastructure assumes socket-based handles/fds and that
we don't use Windows pipes at all, see Core::System::is_socket() in
SystemWindows.cpp. So we use socketpair() to keep our current
assumptions true.

Given that Windows uses socketpair() and Unix uses pipe2(), this
RequestPipe abstraction avoids ifdef soup by hiding the details about
how the read/write fds pair is created and how response data is written
to the client.
2025-10-29 17:47:02 -04:00
Andreas Kling
9dae1acc31 LibJS: Pass ExecutionContext to Interpreter::run_executable()
This avoids having to get it from the VM's context stack, since most
callers already have it on hand.
2025-10-29 21:20:10 +01:00
Andreas Kling
a7d13b107e LibJS: Move all per-frame state from Interpreter to ExecutionContext
This simplifies function entry/exit and lets us just walk away from the
used ExecutionContext instead of resetting a bunch of its state when
returning control to the caller.
2025-10-29 21:20:10 +01:00
Andreas Kling
59ce6c9b41 LibJS: Shrink two u64 fields in ExecutionContext to u32
To shrink ExecutionContext, these two fields are made 32-bit:

- skip_when_determining_incumbent_counter
- program_counter
2025-10-29 21:20:10 +01:00
Andreas Kling
4c7ffc0552 LibJS: Remove ExecutionContext::function_name field
Instead of having ExecutionContext track function names separately,
we give FunctionObject a virtual function that returns an appropriate
name string for use in call stacks.
2025-10-29 21:20:10 +01:00
Andreas Kling
e967631763 LibJS: Remove ExecutionContext::arguments_offset and just compute it 2025-10-29 21:20:10 +01:00
Andreas Kling
fdb85a330e LibJS: Stop tracking whether execution context is strict mode or not
This was only used for basic testing, and forced us to plumb this flag
flag in a bunch of places.
2025-10-29 21:20:10 +01:00
Andreas Kling
fb05063dde LibJS: Let bytecode instructions know whether they are in strict mode
This commits puts the strict mode flag in the header of every bytecode
instruction. This allows us to check for strict mode without looking at
the currently running execution context.
2025-10-29 21:20:10 +01:00
Andreas Kling
3fb678b376 LibGC: Delete operators ! and bool from GC::Ref
The GC::Ref smart pointer is always non-null, so there's no need for it
to be convertible to bool.

This exposed a small number of unnecessary null checks which we remove.
2025-10-29 21:20:10 +01:00
Tim Ledbetter
e4e18ca84b UI/AppKit: Support dead keys on MacOS 2025-10-29 12:38:59 -04:00
InvalidUsernameException
35254d17d1 LibWeb/CSS: Do not crash when parsing some multi-layer mask shorthands
This fixes a silly bug where we would crash when parsing a multi-layer
mask shorthand property that contained the no-clip keyword but no value
for mask-origin.

Fixes a crash when parsing the CSS of https://www.browserbase.com/. The
site still has other, unrelated problems though.
2025-10-28 23:50:46 -07:00
Zaggy1024
418f1575b0 LibWeb: Stop returning the value in HTMLMediaElement::set_current_time
This wasn't actually affecting the result in a script assigning a
variable to the result of an expression assigning to currentTime.
2025-10-29 06:22:48 +00:00
Lorenz A
14dba82202 LibWeb: Allow whitespace in not after a boolean-expr-group 2025-10-28 21:54:48 -07:00
dependabot[bot]
32cfb4e7d8 CI: Bump actions/upload-artifact from 4 to 5
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-28 21:41:38 -07:00
stelar7
964c0ddde9 LibWeb/IDB: Import getAllRecords test 2025-10-28 19:25:26 -04:00
stelar7
8fcba173e0 LibWeb/IDB: Correctly implement IDBRecord getters 2025-10-28 19:25:26 -04:00
ayeteadoe
244f086709 LibRequests: Decode RequestTimingInfo IPC fields as i64's
On 64-bit Windows, long's are only 4 bytes. This meant that when the
client is deocding the IPC message from a async_request_finished call,
we were corrupting the RequestTimingInfo field and all the fields after
it as we were 4 bytes off.
2025-10-28 19:09:42 -04:00
Luke Wilde
d2b2d57387 LibWeb: Set attribute value directly in HTMLScriptElement::set_src
Otherwise we'll try to use the Utf16String that has already been
through Trusted Types and put it through again. That can also fail if
there's no default policy and there's a `require-trusted-types-for
'script'` directive.

Fixes Outlook failing to load.
2025-10-28 11:05:09 -07:00
Luke Wilde
498e59f71d LibWeb: Set width/height of ImageBitmap when deserializing or receiving 2025-10-28 10:05:56 -07:00
Luke Wilde
3ca4ff6037 LibWeb/WebGL: Don't attempt to do texture transforms on an empty texture
Skia will not give us a surface if the width or height is zero.
2025-10-28 10:05:56 -07:00
Tete17
b0e02af040 Tests: Add previously crashing TrustedTypes tests
Some of these fail, but we think it is due to a discrepancy between
what the spec says and what the WPT test.

Ref: https://github.com/w3c/trusted-types/issues/595
2025-10-28 13:46:54 +00:00
Tete17
676171bccd IDLGenerators: Allow set_attribute's to throw exceptions 2025-10-28 13:46:54 +00:00
Timothy Flynn
7f37889ff1 RequestServer: De-duplicate some disk cache requests
We previously had no protection against the same URL being requested
multiple times at the same time. For example, if a URL did not have any
cache entry and became requested twice, we would open two cache writers
concurrently. This would result in both writers piping the response to
disk, and we'd have a corrupt cache file.

We now hold back requests under certain scenarios until existing cache
entries have completed:

* If we are opening a cache entry for reading:
  - If there is an existing reader entry, carry on as normal. We can
    have multiple readers.
  - If there is an existing writer entry, defer the request until it is
    complete.

* If we are opening a cache entry for writing:
  - If there is an existing reader or writer entry, defer the request
    until it is complete.
2025-10-28 11:52:51 +01:00
Timothy Flynn
95d23d02f1 RequestServer: Pass the Request object to disk cache entry factories
This object will be needed in a future commit to store requests awaiting
other requests to finish. Doing this in a separate commit just to make
that commit less noisy.
2025-10-28 11:52:51 +01:00
Timothy Flynn
5384f84550 RequestServer: Create disk cache writers for new requests immediately
We previously waited until we received all response headers before we
would create the cache entry. We now create one immediately, and handle
writing the headers in its own function. This will allow us to know if
a cache entry writer already exists for a given cache key, and thus
prevent creating a second writer at the same time.
2025-10-28 11:52:51 +01:00
Timothy Flynn
d67dc23960 RequestServer: Fix typo in CacheEntry::close_and_destroy_cache_entry 2025-10-28 11:52:51 +01:00
Timothy Flynn
822fcc39de RequestServer: Manage request lifetimes as a simple state machine
We currently manage request lifetime as both an ActiveRequest structure
and a series of lambda callbacks. In an upcoming patch, we will want to
"pause" a request to de-duplicate equivalent requests, such that only
one request goes over the network and saves its response to the disk
cache.

To make that easier to reason about, this adds a Request class to manage
the lifetime of a request via a state machine. We will now be able to
add a "waiting for disk cache" state to stop the request.
2025-10-28 11:52:51 +01:00
Timothy Flynn
6cf22c424e RequestServer: Remove extra verbose disk cache log entry
This isn't particularly useful anymore, and is especially verbose for
large responses.
2025-10-28 11:52:51 +01:00
Timothy Flynn
dc10c28b57 RequestServer: Remove erroneous placeholders from dbgln statements
Apparently Services aren't compiled with ENABLE_COMPILETIME_FORMAT_CHECK
2025-10-28 11:52:51 +01:00
Timothy Flynn
1216a2f952 RequestServer: Move some cURL utilities to their own file
This will allow more easily using these from other files. This also lets
us hide the Windows.h header necessity in a single location, instead of
needing to remember to include it everywhre we would otherwise include
<curl/curl.h>.
2025-10-28 11:52:51 +01:00
Timothy Flynn
7450da5556 RequestServer: Move Resolver (and related structures) to its own file
In an upcoming commit to handle requests as a state machine, we will
need access to Resolver from outside of ConnectionFromClient..
2025-10-28 11:52:51 +01:00
ayeteadoe
997d6ee75a RequestServer: Support UDP default resolver on Windows 2025-10-28 11:52:51 +01:00
stelar7
d3568d9467 LibWeb/IDB: Handle off-by-one error in IDBIndex::getAll 2025-10-28 11:50:01 +01:00
Zaggy1024
e5d5ff952c LibMedia: Remove an unused debug variable from AudioDataProvider
Fixes the ENABLE_ALL_THE_DEBUG_MACROS build.
2025-10-27 23:03:01 -07:00
Adrian Kiezik
823deacc27 LibWeb: Implement CanvasRenderingContext2D direction property
When direction is 'rtl':
  - textAlign='start' now aligns text to the right
  - textAlign='end' now aligns text to the left

Fixes the FIXME at CanvasRenderingContext2D.cpp:283
2025-10-27 22:03:26 -07:00
Lorenz A
ffcd3a4bb2 LibWeb: Count the width of inline-blocks in InlineNodes only once
An BlockContainer inside an InlineNode is called from the
`for each in inclusive_subtree_of_type`  but is also a fragment
 of that InlineNode. Don't count the the Node twice.
2025-10-27 21:45:33 -07:00
Zaggy1024
93fde59892 LibWeb: Make the value of assignment to media currentTime the rhs value
In cases where a script assigns `x = video.currentTime = y`, we are
expected to have a result of `x === y`, even if the video's duration
is less than y.

According to the spec, this happens because the official playback
position is set to `y` in this case, but since we are following
implementations in making `currentTime` immediately return the position
on the valid media timeline, we have to specifically return the
unchanged value from the setter.

See: https://github.com/whatwg/html/issues/11773
2025-10-27 17:28:49 -07:00
Zaggy1024
9e4c87ab85 LibWeb: Ensure that media elements can seek to the duration
Due to the round trip of Duration -> double -> Duration, seeking to the
end of some media can sometimes result in the seek being resolved close
to the end but not quite there. This is a little bit of a hack to make
that work, but may be necessary depending on how the spec changes with
regard to the value returned by currentTime after a seek begins.
2025-10-27 17:28:49 -07:00
Zaggy1024
cb1719aa81 LibWeb: Don't loop the media element when paused
We should be able to seek to the end of the media without looping if
we're paused.

See: https://github.com/whatwg/html/issues/11774
2025-10-27 17:28:49 -07:00
Zaggy1024
4471e8c0ec LibWeb: Consider playback ended when loop is set after ending playback
This allows playback to restart when playing is requested after the end
of playback was reached while loop was disabled, regardless of whether
loop is then subsequently enabled.

This matches other browsers' implementations, but differs from the spec
in how the ended attribute is handled.

See: https://github.com/whatwg/html/issues/11775
2025-10-27 17:28:49 -07:00
Zaggy1024
3be6b957f8 LibWeb: Add the concept of direction of playback in HTMLMediaElement 2025-10-27 17:28:49 -07:00
Zaggy1024
45727d7a58 LibWeb: Fire the media element ended event inside a task
The spec changed in this regard, and this change ensures that once the
ended attribute is updated only during event loop step 1, ended event
handlers will see the ended attribute set to true.
2025-10-27 17:28:49 -07:00