Commit graph

18188 commits

Author SHA1 Message Date
Linus Groh f418115f1b LibJS: Add initial support for Promises
Almost a year after first working on this, it's finally done: an
implementation of Promises for LibJS! :^)

The core functionality is working and closely following the spec [1].
I mostly took the pseudo code and transformed it into C++ - if you read
and understand it, you will know how the spec implements Promises; and
if you read the spec first, the code will look very familiar.

Implemented functions are:

- Promise() constructor
- Promise.prototype.then()
- Promise.prototype.catch()
- Promise.prototype.finally()
- Promise.resolve()
- Promise.reject()

For the tests I added a new function to test-js's global object,
runQueuedPromiseJobs(), which calls vm.run_queued_promise_jobs().
By design, queued jobs normally only run after the script was fully
executed, making it improssible to test handlers in individual test()
calls by default [2].

Subsequent commits include integrations into LibWeb and js(1) -
pretty-printing, running queued promise jobs when necessary.

This has an unusual amount of dbgln() statements, all hidden behind the
PROMISE_DEBUG flag - I'm leaving them in for now as they've been very
useful while debugging this, things can get quite complex with so many
asynchronously executed functions.

I've not extensively explored use of these APIs for promise-based
functionality in LibWeb (fetch(), Notification.requestPermission()
etc.), but we'll get there in due time.

[1]: https://tc39.es/ecma262/#sec-promise-objects
[2]: https://tc39.es/ecma262/#sec-jobs-and-job-queues
2021-04-02 10:47:40 +02:00
Linus Groh 563712abce Ports: Build Python with --disable-ipv6
The addition of some IPv6 related things makes the configure script
think we support it now. We don't.
2021-04-01 22:49:44 +02:00
AnotherTest 0f468a5013 LibRegex: Test alternatives in the expected order
That is, first try to match the left side of the alternation, and then
the right side.
Fixes part of #6042.
2021-04-01 21:55:47 +02:00
AnotherTest 6bbb26fdaf LibRegex: Allow references to capture groups that aren't parsed yet
This only applies to the ECMA262 parser.
This behaviour is an ECMA262-specific quirk, such references always
generate zero-length matches (even on subsequent passes).
Also adds a test in LibJS's test suite.

