Will be used by an upcoming JS prototype
(cherry picked from commit 41e14e3fc3aab8417b8687df7e4242982e97ba23)
Co-authored-by: Jamie Mansfield <[email protected]>
The existing rebaseline script is a bit limiting in that it can only
rebaseline a single test at a time. When making sweeping changes, this
patch will let us rebaseline any number of tests at once.
(cherry picked from commit f56b33f8d5924aceff823edc7c81e30dbaaacebf)
When the user resizes the browser window, AppKit will spin the current
run loop in the common mode. This patch allows socket events from IPC to
be processed while the resize is ongoing. This includes the WebView hook
to repaint.
(cherry-picked from commit 3bbe1b0c62c3b71fbfdd1eeb2291677e9cba1bbf)
Co-Authored-By: Andreas Kling <[email protected]>
When choosing the best image from an ICO file, prefer the entry with the
largest pixel area first, and only use bits-per-pixel as a tie-breaker.
This had regressed in commit b10fe7c136.
This fixes ICO files like Discord's favicon, where 16x16, 32x32, 48x48,
and 256x256 entries all advertise the same bpp. We were previously just
choosing whichever we saw first, which happened to be the 16x16 icon.
(cherry picked from commit b7c4cd511f0f1b02b90dc7be66333617e5a84cb3)
We can now use the latest checkout action. The guidance from the deploy
action is to now set persist-credentials to false during checkout for
cross-repo deployments.
This is based on:
https://github.com/LadybirdBrowser/ladybird/compare/e0dd182..46ce9b0
For more info, see:
https://github.com/orgs/community/discussions/26694
Note that although we use this token when pushing to the libjs-data
repo, it needs to be set when checking out the Serenity repo, as that
is where git operations are ultimately performed with
JamesIves/github-pages-deploy-action.
It's not clear to me if the permissions added here are needed. I think
it depends on repo settings I can't access. But it's not incorrect to
add them anyways.
There are actually a couple of issues here:
1. We are not properly perfect-forwarding the iterable to the Enumerator
member. We are using the class template as the constructor type, but
we would actually have to do something like this to achieve perfect
forwarding:
template <typname Iter = Iterable>
Enumerator(Iter&&)
2. The begin / end methods on Enumerator (although they return by const-
ref) are making copies during for-each loops. The compiler basically
generates this when we call enumerate:
for (auto it = Enumerator::begin(); it != Enumerator::end(); ++it)
The creation of `it` above actually creates a copy of the returned
Enumerator instance.
To avoid all of this, let's create an intermediate structure to act as
the enumerated iterator. This structure does not hold the iterable and
thus is fine to copy. We can then let the compiler handle forwarding
the iterable to the Enumerator.
On macOS, the first time TabBar::tabSizeHint is called, the count is
reportedly zero, and results in a floating point exception on x64.
(cherry picked from commit cbf1fd3e61710d9e8069ea1480b25734fd35d26f)
The ${resource_base_dir} no longer exists in this context. Thus LibWeb
tests were no longer actually running.
(cherry picked from commit cd581e9502dd765a61cd0a73a0c93f1ea1cb9b0f)
For some reason, moving the UI-specific CMake to its own files prevents
resource files from being copied to the Resource directory in the macOS
application. I'm not sure what the difference here is, but doing this
step during create_ladybird_bundle() works.
(cherry picked from commit 8641e78cdce4da621251b0faee755b4040f444c9)
POLLHUP is set when the remote end of the monitored fd is closed. There
may still be some buffered data to read from the socket, however. Some
systems do not set POLLIN in these cases. So we should just always try
to read from fds when we receive this event.
(cherry picked from commit a9f757973894e64ffd81d9baa12a361fa4d4607d,
tweaked due to additional Userland/ prefix in path)
One benefit of using `poll` over `select` is that we can re-use the poll
structure list. But there's no guarantee that the underlying system will
reset the `revents` field back to 0. So let's explicitly do so.
(cherry picked from commit f46b721c57b9ccde9ad3de3034f626e0a7607e92,
tweaked due to additional Userland/ prefix in path)
When a BackgroundAction completes, it resolves a Promise (stored on the
BackgroundAction object) with a reference to itself. The Promise will
never unset this resolved value, thus it will hold a strong reference to
the BackgroundAction until it is destroyed. But because the Promise is
owned by the BackgroundAction itself, we have a reference cycle, and
neither object can be destroyed.
The only user of BackgroundAction is the ImageDecoder process. The
consequence was that the ImageDecoder process would never release any
image data for successfully decoded images.
To fix this, instead of storing the promise on the class itself, we can
just create it as a local variable and pass it around.
(cherry picked from commit f20aa82c2770d1cf725384f64e9990df4d44b33a)
In particular, if given a value of -2147483648, we would invoke signed
integer overflow (which is UB).
(cherry picked from commit edd3b14ddf049048e5d6bd952677133237adb652)
Even though calling delete on a super property will ultimately throw a
ReferenceError, we must return the allocated register for the result of
the delete operation (which would normally be a boolean). If the delete
operation is used in a return statement, the bytecode generator for the
return statement must be able to assume the statement had some output.
(cherry picked from commit 5947c37637f8ea3d4c323a04e5e5dfe9fad5a4d7)
This defers accessing TA internal slots until we know we have a valid,
attached TA. Our implementation has assertions that guard against this.
(cherry picked from commit 962441b3cf34c1350877ac7c73351657c10f675b)
Almost the entirety of drag-and-drop operations are handled within
LibWeb. This patch just hooks up the UI-side operations to trigger
the events.
A FIXME is left here to open files in the browser that were not accepted
by the web page.
To support drag-and-drop for LibWeb, the drag events need the full mime
data from WindowServer, not just the list of stringified mime types. We
only provided the full data in the drop events. This patch provides the
Core::MimeData type, as well as other mouse-event information needed for
LibWeb (what buttons / modifiers are pressed).
To do this, we add a specific WindowServer IPC to inform the Application
of the event. We previously tagged mouse-move events with some drag data
and formed the drag event client-side. That extra data is removed in
favor of this new IPC.
The following classes are in the HTML spec and thus belong in the HTML
namespace:
* BeforeUnloadEvent
* HTMLFormControlsCollection
* RadioNodeList
(cherry picked from commit 13b7355ec10c21be90df997c66022e246c57656d)
This test caused some flakiness due to the about:blank load it triggers.
It causes headless-browser to receive a load event for about:blank. If
we have moved onto the next test before that event arrived, that test
would ultimately time out, as its own load will have been dropped while
the about:blank load is still ongoing.
This patch makes us wait for that iframe load event before completing
the test.
We may want to consider never sending subframe load events to the UI
process as well. We really only care about top-level page loads in the
receivers of that event.
(cherry picked from commit be9071834eb0c836ccd821adaa0134820e3f6297)
Invoking exec() entirely blocks the UI application's main thread. Qt
explicitly recommends against this. In practice, it seems prevents some
IPC messages from being handled by the UI until the dialog is closed by
the user.
Instead, use open() (which is non-blocking) and set up a signal handler
to deal with the result.
(cherry picked from commit ea9abe26e1c40c0d2e96007bf7d69afb49a7052a)
There was a timing issue here where WebDriver would dismiss a dialog,
and then invoke another endpoint before the dialog was actually closed.
This is because the dismissal first has to hop over to the UI process to
close the graphical dialog, which then asynchronously informs WebContent
of the result. It's not until WebContent receives that result that the
dialog is considered closed, thus those subsequent endpoints would abort
due a dialog being "open".
We now wait for dialogs to be fully closed before returning from the
dismissal endpoints.
(cherry picked from commit 0722a3b1c091adbafc056686ebedbf5c2db84207)
Similar to commit c2cf65adac78912883996153fb608dafe389b6e0, we should
avoid spinning the event loop from the WebContent-side of the WebDriver
connection. This can result in deadlocks if another component in LibWeb
also spins the event loop.
The AO to await navigations has two event loop spinners - waiting for
the navigation to complete and for the document to reach the target
readiness state. We now use NavigationObserver and DocumentObserver to
be notified when these conditions are met. And we use the same async IPC
mechanism as script execution to notify the WebDriver process when all
conditions are met (or timed out).
(cherry picked from commit bf0bc62654803565a6f39ade63d9172cc48c085a)
This contains a hook to be notified when a navigable navigation is
complete, to be used by WebDriver.
(cherry picked from commit 74ef9dc3936d678fdf811bb3c1b39a6ffba2b106)
Some callers (namely WebDriver) will want to stop receiving updates from
the DocumentObserver.
(cherry picked from commit 247307a2a28e92b20a57d127eed73a093dd4e3d3)
Contradictory to the spec, the Set Timeouts endpoint should update the
existing timeouts configuration in-place, rather than replacing it. WPT
expects this, and other browsers already implement this endpoint this
way.
(cherry picked from commit dae6200c1dab586258a8a970ba308c6b2f1cad9c)
Namely, all fields in the timeouts object may now be null. There are a
few calling AOs that we will want to bring up to date as well.
(cherry picked from commit 8396afeb76b5229c385525d307a8d91efa45d6ff)
We've added a few JS::Handle members to this class over time. Let's
avoid creating a new GC root for each of these, and explicitly add a
visitation method.
(cherry picked from commit 048b51eb54d003af5dc202af1b16bb690b1348f9)
The underlying concept is the same, but this method was renamed in the
spec to drop the word "connected".
(cherry picked from commit 022e2b8a94497c01138840478f76af07ddcf51da)
Some of this code is older than widespread use of GCPtr. These functions
returning raw pointers has been a point of confusion at times, so lets
just indicate that they are non-null.
(cherry picked from commit a96a762305423965a9697c2b7038a229d96ac734)
This is a method defined in the WebDriver spec, but requires access to a
bunch of private fields in these classes, so this is implemented in the
same manner as the reset algorithm.
(cherry picked from commit 516f5f70081526ddef2d4a88fc5a1ae916e12fab)
Instead of having N functions all implement the same practice of looping
until an async event has arrived, this templatizes the bulk of the work.
(cherry picked from commit 922837f31b4cc66f6a3acd875962b54c6d547f65)
These aren't required to comply with the UIEvents spec, but they are
required by WebDriver.
(cherry picked from commit 5b2633d90f81d0098d5d7cea1274b98c91851fae;
amended to change `MOD_KEYPAD` to 32 to match serenity's `Mod_Keypad`
in Kernel/API/KeyCode.h)
Multi-byte code point presses do not have a UIEvents::KeyCode value, so
we would previously set the event's key field to "Unidentified".
(cherry picked from commit a11e5055c7f225da3b96571e892042868fd2af18)
We have support for using (shift+)tab to move focus to the next/previous
element on the page. However, there were several ways for this to crash
as written. This updates our implementation to check if we did not find
a node to move focus to, and to reset focus to the first/last node in
the document.
This doesn't seem to work when wrapping around from the first to the
last node. A FIXME has been added for that, as this would already not
work before this patch (the main focus here is not crashing).
(cherry picked from commit 96b5646fc116a98dac80559b9a4be2c149f2e157)
The spec says we don't need to await navigations if we navigate to the
same URL that we are already on, but at least in our implementation, we
should still await the page load. Otherwise, we will invoke WebDriver
endpoints on the wrong page.
(cherry picked from commit 13fe3477ab8ac253bd7346d50b3224baf891872e)
Our handling of left vs. right modifiers keys (shift, ctrl, etc.) was
largely not to spec. This patch adds explicit UIEvents::KeyCode values
for these keys, and updates the UI to match native key events to these
keys (as best as we are able).
(cherry picked from commit 4fcaeabe1a6acd9f4d5fd811a36f2e86748b2a72;
amended to make the rest of the system build and to keep `Mod_AltGr`
around in addition to adding it as a key)
Co-authored-by: Nico Weber <[email protected]>
For example, pressing just the shift key should not producde a keypress
event.
(cherry picked from commit 448754d95dc797b44d9b066c1e37dabec79d79e6;
amended to not use ICU in CharacterTypes.cpp)
Fire the events before handling any close requests or selection changes.
Pages must have an opportunity to cancel the events.
(cherry picked from commit 3925317c118e23a9b87b65ca792c5d94a92c98a7)
If the user only presses the shift key, for example, we are required to
still send that event to WebContent and generate the corresponding JS
events. Unfortunately, NSApp does not inform us of these events via the
keyDown/keyUp methods. We have to implement the flagsChanged interface,
and track for ourselves what modifier keys were pressed or released.
(cherry picked from commit eabd5b0f2271e7a89727daf80dd28623711f3416)
The expensive part of creating a segmenter is doing the locale and UCD
data lookups at creation time. Instead of doing this once per text node,
cache the segmenters on the document, and clone them as needed (cloning
is much, much cheaper).
On a profile loading Ladybird's GitHub repo, the following hot methods
changed as follows:
ChunkIterator ctor: 6.08% -> 0.21%
Segmenter factory: 5.86% -> 0%
Segmenter clone: N/A -> 0.09%
(cherry picked from commit 5d7175874258f00763adcced230149dd1379e4a6;
mended as usual for Unicode::Segmenter -> Locale::Segmenter, and also
to resolve minor conflicts due to serenity not yet having
LadybirdBrowser/ladybird#1106. Also, due to serenity not using ICU,
this doesn't have a big performance effect over here, but it still
makes future cherry-picks easier)
Our current text iterator is not aware of multi-code point graphemes.
Instead of simply incrementing an iterator one code point at a time, use
our Unicode grapheme segmenter to break text into fragments.
(cherry picked from commit f0105b473b9cc3446ec36359b559db9a8e78446d;
amended as usual for Unicode::Segmenter -> Locale::Segmenter, and to
tweak expected/multi-code-point-graphemes.txt for serenity's superior
emoji glyphs)
We currently use a naive word segmentation, looking for ASCII spaces to
mark a word boundary. Use LibUnicode's complete implementation instead.
(cherry picked from commit 430c9d3e3fb6ec9e2aa3d962381672b70957c395;
amended to use Locale::Segmenter instead of Unicode::Segmenter due
to LibLocale and LibUnicode being two distinct libraries in serenity)
In text documents, pressing the left/right arrow keys with the cmd key
pressed should be treated as home/end key presses.
(cherry picked from commit bf9d05d97a570e8d4ebd83ca7e757938c2b504b3)
This implementation is based on the same feature I added to Serenity's
TextEditor:
https://github.com/SerenityOS/serenity/pull/17477
(cherry picked from commit ecf2cc600bea8f8396061f5fe6aba8358a033bbb;
amended to change Unicode::Segmenter to Locale::Segmenter due to
LibLocale and LibUnicode being separate libraries in serenity)
We will be adding a word segmenter as well, so this is to disambiguate
the two.
(cherry picked from commit eece7697fdcaf50eed98fff069c5e678ac425784;
amended to fix conflict due to Serenity's Segmenter still being in
LibLocale, while upstream combined LibLocale and LibUnicode)
On Linux/Windows, the ctrl key is used in conjunction with arrow keys to
jump word-by-word in text documents. On macOS, the option key is used
(which is mapped to the alt key code).
(cherry picked from commit feecf89d65b3f76a4fe090daa01928439efb9fce;
amended to fix minor conflict)
The spec does not define activation behavior of ctrl/cmd clicks, so we
have to go a bit ad-hoc here. When an anchor element is clicked with the
cmd (on macOS) or ctrl (on other platforms) modifier pressed, we will
skip activation of that element and pass the event on to the chrome. We
still dispatch the event to allow scripts to cancel the event.
(cherry picked from commit 40b2d24d5585a94f09f521bb0ceb055dcae7b6e9)
For all intents and purposes, the cmd (super) key on macOS should be
treated as the ctrl key.
(cherry picked from commit 71b25e3e5a70937f1e2031b94541c04a68d28efa;
amended to fix minor conflict)
The motivation is to have `code_point_has_*_control_general_category()`
functions, so that clients don't have to look at `GeneralCategory`
values directly and hence don't have to worry about
`code_point_has_general_category()` returning an empty Optional. This
isn't quite achieved since some code inside LibLocale still uses some of
them, but it removes uses in LibGfx and LibJS.
This kind of cherry-picks the 2nd commit of
LadybirdBrowser/ladybird#239 (aa3a30870b58c47cb37bce1418d7e6bee7af71d9):
The Lexer.cpp, RegexByteCode.cpp, CharacterTypes.h, KeyboardEvent.cpp
changes are by trflynn.
This does not (yet?) pick up the new type for `GeneralCategory`. In the
future, we might want to make the generator generate a
`GeneralCategoryEnum` type and have the
`AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL` in Forward.h, but at the moment
that makes things more complicated. (It also means we don't pick up the
RegexParser.cpp changes.)
Co-authored-by: Tim Flynn <[email protected]>
The motivation is to have `code_point_has_*_property()` functions, so
that clients don't have to look at `Property` values directly and hence
don't have to worry about `property_from_string()` returning an empty
Optional. This isn't quite achieved since some code inside LibLocale
still uses some of them, but it removes uses in LibGfx and LibJS.
This kind of cherry-picks the 1st commit of
LadybirdBrowser/ladybird#239 (aa3a30870b58c47cb37bce1418d7e6bee7af71d9):
The TextLayout.cpp, Lexer.cpp, CharacterTypes.h, Emoji.cpp changes are
by trflynn.
This does not (yet?) pick up the new type for `Property`. In the future,
we might want to make the generator generate a `PropertyEnum` type and
have the `AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL` in Forward.h, but at the
moment that makes things more complicated. (It also means we don't pick
up the RegexParser.cpp changes.)
Co-authored-by: Tim Flynn <[email protected]>
(cherry picked from commit 12f177e9e94ca71c619ec1171078e8635debde09;
amended to remove mention of ICU in commit message, and to resolve
a minor conflict in CharacterData.h due to serenity cherry-picking
LadybirdBrowser/ladybird#901 before this change)
(cherry picked from commit 14071c52f94e3f7149ee60325ae855afdd94d088;
amended to tweak commit message and Intl/Segmenter.h to not say
"ICU", and undid FIXME removal in Segmenter.prototype.segment.js
since these checks still fail in serenity)
There are many WPT subtests which validate how we behave against frames
that have been removed. They do this by adding an iframe element with a
button whose click action removes the iframe element. When the click is
dispatched, the spec would have us generate a mouse event relative to
that iframe, rather than the top-level frame, thus the click would miss
the target button.
Serendipitously, a spec issue and PR were just opened to generate mouse
events relative to the top-level frame. This patch implements that PR;
it has some editorial issues to be resolved, but is a clear improvement
for these tests.
(cherry picked from commit 0042bbb68d906a557ddc614392075a961531c917)
For example, in the following abbreviated test HTML:
<span>some text</span>
<script>println("whf")</script>
We would have to craft the expectation file to include the "some text"
segment, usually with some leading whitespace. This is a bit annoying,
and makes it difficult to manually craft expectation files.
So instead of comparing the expectation against the entire DOM inner
text, we now send the inner text of just the <pre> element containing
the test output when we invoke `internals.signalTextTestIsDone`.
(cherry picked from commit bf668696de9a68bbcd6adfeaac809a475da015dc;
amended a bit but not as much as one might think -- see PR for details)
The events tested here are decidedly async. We also can't really write
sync tests of the form "test(async () => {})". Nothing will await the
async callback.
(cherry picked from commit c9cbaeb59d6f699b33bf3924688987b3ca917fee)
These tests were mostly async tests written in a manual way. This ports
them to use the standard asyncTest() infrastructure.
This is mostly just to reduce calls to internals.signalTextTestIsDone,
which will have a required parameter in an upcoming test.
(cherry picked from commit 96082d6ae127832eb9b644d2abee892284317b6a)
This happens when window.close() is invoked immediately upon a window
being opened.
(cherry picked from commit ce11a907263670a326ccb4a9625bfeaa65dac937)
This avoids a crash seen in WPT when a click event is fired on a BC that
has been removed from the document.
(cherry picked from commit 95bf6c98779bbb879b19319884389148e8cd2fd2)
We are currently trying to access the current parent and top-level
browsing contexts from the current BC itself. However, if the current BC
is closed, its association to the parent and top-level BCs is lost, and
we are no longer able to handle WebDriver endpoints involving those BCs.
Instead, let's store the parent and top-level BCs separately, and update
them in accordance with the spec.
(cherry picked from commit ab3cfd9bbb3d572d2e1ce4337e112d10ac0e94a3)
Attributes have a max value length of 1024. So we theoretically need to
support values in the range -${"9".repeat(1023)} to ${"9".repeat(1024)}.
These obviously do not fit in an i64, so we were previously failing to
parse the attribute.
We will now cap the parsed value to the numeric limits of an i64, after
ensuring that the attribute value is indeed a number.
(cherry picked from commit ba1189cd1c47ab0593e0c3d7eee85e7aafc3462d)
We were only looking at the current top-level navigable and its children
when searching for the specified window handle. We need to search *all*
known navigables if the handle belongs to a window not in the current
tree.
(cherry picked from commit 47e9357243c5e561576d03ed8d1c444076847272)
Similar to script execution, this spins the WebDriver process until the
action is complete (rather than spinning the WebContent process, which
we've seen result in deadlocks).
(cherry picked from commit 709deeb482a6433abbcb194551788bc5409166f4)
This implements execution of the pointer up, pointer down, and pointer
move actions.
This isn't 100% complete. Pointer move actions are supposed to break
the move into iterations over the specified duration, which we currently
do not do.
(cherry picked from commit 8000837f7821fe9854156c7ae1349d37c77e89b2)
There's a lot of parsing involved in action extraction. So this patch
implements only that - actually executing actions will be a future
patch.
(cherry picked from commit 6cf7d07a989bb6d7ddc897a444053deef7192c9c)
These concepts are rather tightly coupled. This implements the types and
AOs needed to handle the Perform Actions endoint.
(cherry picked from commit 0c98c7637e1daa572a29e6cce7ca703452873264)
In particular, we need to convert web element references to the actual
element. The AO isn't fully implemented because we will need to work out
mixing JsonValue types with JS value types, which currently isn't very
straight forward with our JSON clone algorithm.
(cherry picked from commit 94c243acd6873a9fd9115f1467093326392f06c0)
Move the helper to convert MouseButton to its DOM event code to a public
header. And add a helper to convert in the opposite direction.
(cherry picked from commit 5e99715377cad26174344b9cca3e3cb8a7eb93ad)
We are currently returning a JSON object of the form:
{
"name": "element-6066-11e4-a52e-4f735466cecf",
"value": "foo"
}
Instead, we are expected to return an object of the form:
{
"element-6066-11e4-a52e-4f735466cecf": "foo"
}
(cherry picked from commit 157d41bb0dae1ab3b04e079a72184b99f2137c5c)
We were returning the handle of the already opened window, rather than
the handle of the window we just opened.
(cherry picked from commit 6cba55893e6cd5be39b2f8597970380e7f08b006)
Some callers (namely WebDriver) will need access to the navigable opened
by these steps. But if the noopener parameter is set, the returned proxy
will always be null.
This splits some of the Window open steps into an internal method that
returns the chosen navigable.
(cherry picked from commit 981aaba96cd6ee752d9cf76595731612898fe05c)
Namely, we must always return NoSuchError invalid element IDs, and we
must handle stale elements.
(cherry picked from commit 92a37b3b1a62cf8ed6bc942229cb77bce01ec815)