Commit graph

36064 commits

Author SHA1 Message Date
Timothy Flynn
16def85153 LibWeb: Implement HTMLFrameElement as a NavigableContainer
NavigableContainer is our home grown concept which already contains the
AOs needed for frame and iframe elements. This patch simply aligns our
HTMLFrameElement implementation with this class.

A couple of notes:

1. The <script> in the <head> element is intentional. The <frameset>
   element effectively takes the place of the <body> element, and we
   cannot add a <script> to a <frameset> element.

2. We don't render <frameset> or <frame> at all. Rendering is defined
   in the following spec:
   https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets

3. If you load the test page in your browser, you won't see anything,
   regardless of (2). Our test infra adds a <pre> element to the "body"
   element (which is the <frameset> element here). Such children will
   never be rendered. In the future, we could come up with something
   better for our test infra to do, but this isn't important anyways
   for this test - we can still grab the <pre> element's innerText.
2024-11-04 09:54:32 +00:00
Timothy Flynn
0e04d49b44 LibWeb: Implement most WebDriver element locator strategies
Notably missing here is an XPath implementation.
2024-11-03 20:42:46 -05:00
Timothy Flynn
64a8fcc4ef LibWeb: Begin implementing a Selenium-like method to get element text
Unfortunately, there isn't an exact spec method to get the rendered text
of an element, including its shadow DOM. The WebDriver spec requires
just doing exactly what Selenium does.

This patch does not implement this, but is a step in the right direction
as we will now handle text transforms.
2024-11-03 20:42:46 -05:00
Timothy Flynn
a4daf6f928 WebContent: Implement WebDriver's Switch Frame endpoint for numeric IDs 2024-11-03 20:42:46 -05:00
Timothy Flynn
cfcb29bdfd AK+LibUnicode: Add a method to trim non-ASCII whitespace from a String
Required by WebDriver.
2024-11-03 20:42:46 -05:00
Andreas Kling
969ee0f3e0 LibJS: Make DataView::byte_offset() return u32
This fixes structured serialization of DataView. It was expected
to be uniform with TypedArray, which returns u32 for byte_offset().

This was covered by a number of WPT infrastructure tests, which this
commit also imports.
2024-11-04 00:22:40 +01:00
Jonne Ransijn
7402ae3a00 LibWeb: Use the realm from the ServiceWorker client
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
`vm.realm()` might not exist, and was probably not even the right realm
to use in the first place.
2024-11-03 15:26:45 -07:00
Timothy Flynn
3da20aca65 WebContent+WebDriver: Convert all user prompt handlers to be async
Making these async were all actually pretty trivial. This patch does so,
and removes the deprecated synchronous user prompt handler.
2024-11-03 22:11:19 +01:00
rmg-x
0db171c36e LibWeb/Crypto: Fix sizes being passed into generate_aes_key()
Previously, callers were passing the size in bytes, but the method
expected bits. This caused a crash in LibCrypto when verifying the key
size later on.

Also make the naming of local variables and parameters a little more
clear between the different AES algorithms :^)
2024-11-03 21:55:43 +01:00
Andreas Kling
64747c0397 LibWeb: Make HTML parser "current node" APIs return nullable pointer
It's actually possible for there to be no adjusted current node, when
the stack of open elements is empty. This was covered by one of the WPT
parsing tests.
2024-11-03 20:32:32 +01:00
Andreas Kling
ebce483278 LibWeb: Add spec comments to the "in head noscript" parser state 2024-11-03 20:32:32 +01:00
Andreas Kling
0a47d8cb08 LibWeb: Handle more MathML/HTML integration points in the parser 2024-11-03 20:32:32 +01:00
Andreas Kling
ae39c54e51 LibWeb: Fix SVG tag adjustment for feSpotLight, feTile, feTurbulence 2024-11-03 20:32:32 +01:00
rmg-x
c755a09376 RequestServer/ConnectionFromClient: Remove unused header directives 2024-11-03 20:02:52 +01:00
rmg-x
fc53422e1c RequestServer: Implement preconnect for CreateConnection cache level 2024-11-03 20:02:52 +01:00
Aliaksandr Kalenik
feba8e6218 LibWeb: Replace nested_browsing_context() with content_navigable() 2024-11-03 18:43:51 +01:00
Aliaksandr Kalenik
fec4737255 LibWeb: Remove unused members in PaintableFragment
Those are no longer used after we got rid of InlinePaintable.
2024-11-03 18:43:51 +01:00
Timothy Flynn
fd3f8b7645 LibWeb+WebContent: Fully implement WebDriver JSON deserialization 2024-11-03 17:51:58 +01:00
Timothy Flynn
7e1caf30a7 LibWeb: Implement some window/frame reference WebDriver AOs
We must also be careful in how we decide if a window's active browsing
context is top-level.
2024-11-03 17:51:58 +01:00
Timothy Flynn
0371097e2c LibWeb: Add overloads of some element reference AOs for JS objects
We currently only use these methods with AK JSON objects, but they're
actually spec'd for JS objects, as the WebDriver spec sort of assumes
we are sending encoded JS objects over the wire.

