Commit graph

2435 commits

Author SHA1 Message Date
implicitfield
012f2fd712 mkfs.fat: Fill in the last known free cluster count hint
This allows generated FAT32 file systems to pass fsck.fat without
tripping any warnings.
2024-02-26 13:26:47 -07:00
implicitfield
e91f60e0f5 CMake: Replace bespoke utility name mangling logic
Instead of manually removing the '.cpp' extension, we can simply ask
CMake to give us the file name without the last extension.
2024-02-26 13:26:47 -07:00
Andrew Kaster
0a55749a39 Ladybird+Userland: Use ByteString for candidate server paths
We've adopted a stance that paths should be ByteStrings rather than
UTF-8 strings, so apply that to the Ladybird helpers.
2024-02-26 13:16:27 -07:00
Timothy Flynn
108521a566 LibWeb+LibWebView+WebContent: Implement more <input type=file> behavior
We had previous implemented some plumbing for file input elements in
commit 636602a54e.

This implements the return path for chromes to inform WebContent of the
file(s) the user selected. This patch includes a dummy implementation
for headless-browser to enable testing.
2024-02-26 14:18:49 +01:00
Hediadyoin1
21a21c6a11 LibDeviceTree: Add a simple DeviceTree class
This makes it easier to work with device tree nodes and properties, then
writing simple state machines to parse the device tree.
This also makes the old slow traversal methods use the
DeviceTreeProperty helper class, and adds a simple test.
2024-02-24 16:43:44 -07:00
Sönke Holz
0b0ea19d12 LibELF+readelf: Add support for RISC-V dynamic relocation types 2024-02-24 16:05:50 -07:00
Tim Ledbetter
f3a68fc80d mktemp: Ensure --tmpdir and template paths are concatenated correctly
Previously, using the `--tempdir` option with a template containing a
path didn't work correctly, as the template path would be discarded.
2024-02-24 15:57:14 -07:00
implicitfield
84252db976 Utilities: Add mkfs.fat
This adds a basic `mkfs.fat` utility, which can format FAT12, FAT16
and FAT32 partitions.

This does have a few limitations, namely in that FAT12 formatting is
limited to a set known floppy disk sizes, and we can only generate
512-byte sectors.
2024-02-24 15:54:52 -07:00
implicitfield
f2503b2048 CMake: Allow the names of utilities to contain extensions
Previously, we would remove the "longest extension" from each file name
when parsing it as the name of a utility, which made it impossible for
the names of utilities to contain any extensions.
2024-02-24 15:54:52 -07:00
Fabian Dellwing
29ef508b4e tail: Collapse repeated error handling into statement expression
Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2024-02-24 15:48:36 -07:00
Fabian Dellwing
e40aca2d77 tail: Handle truncation in follow mode 2024-02-24 15:48:36 -07:00
Andreas Kling
8586897928 headless-browser: Don't choke on subframe load completions
This didn't break any existing tests, but I have to do this for an
upcoming test to not bring everything down.
2024-02-24 19:56:08 +01:00
ddorando
7eec2d6c21 useradd: Don't crash on -m if directory already exists 2024-02-23 09:52:08 +01:00
ronak69
a42cf020ea LibTest: Return 0 if all test cases pass and 1 otherwise from TEST_MAIN
Before, TEST_MAIN used to return the return value of TestSuite::main()
function (which returns the number of test cases that did not pass, so
it can be >=256) directly.