Fixes #6039.
2021-04-01 21:55:47 +02:00
vcollette 804ab79995
AK: Fix bogus return type of Result::release_error() (#6054)
The function was not used anywhere so the error was unnoticed.
2021-04-01 21:03:57 +02:00
Manuel Palenzuela a8f8e883c1 Ports: Updated the SDL2_mixer port to make it compile without
the opus and modplug music libraries.

Previously it wasnt compiling as we do not have ports of those
libraries. I have also changed the install location of the library so it
installs under /usr/include/SDL2 instead of /usr/local/include/SDL2.
2021-04-01 20:55:49 +02:00
Manuel Palenzuela 8324e48218 Ports: Added a SDL2_image port 2021-04-01 20:55:32 +02:00
Linus Groh 4e2d4b193a Ports: Get Python's --build value from config.guess 2021-04-01 20:54:05 +02:00
Alexander 86ecbd809f Ports: add libvorbis 2021-04-01 08:28:20 +02:00
Linus Groh 1ea8d73628 LibJS: Provide 'details' key in results object for duplicate test
The test-js program expects this to exist for 'result: "fail"' results
and would crash if any duplicated test(message) occurs, as we didn't
provide 'details' in that case.
2021-03-31 23:59:21 +02:00
Timothy Flynn 316e19c3ac Base: Add a bullet emoji • 2021-03-31 23:58:45 +02:00
Timothy Flynn 53ccfc1f4c LibWeb: Don't hit test a stacked child if it is behind its parent
When hit testing a stacked context, skip hit testing children if the
child's z-index is less than the parent's. The children are already
sorted by z-index, but also need to consider the parent.
2021-03-31 23:53:15 +02:00
Timothy Flynn 2cc10c62ee Base: Add test for a box placed over links with negative z-index
In this test, a set of links has a background box placed behind them via
a negative z-index. The expectation is that a hit test on a link during
a mouse-move event should select that link, and not the background box.
2021-03-31 23:53:15 +02:00
AnotherTest cbd62c472e UserspaceEmulator: Default-initialize the siginfo struct used in waitid
Otherwise it'll have some random value from the stack, and the kernel
will not bother setting it to zero.
Also add a debug print and tweak the FIXME message.
2021-03-31 23:49:26 +02:00
AnotherTest c4cf4ef111 Shell: Place Pipe redirections at the beginning of the redirection list
This makes commands like `foo 2>&1 | bar` behave as expected (which is
to pipe both stdout and stderr of `foo` to stdin of `bar`).
Previously, this would've piped stderr of `foo` into stdout, and the
stdout of `foo` into the stdin of `bar`.
2021-03-31 23:49:26 +02:00
AnotherTest e8cfa43717 Utilities/sleep: Go back to sleep if not interrupted by SIGINT
This can happen if the process is stopped and continued at a later time.
2021-03-31 23:49:26 +02:00
AnotherTest 5d19509616 Shell: Handle SIGCHLD after sending SIGCONT to job
This fixes `fg` and `bg` causing the shell to go into an infinite loop
of trying to `waitpid` until some current job changes state.

a.k.a. "Fix Shell backgrounding, yet again!" :P
2021-03-31 23:49:26 +02:00
AnotherTest 50f5959996 Shell: Use existing job state when waitpid() returns 0 in jobs 2021-03-31 23:49:26 +02:00
AnotherTest e3fd914187 Kernel: Send SIGCHLD to the parent process when changing stopped state
This is done also by linux (signal.c:936 in v5.11) at least.
It's a pretty handy notification that allows the parent process to skip
going through a `waitpid` and guesswork to figure out the current state
of a child process.
2021-03-31 23:49:26 +02:00
AnotherTest 47080941cc Shell: Replace '#if SH_DEBUG` with dbgln_if() and if constexpr 2021-03-31 23:49:26 +02:00
Idan Horowitz 3b201da473 Utilities: Add simple traceroute utility
This utility traces the route packets take to a user specified host.

QEMU user networking (the type of networking we currently have setup)
does not support sending "real" raw IPv4 packets, and as such we cant
specify a custom TTL value. As a result, this utility will only work
on real hardware, qemu setup with tun networking (requires root) and
other hypervisors that support bridged adapters (VirtualBox/VMWare).
2021-03-31 23:42:24 +02:00
Idan Horowitz aa6547492e LibC+ping: Move internet_checksum to serenity header
This will be useful for traceroute and any other packet related
application, so this will reduce code duplication.
2021-03-31 23:42:24 +02:00
Andreas Kling ea34ba6fa6 WindowServer+LibGfx: Rename menu_bar => menubar
We had a mix of "menu_bar" and "menubar". Let's just use "menubar"
everywhere since that feels the most natural to write.
2021-03-31 23:38:26 +02:00
Andreas Kling 0e798234c7 WindowServer+LibGfx: Remove code for drawing the old-style menu bar 2021-03-31 23:38:26 +02:00
Baitinq 19c578024b
Kernel: Added TIOCSTI ioctl placeholder (#6037)
Added a dummy TIOCSTI ioctl placeholder. This is a dangerous ioctl that
can be used to inject input into a tty. Added for compatibility. Always
fails with EIO.
2021-03-31 22:58:41 +02:00
Brendan Coles 6718941715 Ports: Links: Bump version from 2.19 to 2.22 2021-03-31 22:47:40 +02:00
Andreas Kling de2bf8d232 ResourceGraph.MenuApplet: Make these a little bit smaller 2021-03-30 23:43:24 +02:00
Andreas Kling 87b2725b1f Base: Tweak applet window order 2021-03-30 23:43:24 +02:00
Andreas Kling 2231205863 Taskbar: Reposition the applet area when the desktop rect changes 2021-03-30 23:43:24 +02:00
Andreas Kling 0cd60a28ba WindowServer+LibGUI: Plumb mouse/enter/leave events to applet windows
Since applet windows live in the applet area window, the AppletManager
has to keep track of which applet is hovered and send the appropriate
enter/leave events to the applet windows.

This makes applet tooltips work again. :^)
2021-03-30 23:43:24 +02:00
Andreas Kling 9bbc1c9c93 WindowServer+Taskbar: Show applets in taskbar :^)
WindowServer now collects applet windows into an "applet area" which is
really just a window that a WM (window management) client can position
via IPC.