When we fully implement JSON deserialization for executing scripts, we
will need to invoke these AOs with JS objects.
2024-11-03 17:51:58 +01:00
Timothy Flynn
dc188329df LibWeb: Use C-style function pointers for ActionsOptions callbacks
This is a bit unfortunate, but if a function provided to this struct is
overloaded, the C++ compiler cannot distinguish which overload should be
assigned to the Function object. This is explained in detail here:
https://stackoverflow.com/a/30394755

C-style function pointers do work, however, and are fine here because
we only ever assign global free functions to these members.
2024-11-03 17:51:58 +01:00
Timothy Flynn
6fb8500a7a LibWeb+WebContent: Simplify hand-rolled script execution result struct
Instead of maintaining a list of script execution result types, which we
then map to WebDriver error types, just return the WebDriver error that
is specified by the spec. Then perform the JSON clone algorithm from the
caller in WebDriverConnection, again as specified by the spec. To do so,
this moves the JSON clone algorithm to its own file. This will also be
the future home of the JSON deserialize algorithm, which will need some
of the internal AOs implemented there.
2024-11-03 17:51:58 +01:00
Timothy Flynn
a5ca036d36 LibWeb+WebContent: Update and fully implement the JSON clone algorithm
We have the facilities now to fully implement this AO. Do so, and update
the AO to match the latest spec.
2024-11-03 17:51:58 +01:00
Timothy Flynn
3d0bbb4bcf LibWeb: Get the length property from collection through standard getters
DOMTokenList and FileList do not have the 'length' own property - their
prototypes have this property instead. So we must go through [[Get]] to
retrieve this property, which will consider the prototype.
2024-11-03 17:51:58 +01:00
Timothy Flynn
627eb90086 LibWeb: Update WebDriver's list of collection types
HTMLAllCollection and HTMLFormControlsCollection were implemented since
this AO was written, and DOMTokenList was added to the spec.
2024-11-03 17:51:58 +01:00
Andreas Kling
102cf345ba LibWeb: Recompute targetStep once more in "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.

Same exact idea as ac48222ed7, once again.
2024-11-03 17:51:44 +01:00
Andreas Kling
b82e34ed00 LibWeb: Flesh out the "in frameset" parsing state and add spec comments
This also implements two FIXMEs, which were covered by WPT tests.
2024-11-03 17:51:44 +01:00
Andreas Kling
ecc9fdf377 LibWeb: Fix incomplete assertion in the "in body" parsing state
We were incorrectly tripping an assertion failure on some WPT tests.
2024-11-03 17:51:44 +01:00
Andreas Kling
40ac3cc2c8 LibWeb: Implement HTML frameset parsing in the "in body" state
Covered by many WPT parsing tests, which will be imported.
2024-11-03 17:51:44 +01:00
Andreas Kling
cfa820922b LibWeb: Bail nicely on EOF in HTML parser "in body" state
If we reach the end of the token stream when "ignoring and moving on
to the next token" in the "in body" state, we should just not move
on to the next token, since there isn't one.

Covered by various WPT HTML parsing tests that will be imported in
a subsequent commit.
2024-11-03 17:51:44 +01:00
Gingeh
c2cd191864 LibWeb: Use machine epsilon when approximating cubic bezier 2024-11-03 17:35:20 +01:00
BenJilks
9395b266c6 LibWeb: Support vertical text hit detection and selection
If a PaintableFragment has a vertical orientation, use y instead of x to
compute the offset of each character in the text fragment.
2024-11-03 17:01:54 +01:00
BenJilks
02276360e9 LibWeb: Draw text vertically, for fragments with vertical writing-mode
For fragments with a vertical `writing-mode`. Rotate the text, so that
it is rendered on its side. This makes it fit into its layout box.
2024-11-03 17:01:54 +01:00
BenJilks
80e7e6dd7d LibWeb: Layout inline elements respective of writing-mode
Use the `writing-mode` property to determine what values should be used
for computing each element's rect on the screen. If it is a vertical
mode, swap the inline and block, lengths and offsets.