The run-tests utility determines the success / failure of a test suite
binary by examining its (or i.e. TEST_MAIN's) exit status.

But as exit status values are supposed to be between 0 and 255, values
>=256 will get wrapped around (modulo 256), converting a return value of
256 to 0.

So, in a rare case where exactly 256 test cases are failing in your test
suite, run-tests utility will display that the test suite passed without
any failures.

Now, TEST_MAIN just returns 0 if all of the test cases pass and returns
1 otherwise.
2024-02-21 22:45:51 +01:00
Nico Weber
24a469f521 Everywhere: Prefer {:#x} over 0x{:x} in format strings
The former automatically adapts the prefix to binary and octal
output, and is what we already use in the majority of cases.

Patch generated by:

    rg -l '0x\{' | xargs sed -i '' -e 's/0x{:/{:#/'

I ran it 4 times (until it stopped changing things) since each
invocation only converted one instance per line.

No behavior change.
2024-02-21 17:54:38 +01:00
Shannon Booth
d18f7145ad patch: Remove empty files after patching 2024-02-21 14:11:49 +01:00
Nico Weber
0160f737e2 LibGfx/ICC+icc: Be lenient about invalid profile creation datetimes
Before, we used to reject profiles where the creation datetime was
invalid per spec. But invalid dates happen in practice (most commonly,
all fields set to 0). They don't affect profile conversion at all,
so be lenient about this, in exchange for slightly more wordy code
in the places that want to show the creation datetime.

Fixes a crash rendering page 2 of
https://fredrikbk.com/publications/copy-and-patch.pdf
2024-02-21 13:37:08 +01:00
Nico Weber
6a8e418e40 pdf: Add a --render-bench option
It's similar to `--render <filename>.png`, but skips the "save to
file" step. Useful for benchmarking, in part because our png codec
is so slow.
2024-02-19 07:16:05 +00:00
Ollrogge
37e595a96c Utilities: Add xxd utility 2024-02-18 23:56:37 +01:00
Ali Mohammad Pur
b7a8081b0f wasm: Make --arg use a more useful value format
This allows the user to pass very specific values instead of a u64 value
that is later cast to the underlying type.
The change also adds support for passing v128 values:
- v(i64.const 4) (splat 4)
- v128.const 0x4 (just a few bits specificed, everything else = 0)
2024-02-18 23:50:50 +01:00
Fabian Dellwing
e8bdb7e5f8 tail: Support skip from start mode
This commit adds the possibility to skip the first NUM lines of a
file by calling `tail -n +NUM filename`.
2024-02-18 23:46:46 +01:00
Fabian Dellwing
7beabc8e91 tail: Use File::seek() to determine seekability
Some change in the past made `File::tell()` not return an error if
a file is not seekable. So instead do a real seek to check.
2024-02-18 23:46:46 +01:00
MacDue
2ede299b4a headless-browser: Run .svg dump tests
Previously, the check for `.html` meant that `.svg` tests were excluded.
This led to a few `.svg` with missing or bit-rotted expectations, which
have now been added/updated.
2024-02-18 18:33:11 +01:00
MacDue
012cb7f71e headless-browser: Fix loaded URL about:blank check
This check was meant to let about:blank through, but it checked the URL
from the file path, not the `loaded_url`, so still crashed on
about:blank.
2024-02-18 18:33:11 +01:00
Tommy van der Vorst
08c02ad888 LibWeb: Only dump layout and text tree for the desired URL
Before this change, the rebaseline script would generate reference
based on 'about:blank' (at least running it on my macOS system).
This commit allows 'about:blank' through the assertion and only dumps
the layout tree when theloaded URL matches the one we are interested
in.
2024-02-16 15:05:30 +01:00
Gurkirat Singh
fc8f6c07b4 Utilities/pkg: Integrate LibSemVer for update information
Along with this, Port.h is include which helps generalising common
information for the port package, like it's name and version. With
SemVer complaint versions, it is possible to show positive change
(upgrade) or negative change (downgrade) in the installed ports.

However, for some non-complaint versions (eg. using git commit hash),
non-equality (`!=`) is used to notify upgrade. Since there is no
algorithm (without git history) to check the order of commits, it is
not possible to inform whether it is an upgrade or downgrade.
2024-02-15 18:23:05 +01:00
Tim Ledbetter
89c0e3541e Fuzzers: Add PAM fuzzer 2024-02-14 19:58:46 +01:00
Andrew Kaster
bb9da0ed8d Ladybird: Plumb overriding root certificate paths through the chromes 2024-02-08 08:49:32 -07:00
Kyle Lanmon
e09245badd cut: Add -c,--characters option 2024-02-08 07:20:50 -07:00
Erick Howard
3e0d1becd4 cp: Add --interactive/-i flag
- Add interactive flag which tells `cp` to prompt before overwriting
  files
- Accept 'yes', 'no', 'n', and 'y' as input, all other inputs will
  result in the prompt being shown again
2024-02-08 07:11:44 -07:00
Dan Klishch
677bcea771 ntpquery: Use AK::convert_between_host_and_network_endian
Instead of polluting global namespace with definitions from
libkern/OSByteOrder.h and machine/endian.h on MacOS, just use AK
functions for conversions.
2024-02-06 04:37:47 -07:00
Dan Klishch
3e43d15440 Everywhere: Prefer VERIFY over assert() 2024-02-05 07:03:53 -05:00
Nico Weber
c4780f4ee1 image: Add an --invert-cmyk option
This is useful for working with CMYK jpegs extracted from PDFs
by mutool. CMYK channels for jpegs in PDFs are inverted compared to
CMYK channels in standalone jpegs (!), and mutool doesn't compensate
for that.

You can now do:

    mutool extract  ~/Downloads/0000/0000711.pdf 461

Followed by:

    Build/lagom/bin/image -o out.png \
        --invert-cmyk \
        --assign-color-profile \
            Build/lagom/Root/res/icc/Adobe/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        cmyk.jpg

Doesn't exactly roll off the keyboard, but at least it's possible.

(We should probably add an implicit default CMYK color profile if
the input file doesn't have one, and assume conversion to sRGB when
saving to a format that can only store RGB.)
2024-02-04 21:34:53 +01:00
Nico Weber
fa3fead7a4 image: Move ppm_ascii down a bit
It belongs close to `quality` since it needed at output time.

No behavior change (except for `--help` output order).
2024-02-04 21:34:53 +01:00
Andrew Kaster
36cd2fb7c5 Ladybird+WebContent: Update IPC calls to handle multiple traversables
The IPC layer between chromes and LibWeb now understands that multiple
top level traversables can live in each WebContent process.

This largely mechanical change adds a billion page_id/page_index
arguments to make sure that pages that end up opening new WebViews
through mechanisms like window.open() still work properly with those
extra windows.
2024-02-03 20:51:37 -05:00
Andrew Kaster
48ce8fb4e9 Ladybird: Add ability to create a tab without creating a new WebContent 2024-02-03 20:51:37 -05:00
Nico Weber
eeb0d6f52b image: Remove "do_" prefix on two function names
These were here due to the prefix-less name conflicting with a local
bool, but now that options are in a struct that's no longer a problem.

No behavior change.
2024-02-02 07:20:02 +01:00
Nico Weber
d575d4fb9b image: Extract option parsing to separate function
No behavior change.
2024-02-02 07:20:02 +01:00
Nico Weber
6dc5608d95 image: Allow saving CMYK jpegs
`image` can't transform from RGB to CMYK yet, so the only way to
do this is by having a CMYK input.

For example, this works now (and it does a full decode and re-encode):

    Build/lagom/bin/image -o out.jpg \
        Tests/LibGfx/test-inputs/jpg/buggie-cmyk.jpg

Using this to convert `.pam` files written by `mutool extract`
to jpegs is a somewhat convenient method of looking at these
.pam files.
2024-02-02 07:19:18 +01:00
Nico Weber
2298aac1d1 image: Only create output file for known extensions
Previously `image -o foo.asdf foo.png` would create a 0-byte foo.asdf
before complaining that it doesn't know how to write .asdf images.

(Lifetimes of temporaries are extended to the end of the full
expresion, so this is fine.)
2024-02-02 07:19:18 +01:00
Nico Weber
70eac0fbe8 pdf+MacPDF: Use new Build/Root/lagom/res directory 2024-01-30 18:43:06 -07:00
Kemal Zebari
22ea2f638a mktemp: Make sure to use target directory option argument
Previously, we ignored the -p argument if it was specified. This
would resort in a crash because final_target_directory wasn't given a
value.

This snapshot does away with giving this variable an Optional<> and
just has the -p argument be its default value.
2024-01-30 00:12:54 +00:00
Sam Atkins
f4b345258d tar: Remove unnecessary conversions to String
We use these canonicalized_path variables as StringViews, so it doesn't
matter if they are a String or ByteString. And they're paths so
shouldn't be String anyway.
2024-01-29 23:14:39 +00:00
Timothy Flynn
85b8971a80 Ladybird+LibWeb+WebContent: Port the did_request_cookie IPC to String 2024-01-26 20:22:39 +01:00
Nico Weber
db4982bd29 LibGfx+image: Implement writing ICC profiles to jpeg files 2024-01-26 14:03:20 -05:00
Andrew Kaster
d85a0e306a headless-browser: Add option to filter which tests are run with a glob
This is the same feature that run-tests has on Serenity.
2024-01-25 09:44:42 -07:00
Nico Weber
fac48fdda4 image: Allow converting CMYK inputs to RGB
This worked in PDFs for a while, but now `image` can also do
CMYK->RGB conversions that actually use color profiles :^)
2024-01-25 15:53:44 +01:00
Nico Weber
0acc370f7b image: Load images that contain CMYK data into a CMYKBitmap
Every single of images's functions then go ahead and error out on
CMYKBitmaps for now.

(Alternatively, we could make them the low-quality CMYK->RGB
conversion that previously happened implicitly, but let's go
with this for now.)

(With this structure, we could also do something smarter for
Vector images in the future.)

Here's how this looks:

    % Build/lagom/bin/image \
        -o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
    Runtime error: Can't save CMYK bitmaps yet, convert to RGB first
                   with --convert-to-color-profile

    % Build/lagom/bin/image \
        --convert-to-color-profile serenity-sRGB.icc \
        -o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
    Runtime error: No source color space embedded in image.
                   Pass one with --assign-color-profile.

    % Build/lagom/bin/image \
        --assign-color-profile path/to/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        -o out.png Tests/LibGfx/test-inputs/jpg/ycck-2111.jpg
    Runtime error: Psych, can't convert CMYK bitmaps yet either

As usual, serenity-sRGB.icc is from
`Build/lagom/bin/icc  -n sRGB --reencode-to serenity-sRGB.icc` and
the adobe cmyk profiles are available at
https://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html
which ultimately leads to:
https://download.adobe.com/pub/adobe/iccprofiles/win/AdobeICCProfilesCS4Win_end-user.zip
2024-01-25 15:53:44 +01:00
Nico Weber
2c40886851 image: Update an error string
We have been able to write .jpg files for a while now.
2024-01-25 15:53:44 +01:00
Nico Weber
8a56abf48b image: Move image writers up that don't return bytes
Makes the early returns a bit easier to see.

Also alphabetize them while touching these lines.

No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
96c71b7042 image: Move image loading code into a separate function
Haters will say this is overkill, but this function will do a bit more
once we allow loading CMYK data.

No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
653b614611 image: Move image saving code into helper function
No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
0681df7f3b image: Move profile conversion code into helper function
No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
48a0fb1e8e image: Introduce a struct "LoadedImage" to hold bitmap and icc data
This makes it easier to move the color space conversion code out
into a helper function, and will be used to pass around CMYK bitmaps.

No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
a339f297d1 image: Move image modification code to helper functions
No behavior change.
2024-01-25 15:53:44 +01:00
Nico Weber
da243ebb8b image: Use Error::from_string_view() for errors
...instead of warn() + manual return.

Before:

    % Build/lagom/bin/image -o out.asdf in.png
    can only write .bmp, .png, .ppm, and .qoi

Now:

    % Build/lagom/bin/image -o out.asdf in.png
    Runtime error: can only write .bmp, .png, .ppm, and .qoi

That doesn't look worse, and it's less code (and makes moving the
code into helper functions easier).
2024-01-25 15:53:44 +01:00
Sam Atkins
7bcb560060 uptime: Add -s/--since option to output only when the system came online
This also matches Linux and the BSDs.
2024-01-25 09:07:32 +01:00
Sam Atkins
8faeb13036 uptime: Bring output closer to Linux/BSDs, and add -p flag
The -p flag is equivalent to the previous behavior: outputting the
uptime in a human-readable form.

We don't seem to expose the number of online users or the load averages,
so those sections are missing from the output compared to those OSes.
2024-01-25 09:07:32 +01:00
Sam Atkins
388856dc7e AK+Userland: Return String from human_readable_size() functions 2024-01-25 09:07:32 +01:00
kleines Filmröllchen
3f0a77e788 disasm: Allow disassembling just one symbol
This is done in a crude way for now in that we
disassemble all instructions up to the symbol without printing them.
2024-01-22 20:54:16 -07:00
kleines Filmröllchen
10a1b0de96 disasm: Overhaul symbol printing
We now split up symbols into zero-sized symbols that label single
instructions (no need to separate them by newlines; they are used for
jump labels and relocation targets within a larger block of code) and
ranged symbols that label functions. Empty symbols are discarded since
at least RISC-V ELF files contain quite a few of those. Zero-sized
symbols and ranged symbols are handled almost the same, but this way we
can make sure that zero-sized symbols don't interfere with ranged
symbol's newline separation logic. For zero-sized symbols, the "symbol
contains address" logic is updated so they actually contain the one
address they're pointing at, fixing the bug with many "dangling"
zero-sized symbols after a function that contained them. Zero-sized
labels are also no longer printed as a start-end range, since that is
unnecessary visual noise.
2024-01-22 20:54:16 -07:00
Kemal Zebari
1d43bfc598 base64: Implement -w/--wrap
This is an option supported by coreutils, so we might as well support
it too.

It allows users to wrap their encoded output after the "column" value
they provide.

This commit also has the Markdown look more like what we see
when running ArgsParser::print_usage_markdown() (and it fixes some
of the examples).
2024-01-21 21:54:51 -05:00
Tim Ledbetter
9b3f9c46b9 ls: Show T in long mode if sticky bit is set for non-executable files 2024-01-21 08:49:33 -05:00
Tim Ledbetter
0266a32580 ls: Show S in long mode if SUID/SGID bit is set for non-executable files 2024-01-21 08:49:33 -05:00
Kemal Zebari
02d8aaa2e8 nohup: Use return code 127 for errors caught by serenity_main()
For any errors that occur during the runtime of nohup, POSIX uses
a 127 return code.
2024-01-19 12:16:56 -07:00
Andrew Kaster
05ea3d6be0 headless-browser: Navigate after attaching new callbacks for ref tests 2024-01-19 11:47:59 +01:00
implicitfield
de9fa25e11 cksum: Use the POSIX cksum algorithm rather than vanilla CRC32 2024-01-18 18:01:26 +03:30
Bastiaan van der Plaat
dc2233ef7a Ladybird+WebContent: Add chrome command line and exe path passing 2024-01-17 17:32:05 +01:00
Sam Atkins
cac66aeb53 mktemp: Use ByteString for paths 2024-01-16 08:42:34 +00:00
Sam Atkins
56c5ffe398 LibFileSystem+Userland: Return ByteString from real_path() 2024-01-16 08:42:34 +00:00
Sam Atkins
cdf17efb9a LibFileSystem+Userland: Return ByteString from absolute_path() 2024-01-16 08:42:34 +00:00
Kemal Zebari
b7dbdb4cd2 cksum: Print checksums as decimal rather than hexadecimal
POSIX and the implementations I see expect checksum to be printed
just as an unsigned integer.
2024-01-15 23:08:28 -07:00
Kemal Zebari
09a053a723 cksum: Handle edge case when no file operands are given when printing
Given no file operands, POSIX wants us to read from stdin as well
as omit "the pathname and its leading <space>" when printing.
2024-01-15 23:08:28 -07:00
Kemal Zebari
5d07c56d0d cksum: Decouple printing logic from checksum construction
This is to avoid duplicating the printing logic and so that we can
have an alternative way of printing the result (i.e. for the next
commit that will print without a pathname if no file operands were
provided). This also has us avoid the algorithm checks in the for
loop.
2024-01-15 23:08:28 -07:00
Kevin Meyer
284f14d046 LibVideo: Replace DeprecatedFlyString with FlyString 2024-01-14 15:00:13 -07:00
Nico Weber
96e8debf0b test-jpeg-roundtrip: Add a few more colors 2024-01-14 11:35:40 +00:00
Nico Weber
25efe65a83 test-jpeg-roundtrip: Print summary statistics at the end 2024-01-14 11:35:40 +00:00
Nico Weber
8ef3310525 test-jpeg-roundtrip: Print perceived delta of fixpoint to start color 2024-01-14 11:35:40 +00:00
Nico Weber
5a47e71604 Utilities: Add test-jpeg-roundtrip
This creates a bitmap filled with a fixed color, then (in memory)
saves it as jpeg and loads it again, and repeats that until the
color of the bitmap no longer changes. It then reports how many
iterations that took, and what the final color was.

It does this for a couple of colors.

This is for quality assessment of the jpeg codec. Ideally, it should
converge quickly (in one iteration), and on a color not very far from
the original input color.
2024-01-14 11:35:40 +00:00
Liav A
fc0dbd2334 Utilities: Add the listdir utility
This utility uses the Core::DirIterator facility which in turn uses the
get_dir_entries syscall. Therefore, this utility lets us to view the
actual values for inode numbers, and entry type value for directory
entries.
2024-01-13 19:01:07 -07:00
Dan Klishch
ccd701809f Everywhere: Add deprecated_ prefix to JsonValue::to_byte_string
`JsonValue::to_byte_string` has peculiar type-erasure semantics which is
not usually intended. Unfortunately, it also has a very stereotypical
name which does not warn about unexpected behavior. So let's prefix it
with `deprecated_` to make new code use `as_string` if it just wants to
get string value or `serialized<StringBuilder>` if it needs to do proper
serialization.
2024-01-12 17:41:34 -07:00
Ollrogge
90ff6cca8a LibELF: Correctly determine symbol amount for DT_GNU_HASH table 2024-01-12 17:04:43 -07:00
kleines Filmröllchen
eada4f2ee8 AK: Remove ByteString from GenericLexer
A bunch of users used consume_specific with a constant ByteString
literal, which can be replaced by an allocation-free StringView literal.

The generic consume_while overload gains a requires clause so that
consume_specific("abc") causes a more understandable and actionable
error.
2024-01-12 17:03:53 -07:00
kleines Filmröllchen
bdd92e881f pixelflut: Implement alternative flooding strategies
These allow column-wise, traditional scanline, or random pixel flooding.
Depending on the use case and amount of contestion, any of the
strategies may work best, as tested on 37c3.
2024-01-12 16:10:28 -07:00
kleines Filmröllchen
fdfd4b5e3d pixelflut: Ignore EAGAIN errors
Very contested servers are likely to cause EAGAIN socket errors on the
client. Since these errors are not supposed to be fatal, just try
sending the pixel again.

This was tested successfully against massively contested 37c3 pixelflut
servers.
2024-01-12 16:10:28 -07:00
Andrew Kaster
02edd240ae LibWeb+WebContent: Spawn Worker processes from the chrome
Instead of spawning these processes from the WebContent process, we now
create them in the Browser chrome.

Part 1/N of "all processes are owned by the chrome".
2024-01-12 15:53:11 -07:00
Nico Weber
7d796c83f1 image: Fix flag names and grammar in diagnostic texts 2024-01-11 08:00:27 +00:00
Timothy Flynn
0989a81a48 headless-browser: Add support for cookies with SQLServer
This will allow us to test cookies and the database during CI.
2024-01-10 23:26:40 +01:00
Nico Weber
07fe8b8d0a icc: Add a --debug-roundtrip flag
With this, we convert a bunch of random colors to a
profile's profile connection space and back, and count
how many u8 colors make it through unchanged.

With this, you can do something like:

    for f in ~/Downloads/Adobe\ ICC\ Profiles\ \(end-user\)/*/*.icc; do
        echo $f
        Build/lagom/bin/icc --debug-roundtrip $f
    done

to test conversion through a bunch of profiles. These profiles are
available at:
https://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html

...which ultimately leads to:
https://download.adobe.com/pub/adobe/iccprofiles/win/AdobeICCProfilesCS4Win_end-user.zip

(Or use `Build/lagom/bin/icc --debug-roundtrip -n sRGB` to test the
built-in sRGB profile.)
2024-01-07 15:42:35 +01:00
Timothy Flynn
d8fa226a8f Ladybird+LibWebView+WebContent: Make the screenshot IPCs async
These IPCs are different than other IPCs in that we can't just set up a
callback function to be invoked when WebContent sends us the screenshot
data. There are multiple places that would set that callback, and they
would step on each other's toes.

Instead, the screenshot APIs on ViewImplementation now return a Promise
which callers can interact with to receive the screenshot (or an error).
2024-01-01 10:11:45 +01:00
Andreas Kling
b6d4eea7ac LibJS: Never give back virtual memory once it belongs to a cell type
Instead of returning HeapBlock memory to the kernel (or a non-type
specific shared cache), we now keep a BlockAllocator per CellAllocator
and implement "deallocation" by basically informing the kernel that we
don't need the physical memory right now.

This is done with MADV_FREE or MADV_DONTNEED if available, but for other
platforms (including SerenityOS) we munmap and then re-mmap the memory
to achieve the same effect. It's definitely clunky, so I've added a
FIXME about implementing the madvise options on SerenityOS too.

The important outcome of this change is that GC types that use a
type-specific allocator become immune to use-after-free type confusion
attacks, since their virtual addresses will only ever be re-used for
the same exact type again and again.

Fixes #22274
2023-12-31 15:35:56 +01:00
Andreas Kling
b344d39014 headless-browser: Use run_dump_test() for single-test runs as well
This avoids having two separate ways to set up the finish callbacks.
It also makes it possible to run a single async test on its own.
2023-12-24 13:23:40 +01:00
Shannon Booth
e2e7c4d574 Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:

```
Optional<I> opt;
if constexpr (IsSigned<I>)
    opt = view.to_int<I>();
else
    opt = view.to_uint<I>();
```

For us.

The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Sam Atkins
ac63d1e59d headless-browser: Clear document and callbacks between tests
While it would be more hygienic to get a fresh Navigable each time,
loading `about:blank` still means we discard the current Document.

This does noticeably increase the duration of running the LibWeb test
suite. On my machine, we go from ~5.5 seconds to ~7.7.
2023-12-22 16:49:06 +01:00
Aliaksandr Kalenik
d28c400fcb headless-browser: Load test page after callbacks are registered
Eliminates possibility that page will load before callbacks are added.
2023-12-21 10:20:05 +01:00
Aliaksandr Kalenik
2f09bfeff2 headless-browser: Await on_load_finish() while running Text tests
Before this change, it was possible for a text test to finish before
on_load_finish() was triggered, resulting in the subsequent test
receiving the load event from the previous test.
2023-12-21 10:20:05 +01:00
Andrew Kaster
c7f7ee2c4b headless-browser: Log current test when WebContent crashes 2023-12-19 21:08:05 +01:00
Aliaksandr Kalenik
fc9a8c77d5 headless-browser: Update m_viewport_rect after changing scroll offset 2023-12-19 20:59:52 +01:00
Aliaksandr Kalenik
a93ab25487 headless-browser: Implement on_scroll_to_point and on_scroll_by_delta
Without these callbacks "scroll" events are not emitted so we can't
write tests for scrolling.
2023-12-19 10:45:07 +01:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Bastiaan van der Plaat
c069ab1ca0 LibWeb: Refactor int types in WebContentServer to DevicePixels 2023-12-15 17:01:16 +01:00
Liav A
f67b9cb680 Utilities/drain: Add an option to specify different block size
This is useful for a situation when handling a small file than 512 KiB
or being under low system memory pressure.
2023-12-12 06:44:10 -05:00
Kyle Pereira
8191f2b47a LibPDF: Add parameter for background color of render 2023-12-10 16:44:24 +01:00
implicitfield
84b981ade7 Utilities: Add a drain utility 2023-12-08 22:05:43 +03:30
Andrew Kaster
4786d9e3e6 headless-browser: Add ability to skip tests 2023-12-07 16:46:20 -05:00
Dan Klishch
d317309d89 Everywhere: Unport Core::System::current_executable_path from new string
Storing paths in AK::String is never correct.
2023-12-07 10:13:21 -07:00
Andreas Kling
8b7d27b349 LibJS+LibWeb: More bringing module loading closer to spec
In particular, this patch removes three host hooks on JS::VM in favor
of the new JS-side module loading stuff.
2023-12-03 20:46:55 +01:00
Timothy Flynn
07e9a8f79b Ladybird+LibWebView: Move options used to launch WebContent to a struct
It is currently a bit messy to pass these options along from main() to
where WebContent is actually launched. If a new flag were to be added,
there are a couple dozen files that need to be updated to pass that flag
along. With this change, the flag can just be added to the struct, set
in main(), and handled in launch_web_content_process().
2023-12-01 20:07:27 -05:00
Daniel Bertalan
45d81dceed Everywhere: Replace ElfW(type) macro usage with Elf_type
This works around a `clang-format-17` bug which caused certain usages to
be misformatted and fail to compile.

Fixes #8315
2023-12-01 10:02:39 +02:00
Andrew Kaster
890cce6fbb headless-browser: Centralize test timeouts and up default to 30 seconds
We're seeing timeouts for WebWorker based tests in some CI runs. It's
possible that these are legitimate timeouts, so bump the default timeout
to 30sec. When porting the test runner to run on CI, Andreas had to bump
the test timeout from 5 seconds to 10, to 15. It's likely that loading
our ASAN/UBSAN binaries on slow CI machines takes a significant amount
of time. Tests that use the new WebWorker process are spawning yet
another process that needs to load LibWeb and all its dependencies.
2023-11-28 16:38:51 +01:00
Sam Atkins
edaa5061c4 headless-browser: Add flag to dump screenshots of failing ref-tests
When the `--dump-failed-ref-tests` flag is provided, screenshots of the
actual and reference pages will be placed in
`Build/lagom/ladbybird/test-dumps`. This makes it a lot easier to spot
what's wrong with a failing test. :^)
2023-11-18 07:49:59 -05:00
Martin Janiczek
b56e022ce8 AK: Add roundtrip fuzzer for Base64 2023-11-18 10:01:29 +01:00
Martin Janiczek
0465ba242b LibCompress: Upgrade compression fuzzer into a roundtrip fuzzer 2023-11-18 10:01:29 +01:00
Sönke Holz
6824d2a788 Userland+Tests: Add initial riscv64 support 2023-11-10 10:30:08 -07:00
Nico Weber
ed7549c64f pdf: Add a --json flag that currently affects only --debugging-stats 2023-11-10 14:46:06 +01:00
Tim Schumacher
a2f60911fe AK: Rename GenericTraits to DefaultTraits
This feels like a more fitting name for something that provides the
default values for Traits.
2023-11-09 10:05:51 -05:00
Tim Ledbetter
e1099a1757 Fuzzers: Use a single fuzzer to test all LibTextCodec encodings
This commit replaces the 5 fuzzers that previously tested LibTextCodec
with a single fuzzer. We now rely on the fuzzer to generate the
encoding and separate it from the encoded data with a magic separator.
This increases the overall coverage of LibTextCodec and eliminates the
possibility of the same error being generated by multiple fuzzers.
2023-11-08 09:39:49 +01:00
Tim Ledbetter
33ad384a7d Fuzzers: Add a DNS packet fuzzer 2023-11-08 09:38:36 +01:00
Lucas CHOLLET
8612aee640 Lagom/Fuzzers: Add a fuzzer for our TIFF decoder 2023-11-06 12:29:30 -07:00
LevitatingBusinessMan (Rein Fernhout)
edd38358c2 ls: Use indicator for sockets and pipes
= indicator for sockets, | for pipes.
Pipes are now colored yellow like other special files
2023-11-04 22:08:56 +01:00
Liav A
55ea2d892c Utilities/beep: Restrict possible capabilities
We can now just unveil the /dev/beep device node, as well as to restrict
the utility functionality for rpath, wpath & stdio related syscalls only
because we don't actually need anything else.
2023-11-03 15:19:33 +01:00
Liav A
26f96d2a42 Kernel+Userland: Add option for duration of /dev/beep producing sound 2023-11-03 15:19:33 +01:00
Liav A
1b00618fd9 Kernel+Userland: Replace the beep syscall with the new /dev/beep device
There's no need to have separate syscall for this kind of functionality,
as we can just have a device node in /dev, called "beep", that allows
writing tone generation packets to emulate the same behavior.

In addition to that, we remove LibC sysbeep function, as this function
was never being used by any C program nor it was standardized in any
way.
Instead, we move the userspace implementation to LibCore.
2023-11-03 15:19:33 +01:00
Simon Wanner
93908fcbcb LibJS+Embedders: Unify stack trace format for uncaught errors
Previously these handlers duplicated code and used formats that
were different from the one Error.prototype.stack uses.

Now they use the same Error::stack_string function, which accepts
a new parameter for compacting stack traces with repeating frames.
2023-11-02 07:37:41 +01:00
Timothy Flynn
cf93e56833 headless-browser: Use LibWebView to sanitize input URLs
Remove the ad-hoc sanitization in favor of LibWebView. This was missed
after commit 191e20d639.
2023-10-31 07:03:15 +01:00
Timothy Flynn
1504469c50 js: Implement the exit builtin without calling the native exit function
If we invoke the exit native function from within the exit builtin, the
native call will then invoke global destructors. This ultimately ends up
deleting the JS::NativeFunction that defines the exit builtin, thus we
try to delete the AK::Function held inside the NativeFunction while that
AK::Function is executing. This is explicitly forbidden by AK::Function.

Instead, simply set a flag to exit the REPL after the builtin executes.
2023-10-30 18:12:17 +01:00
Gurkirat Singh
60640fe38d Utilities: Implement slugify using AK/Slugify 2023-10-30 10:39:59 +00:00
Andrew Kaster
86ce502ae2 LibGfx+Utilities: Add helpers to load vector fonts from Core::Resources 2023-10-29 13:12:28 -06:00
Aliaksandr Kalenik
b6732b0234 Ladybird+WebContent: Add option to use GPU painter
Adds `--enable-gpu-painting` param to enable painting command executor
that uses LibAccelGfx.
2023-10-29 17:13:23 +01:00
Lucas CHOLLET
5c7e5cc738 Ladybird: Decode images out of process
This patch brings a service to handle image decompression. With it comes
security enhancement due to the process boundary. Indeed, consequences
of a potential attack is reduced as only the decoder will crash without
perturbing the WebContent process.
It also allows us to display pages containing images that we claim to
support but still make us crash, like for not-finished-yet decoders.

As an example, we can now load https://jpegxl.info/jxl-art.html without
crashing the WebContent process.
2023-10-27 07:26:32 +02:00
Tim Ledbetter
fff1645c6b Fuzzers: Add WOFF2 fuzzer 2023-10-24 13:45:01 +02:00
Tim Ledbetter
03fbd6c0c8 Fuzzers: Add a fuzzer for JsonParser 2023-10-24 07:54:37 +02:00
Tim Ledbetter
c5a4c22fa7 du: Add -x option to not traverse directories across filesystems 2023-10-19 14:41:09 +02:00
Tim Ledbetter
cc5c7d2a29 du: Remove unnecessary is_inside_dir function argument
This value can be computed using the `current_depth` parameter.
2023-10-19 14:41:09 +02:00
Tim Ledbetter
c006ebe5a3 find: Add the -path and -ipath options
These options behave the same way as `-name` and `-iname` but match
the full file path instead of just the basename.
2023-10-18 06:36:34 -04:00
Andrew Kaster
1af3da39fd headless-browser: Load fonts via Core::Resource URIs 2023-10-17 11:02:01 -06:00
Andrew Kaster
74707d151b pdf: Load fonts in debug mode via Core::Resource URIs 2023-10-17 11:02:01 -06:00
Tim Ledbetter
54a28afc13 LibIMAP: Stop parsing immediately on error
This makes the parser more resilient to invalid IMAP messages.

Usages of `Optional` have also been removed where the empty case is
equivalent to an empty object.
2023-10-13 11:12:18 -06:00
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Nico Weber
5c744a9fb0 pdf: Add a --render-repeats=N flag
It calls render() N times instead of just once. Useful for benchmarking.
2023-10-12 08:03:52 +02:00
Andreas Kling
a396bb0c0b LibGfx: Remove indexed palette formats from Bitmap and Painter
Nobody was actually using these formats anymore, and this simplifies
and shrinks the code. :^)
2023-10-12 07:39:05 +02:00
Tim Ledbetter
6f1f0710f8 find: Don't canonicalize path operands
The POSIX specification for `find` says that: "Each path operand shall
be evaluated unaltered as it was provided, including all trailing
<slash> characters". This also matches the behavior of `find` on
FreeBSD and Linux.
2023-10-07 11:37:53 +02:00
Andreas Kling
65717e3b75 LibJS: Inline fast case for Value::to_{boolean,number,numeric,primitive}
These functions all have a very common case that can be dealt with a
very simple inline check, often avoiding the need to call an out-of-line
function. This patch moves the common case to inline functions in a new
ValueInlines.h header (necessary due to header dependency issues..)

8% speed-up on the entire Kraken benchmark :^)
2023-10-07 07:13:52 +02:00
Tim Ledbetter
0068e91aad open: Display a meaningful error if the specified file doesn't exist
Previously, the error given for any non-existent file was:
"Failed to open ':'".
2023-10-06 08:20:28 +02:00
Karol Kosek
f2f98b7938 grep: Hyperlink filenames in tty
As the newly created function has been also applied to printing the
number of matched file lines, file names will now also be colored
with the `--count` option set. :^)
2023-10-06 08:10:00 +02:00
Karol Kosek
db4a654e9f grep: Print filenames when counting lines and path size is less than 2
`grep --count --recursive foo` doesn't specify any file, but we should
show the paths anyway.
2023-10-06 08:10:00 +02:00
Karol Kosek
018dcf570e grep: Return exit code '2' on error 2023-10-06 08:10:00 +02:00
Karol Kosek
5a85449b23 grep: Don't end the program early after failing to grep a file
We should still try to read remaining files.
2023-10-06 08:10:00 +02:00
Karol Kosek
94eb31865a grep: Remove separate stdin handling logic
Previously we had two somewhat duplicated methods: one just for handling
stdin with the standard C API, and the other one used for everything
else with our Core::File class. By using always Core::File, the code
should be now a little bit cleaner.

Additionally, grep will now use the standard input when it finds a '-'
argument (previously it tried to open a file with that name.)
2023-10-06 08:10:00 +02:00
Karol Kosek
e48b9d74ac grep: Add comment describing why we take leading characters from paths 2023-10-06 08:10:00 +02:00