This is rather hackish, and I think we should come up with a better
architecture eventually, but this brings back the missing applets since
the global menu where they used to live is gone.
2021-03-30 23:43:24 +02:00
Timothy Flynn 44602ae141 LibWeb: Create a new BFC when the overflow is neither visible nor clip
From MDN, a block overflow context should be created for "Block elements
where overflow has a value other than visible and clip."
2021-03-30 22:21:46 +02:00
Timothy Flynn e0f0aa7ce0 Base: Add test page for floating boxes with overflow=hidden 2021-03-30 22:21:46 +02:00
Timothy Flynn c21eafbf38 LibWeb: Compute position of relative blocks before placing them
Turns out compute_position should be invoked before placing the element
in normal flow. Otherwise, the position isn't set on the first layout.
The effect was that the block would "jump" into place on a secondary
layout.

This is a follow-up to commit:
deda7c8995
2021-03-30 22:21:46 +02:00
Timothy Flynn 5b617df496 LibWeb+WebContent: Support displaying tooltips in OOPWV 2021-03-30 21:21:17 +02:00
Timothy Flynn c503047c71 LibWeb: Get the first DOM node with a 'title' attribute for tooltip area
Rather than expecting the first parent to have a 'title' attribute,
search all ancestors.
2021-03-30 21:21:17 +02:00
Linus Groh 4fac577cf0 Ports: Use 'env bash' in hatari and pt2-clone package.sh shebang 2021-03-30 21:13:12 +02:00
Manuel Palenzuela 54b4d7611c Ports: Added a chester port, a very simple GameBoy emulator. 2021-03-30 21:11:23 +02:00
Andreas Kling 6d913db9fe WindowServer: Install WindowServer headers
This is a bit clunky since we really only need WindowType.h and don't
really want to consider any other headers "public" but this is just
to make the SDL port build again now that LibGUI includes WindowType.h
from WindowServer.

Long term we should probably figure out a way to only install "API"
headers from libraries.
2021-03-30 20:20:32 +02:00
Andreas Kling 077406dc36 LibJS: Fix two issues with array (length > INT32_MAX)
1. Allow Value(size_t) and use it for array length properties.

If an array length can't fit in an Int32 value, we shouldn't go out of
or way to force it into one. Instead, for values above INT32_MAX,
we simply store them as Double values.

2. Switch to generic indexed property storage for large arrays.

Previously we would always allocate array storage eagerly when the
length property was set. This meant that "a.length = 0x80000000" would
trivially DOS the engine on 32-bit since we don't have that much VM.

We now switch to generic storage when changing the length moves us over
the 4M entry mark.

Fixes #5986.
2021-03-30 13:52:56 +02:00
Andreas Kling 54f6b52f71 Kernel: Don't dump regions twice when crashing due to bad access
For whatever reason we were dumping regions when first handling the
page fault, and then again when tearing down the process.
2021-03-30 11:50:49 +02:00
Andreas Kling 664571c88f Kernel: Clarify Thread::block() a little bit with a better local name 2021-03-30 11:50:48 +02:00
one-some 279599cbed EditingEngine: Don't jump to the beginning or end of a non-existant word
Previously, when jumping to the next word on the last column of a line,
or when jumping to the previous word on the first column, it would
crash. This checks if that is the case, and if so, will do nothing.
2021-03-30 11:32:59 +02:00
Idan Horowitz 77601e09c8 FontEditor+TextEditor+Playground: Refuse to load device files
This prevents the undefined behaviour that would come up as a result of
doing so. (For example: opening "infinite" devices like /dev/full will
result in an infinite loop until exhaustion of memory)
2021-03-30 11:29:52 +02:00
Idan Horowitz aff774c8ac LibCore: Add Core::File is_device() helpers
The helpers check if the file is a block device or a character device
via stat and fstat.
2021-03-30 11:29:52 +02:00
Andreas Kling 4ee23752a5 Meta: Add thankyouverycool to the contributors list :^) 2021-03-30 10:52:21 +02:00
thankyouverycool d90d07ba52 Taskbar: Update ClockWidget to Calendar view changes
And give it a nice comfy spot in its new home.
2021-03-30 10:34:34 +02:00
thankyouverycool 4465b37897 LibGUI+Calendar: Add new month and year views to Calendar
And overhaul resize and paint events to fix layout edge cases in
which Calendar wasn't filling its parent widget completely. Ensures
month views always display prior month days for click navigation.
Converts Calendar app layout to GML.
2021-03-30 10:34:34 +02:00
thankyouverycool effb426757 MenuApplets: Remove old clock/calendar applet
Whatever the fate of MenuApplets, no need to maintain two
clock-calendars for now.
2021-03-30 10:34:34 +02:00
thankyouverycool fec9c8034d LibGUI: Don't inflate icon text rects beyond available width
Fixes wrapped text candidates not first eliding
2021-03-30 10:33:08 +02:00