This only lays out whole inline formatting contexts vertically, and does
not currently support mixing the two orientations in a single context.
2024-11-03 17:01:54 +01:00
BenJilks
ede9012723 LibWeb: Make inline layout independent of direction
This patch separates the notion of x, y, width, and height, from
inline_offset, block_offset, inline_length, and block_length.
These can then be used to compute the final screen positions,
in respect of the desired layout direction. This is the terminology
used in https://drafts.csswg.org/css-writing-modes/#text-flow

This makes it possible to use this layout algorithm to flow
text in any direction. For example, vertically.
2024-11-03 17:01:54 +01:00
BenJilks
c3f3e93b7e LibWeb: Add writing-mode CSS property, and its values
Introduce the `writing-mode` property, as specified in
https://drafts.csswg.org/css-writing-modes/#block-flow
2024-11-03 17:01:54 +01:00
Jonne Ransijn
755b83c01a LibJS: Implement tc39/proposal-atomics-microwait (Atomics.pause)
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
Implements the https://github.com/tc39/proposal-atomics-microwait
proposal which has recently hit Stage 3.

This commit passes all relevant tests in `test262`.
2024-11-03 08:05:58 -05:00
Shannon Booth
01c2ecf355 LibJS: Update comments for WrappedFunction [[Call]] implementation 2024-11-03 07:41:49 -05:00
Shannon Booth
b5536db915 LibJS: Return void from SetDefaultGlobalBindings
Aligning with spec change:

https://github.com/tc39/ecma262/commit/052def
2024-11-03 07:41:49 -05:00
Shannon Booth
0a1c9e4038 LibJS: Inline somes AO's into InitializeHostDefinedRealm
Aligning with the editorial change in the spec of:

https://github.com/tc39/ecma262/commit/977a6c
2024-11-03 07:41:49 -05:00
Jonne Ransijn
f4e2476284 LibJS: Remember the position into the cached indices
There is no need to do a full linear search from start to end when
we can just remember the position and continue where we left off.
2024-11-03 11:26:23 +01:00
Aliaksandr Kalenik
2bd43e3603 LibWeb: Remove save() call in DisplayListPlayerSkia::add_mask()
This save() call did not have matching restore(). For mask application
it's display list builder responsibility to emit save() and restore()
so mask is applied only to relevant portion.

Progress on https://www.jetbrains.com/
2024-11-03 11:25:01 +01:00
rmg-x
c042971293 LibRequests+LibWeb: Propagate HTTP reason phrase
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
2024-11-02 21:05:07 +01:00
rmg-x
79046c73da RequestServer: Extract HTTP reason phrase from headers 2024-11-02 21:05:07 +01:00
Pavel Shliak
dcf8f2a31d LibGfx: Respect unpremultiplied alpha for JPEG XL 2024-11-02 18:48:35 +01:00
Timothy Flynn
13b7355ec1 LibWeb: Move some classes from the DOM namespace to the HTML namespace
The following classes are in the HTML spec and thus belong in the HTML
namespace:

* BeforeUnloadEvent
* HTMLFormControlsCollection
* RadioNodeList
2024-11-02 11:16:45 -04:00
Jonne Ransijn
69f96122b6 LibJS+LibWeb: Prevent double invocation of [[GetOwnProperty]]
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
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.
2024-11-02 12:27:02 +01:00
Jonne Ransijn
641c549463 LibJS: Split Call Instruction by CallType
Instead of branching on the `CallType` at runtime in a hot
instruction like `Call`, lets emit separate instructions
for each call type during codegen.
2024-11-02 11:15:58 +01:00
Jonne Ransijn
80f0900565 LibJS: Share argument values buffer between calls
This buffer is being created and then immediately destroyed,
let's reuse it to reduce memory allocations.
2024-11-02 11:15:58 +01:00
Timothy Flynn
f16eebb95c WebContent: Begin handling user prompts asynchronously
We have to handle user prompts during the exection of most WebDriver
endpoints. Of the ~50 endpoints which call this AO, ~20 are currently
currently async and handled here.
2024-11-02 11:09:41 +01:00