Commit graph

3001 commits

Author SHA1 Message Date
Shannon Booth e5206f5529 LibWeb: Only use lowercase attributes on toggle for HTML documents 2024-05-12 07:28:09 +01:00
Nico Weber 4b1c1d1cae TestImageWriter: Add a test for writing a webp animation 2024-05-11 15:43:02 -04:00
Shannon Booth 4fd7d58c51 LibWeb/Tests: Add a layout test for insertAdjacentHTML 2024-05-11 12:53:26 +02:00
Andrew Kaster 2bc51f08d9 LibWeb: Implement or stub FontFace interface's attribute getters/setters
We only support parsing half of these, so the ones we don't recognize
get a friendly exception thrown.
2024-05-11 07:30:29 +01:00
Timothy Flynn 1fbf1bc4ac LibWeb: Don't try to click a form image until it has loaded
We are often trying to click the image before it has finished loading.
This results in us trying to click a 0x0 rect. Instead, wait until the
image load event.

This fixes a flake with form-image-submission.html often seen on CI.
2024-05-09 19:29:47 +02:00
Dan Klishch 9c707c4205 Tests/LibELF: Run LibELF tests on Lagom using Linux runtime linker
So that we can be sure Serenity's runtime linker performs the same.
2024-05-08 09:21:36 -06:00
Dan Klishch 6894faac1f Tests/LibELF: Add basic test checking initializer ordering 2024-05-08 09:21:36 -06:00
Nico Weber d988b6facc LibGfx/WebPWriter+TestImageWriter: Fix bugs writing VP8X header
Two bugs:

1. Correctly set bits in VP8X header.
   Turns out these were set in the wrong order.

2. Correctly set the `has_alpha` flag.

Also add a test for writing webp files with icc data. With the
additional checks in other commits in this PR, this test catches
the bug in WebPWriter.

Rearrange some existing functions to make it easier to write this test:

* Extract encode_bitmap() from get_roundtrip_bitmap().
  encode_bitmap() allows passing extra_args that the test uses to pass
  in ICC data.
* Extract expect_bitmaps_equal() from test_roundtrip()
2024-05-08 16:34:11 +02:00
Nico Weber 0805319d1e LibGfx/WebPLoader: Diagnose mismatch between VP8X and VP8L alpha bits
If this turns out to be too strict in practice, we can replace it with
a `dbgln("VP8X and VP8L headers disagree about alpha; ignoring VP8X");`
instead.

ALso update catdog-alert-13-alpha-used-false.webp to not trigger this.
I had manually changed the VP8L alpha flag at offset 0x2a in
da48238fbd to clear it, but I hadn't changed the VP8X flag.
This changes the byte at offset 0x14 from 0x10 (has_alpha) to 0x00
(no alpha) as well, to match.
2024-05-08 16:34:11 +02:00
Shannon Booth 71819153cb LibWeb: Implement Element::scroll(HTML::ScrollToOptions) 2024-05-07 17:21:52 -06:00
Tim Ledbetter 57f0ea186e LibWeb: Update Element::directionality() to match current spec text
This fixes a crash that occurred when determining the directionality of
input elements.
2024-05-07 16:45:28 -06:00
Abuneri b5bed37074 AK: Replace FP math in is_power_of with a purely integral algorithm
The previous naive approach was causing test failures because of
rounding issues in some exotic environments. In particular, MSVC
via MSBuild
2024-05-07 16:43:34 -06:00
Jamie Mansfield 8c4dc9476b LibWeb: Precision when using background-size: contain
This ensures that precision is maintained when calculating the image
size when using `background-size: contain`.
2024-05-07 11:15:04 -04:00
Jamie Mansfield e48cb80a66 LibWeb: Precision when using background-size: cover
This ensures that precision is maintained when calculating the image
size when using `background-size: cover`.
2024-05-07 11:15:04 -04:00
Nico Weber dad4843ee4 TestImageWriter: Add a JPEG roundtrip test 2024-05-07 11:14:41 -04:00
Nico Weber 9384f118d2 TestImageWriter: Add a QOI roundtrip test 2024-05-07 11:14:41 -04:00
Nico Weber 83bdc9c831 TestImageWriter: Add a BMP roundtrip test 2024-05-07 11:14:41 -04:00
Nico Weber 0a26831a10 TestImageWriter: Add a PNG roundtrip test 2024-05-07 11:14:41 -04:00
Nico Weber aefab64984 TestImageWriter: Use double parens instead of temporary err
Explicit template arguments must be wrapped in parens,
else they confuse the preprocessor.

Add the parens instead of avoiding the use of explicit template
arguments.

No behavior change.
2024-05-07 11:14:41 -04:00
Lucas CHOLLET ed1bdf3851 Tests/LibGfx: Add a test for bilevel images with only required tags
Bilevel images are not required to have a BitsPerSample or a
SamplesPerPixel tag, while this is unusual these images are still valid.

The test case has been generated by first making a copy of
ccitt3_1d_fill.tiff and then, using `tiffset` to remove both tags:
tiffset -u 258 ccitt3_no_tags.tiff
tiffset -u 277 ccitt3_no_tags.tiff
2024-05-07 11:06:12 -04:00
matjojo cd1eeb3cdd LibWeb: Do not consume scroll event in PaintableBox without overflow
Specifically, without scrollable overflow.

Fixes #24009, both on brave.com and on the reduction.
2024-05-07 14:04:02 +00:00
Nico Weber 7fc5fd453e Tests: Add TestImageWriter
For now, it tests that webps roundtrip, but it's easy to add basic
roundtrip testing for other image formats.
2024-05-06 17:32:19 +02:00
MacDue b5a7a8dbfd Tests/LibWeb: Add ref tests for non-local SVG clipPaths 2024-05-04 21:24:37 +02:00
Shannon Booth f7ba07cc8b LibWeb: Handle non-object JSON in XMLHttpRequest response
This fixes a crash seen on https://web.basemark.com/run/
2024-05-04 14:11:10 +02:00
Shannon Booth 94354ea7fb LibWeb: Clamp AudioParam's value between min and max
The spec isn't _super_ clear on how this is meant to be done, but the
way I understand this is that we should simply clamp the returned
'current value' between 'min' and 'max'.

Firefox does not appear to do this clamping, but Chrome does.
2024-05-04 14:01:38 +02:00
Shannon Booth e2b5ff2450 LibWeb: Implement OscillatorNode.frequency
Which is an AudioParam clamped by the nyquist_frequency.
2024-05-04 14:01:38 +02:00
Shannon Booth 099c9e4a7e LibWeb: Implement OscillatorNode.type
This is a simple getter and setter of the OscillatorType enum, with
error checking to not allow 'custom', as that should only be changed
through 'setPeriodicWave()'.
2024-05-04 14:01:38 +02:00
Shannon Booth b48ba823b9 LibWeb: Implement AudioNode.context
This is just a simple getter which returns the audio context that
created this audio node.
2024-05-04 14:01:38 +02:00
Shannon Booth 97576d27b9 LibWeb: Add constructor for OscillatorNode
This is still missing a bunch of spec steps to construct the
audio node based on the parameters of the OscillatorNode, but it is at
least enough to construct an object to be able to add a basic test which
can get built upon as more is implemented.
2024-05-04 14:01:38 +02:00
Shannon Booth e070309258 LibWeb: Implement Element.outerHTML setter 2024-05-04 13:54:33 +02:00
Andreas Kling 527ad9ac01 LibWeb: Implement XMLHttpRequest.responseURL
This was used on https://twinings.co.uk/ so let's support it :^)
2024-05-01 12:52:03 +02:00
Andreas Kling 34f2cbf202 LibWeb: Honor intrinsic constraints on available space in table widths
When a table's containing block provides min-content or max-content
available space, we now size the table's width accordingly.
2024-05-01 11:13:48 +02:00
Tim Ledbetter 02a8966b61 LibWeb: Serialize empty media rules with a single newline
This deviates from the CSSOM specification but all modern browsers do
this.
2024-05-01 07:21:21 +02:00
Tim Ledbetter a2cccf9420 LibWeb: Use correct spacing when serializing media features
Previously, there was no space between the media feature name and value.
2024-05-01 07:21:21 +02:00
Andrew Kaster 416eb74fa5 Tests: Skip flaky unicode-range LibWeb Ref test
This seems related to CSS resources and the load event.
2024-04-30 07:18:40 -06:00
Tim Ledbetter b9f0ea2178 LibWeb: Evaluate media rules for adopted style sheets
Previously, media rules were not evaluated for adopted style sheets.
2024-04-29 08:10:38 +02:00
Tim Ledbetter f4e0c5395a LibWeb: Don't apply disabled adopted style sheets to the document
Previously, we would apply any adopted style sheet to the document if
its alternate flag was not set. This meant that all adopted style
sheets would be applied, since constructed style sheets never have this
flag set.
2024-04-29 08:10:38 +02:00
Tim Ledbetter 84193f2746 LibWeb: Align StyleSheet title getter with the specification
The CSSOM specification says that StyleSheet.title should return null
if the title field is empty.
2024-04-29 08:10:38 +02:00
Aliaksandr Kalenik 7bea2b68f4 LibWeb: Paint non-positioned SC with z-index=0 in paint_descendants()
Fixes the bug when non-positioned boxes that establish a stacking
context and have z-index=0 are ignored during paint commands recording.
2024-04-28 22:28:18 +02:00
Timothy Flynn 34b446ab34 LibWeb: Assign the Content-Type fetch response header as appropriate
The condition here was inverted.
2024-04-28 12:32:04 +02:00
Nico Weber f8362c8abf LibGfx/JPEG2000: Remove an incorrect VERIFY in TagTree construction
...and add a test case that shows why it's incorrect.

If one dimension is 2^n + 1 and the other side is just 1, then the
topmost node will have 2^n x 1 and 1 x 1 children. The first child will
have n levels of children. The 1 x 1 child could end immediately, or it
could require that it also has n levels of (all 1 x 1) children. The
spec isn't clear on which of the two alternatives should happen. We
currently have n levels of 1 x 1 blocks.

This test case shows that a VERIFY we had was incorrect, so remove it.

The alternative implementation is to keep the VERIFY and to add a

    if (x_count == 1 && y_count == 1)
        level = 0;

to the top of TagTreeNode::create(). Then we don't have multiple levels
of 1 x 1 nodes, and we need to read fewer bits.

The images in the spec suggest that all nodes should have the same
number of levels, so go with that interpretation for now. Once we can
actually decode images, we'll hopefully see which of the two
interpretations is correct.

(The removed VERIFY() is hit when decoding
Tests/LibGfx/test-inputs/jpeg2000/buggie-gray.jpf in a local branch that
has some image decoding implemented. That file contains a packet with
1x3 code-blocks, which hits this case.)
2024-04-28 01:12:20 +02:00
dgaston 342b358341 Utilities: Make uniq behavior consistent with coreutils
The main difference was that our implementation was writing
the final line of a series of repeated lines, whereas the
spec says "The second and succeeding copies of repeated adjacent
input lines shall not be written."

Additionally, there was a mistake in the -f flag implementation
causing the number of fields skipped to be one greater than
required.
2024-04-27 16:33:27 -06:00
dgaston 1d932d3ebf Utilities: Fix off by one error in uniq
Flags that rely on counting lines (-c and -d) were
producing results that were off by one. This is fixed
by initializing the `count` variable to 1, which is
consistent with behavior in the main loop, where it
is reset to 1 when lines don't match.
2024-04-27 16:33:27 -06:00
dgaston 82887473d2 Utilities: Allow uniq to work on lines of arbitrary length
Calls to `read_line` are replaced with `read_line_with_resize`
and `swap`s of StringViews, which assume a consistent location
of the underlying ByteBuffers, are replaced. A test file has
been added for uniq, which includes a test case for long lines.
2024-04-27 16:33:27 -06:00
Aliaksandr Kalenik 613cd6104d LibWeb: Support masking of SVGForeignObjectPaintable 2024-04-27 07:10:20 +02:00
Nico Weber 88d0702763 AK: Make ceil_div() handle one argument being negative correctly
`ceil_div(-1, 2)` used to return -1.
Now it returns 0, which is the correct ceil(-0.5).

(C++'s division semantics have floor semantics for numbers > 0,
but ceil semantics for numbers < 0.)

This will be important for the JPEG2000 decoder eventually.
2024-04-27 07:09:08 +02:00
Nico Weber f2ebad11a8 Tests/AK: Add some basic ceil_div() tests 2024-04-27 07:09:08 +02:00
Timothy Flynn c9a461ee75 LibWeb: Remove OOM propagation from Fetch::Infrastructure::HTTP 2024-04-27 07:08:14 +02:00
Tim Ledbetter 1127fa1e01 IDLGenerators: Set namespace object prototype to Object.prototype
Previously, namespace objects were constructed with no prototype, so
calling methods like `toString()` on them would unexpectedly throw an
exception.
2024-04-26 20:02:42 +02:00
Tim Ledbetter dda730c46b LibWeb: Exclude [Global] interfaces from legacy platform object method
Previously, [Global] interfaces were not excluded from the
`internal_own_property_keys()` call. This caused a crash when iterating
over the properties of the Window object.
2024-04-26 20:02:21 +02:00
Aliaksandr Kalenik dc4192c149 LibWeb: Remove CSS transform from InlinePaintable's clip rectangle
Fixes bug when CSS transform is applied twice to clip rect:
- While calculating absolute clip rectangles in `refresh_clip_state()`
- While executing `PushStackingContext` painting command.

Duplicated transform is already removed for PaintableBox and this change
adds this for InlinePaintable.
2024-04-26 18:40:45 +02:00
Shannon Booth baaaa0008e LibWeb: Look for first ID _or_ name in HTMLCollection::named_item
Previously we would look for a matching ID, and then for a matching
name. If there was an element in the collection which had a matching ID
as well as an element with a matching name, we would always return the
element with a matching ID irrespective of what order that element was
in.
2024-04-26 07:44:01 -04:00
Timothy Flynn f6407276f7 LibWeb: Stop the video decoder thread when the video element is GC'd
Otherwise, the thread will continue to run and access the media data
buffer, which will have been freed.

The test here is a bit strange, but the issue would only consistently
repro after several GC runs.
2024-04-26 09:49:11 +02:00
Shannon Booth 0c8a98ac94 LibWeb: Begin implementing the interface for AudioBuffer
Implement the constructor and getChannelData function, working towards
the functionality that we need in order to implement
OfflineAudioContext.
2024-04-25 19:26:19 -04:00
goldenzach 65eb7699f4 LibWeb: Resolve vertical padding of inline elements 2024-04-25 12:45:39 +02:00
Aliaksandr Kalenik 988c8451d4 LibWeb: Skip HTMLLinkElement resource fetching for documents without BC
Fixes crashing after following steps:
1. Open https://github.com/SerenityOS/serenity
2. Click on "Pull requests" tab

The problem was `navigable` null pointer dereferencing in
`decode_favicon()`. But navigable is null because the document was
created by `parseFromString()` DOMParser API.

With this change we skip fetching initiated by HTMLLinkElement if
document does not have a browsing context:
- Favicon is not displayed for such documents so no need to fetch.
- Stylesheets fetching won't affect such document because style or
  layout does not run for them.
2024-04-25 09:31:01 +02:00
Timothy Flynn fecd08ce64 Everywhere: Remove 'clang-format off' comments that are no longer needed 2024-04-24 16:50:01 -04:00
Timothy Flynn ec492a1a08 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-18 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")

There are a couple of weird cases where clang-format now thinks that a
pointer access in an initializer list, e.g. `m_member(ptr->foo)`, is a
lambda return statement, and it puts spaces around the `->`.
2024-04-24 16:50:01 -04:00
Cnidarias 1a1e5aaf54 LibWeb: Add null check for get_client_rects() on non paintable elements 2024-04-24 18:04:28 +02:00
Bastiaan van der Plaat 7fa45c5fdf LibWeb: Add map element areas property 2024-04-24 15:23:45 +02:00
Bastiaan van der Plaat 3e507102ea LibWeb: Add datalist element options property 2024-04-24 15:23:45 +02:00
kleines Filmröllchen 0c1ad05f50 LibC: Add rounding specializations for RISC-V
Whenever the floating-point values are in integer range, we can use the
various FCVT functions with static rounding mode to perform fast
rounding. I took this opportunity to clean up the architecture
differentiation for these functions, which allows us to use the software
rounding implementation for all extreme and unimplemented cases,
including AArch64.

Also adds more round & trunc tests.
2024-04-23 19:18:09 -06:00
kleines Filmröllchen 997828c31a LibC: Add some fenv tests
Co-Authored-By: Dan Klishch <danilklishch@gmail.com>
2024-04-23 19:18:09 -06:00
Andrew Kaster 651e78fedb LibWeb: Convert callers of ImageCodecPlugin to the async API
The HTMLLinkElement caller is a bit hairy, so we shove an await() in
there temporarily. This is sure to cause fun times for anyone debugging
task/microtask execution order.
2024-04-23 12:32:04 -06:00
Aliaksandr Kalenik d4f08fb0a1 LibWeb: Fix division by zero in solve_replaced_size_constraint()
Happened when input_width > 0 but input_height == 0.

Fixes crashing on Discord that happens after clicking on direct
messages conversation.
2024-04-23 16:21:48 +02:00
Aliaksandr Kalenik a044e9cf4f LibWeb: Add background-clip: text support for InlinePaintable
Moves background mask calculation into `paint_background()` that is
shared between PaintableBox and InlinePaintable.
2024-04-23 12:50:07 +02:00
Tim Ledbetter 3aea14093f LibWeb: Don't crash if the document element is not visible
Previously, setting the `hidden` property on the `<html>` element would
cause a crash.
2024-04-23 11:17:54 +02:00
Aliaksandr Kalenik dd73cccf8f LibWeb: Fire "scroll" events on DOM elements
Before this change "scroll" events were only fired on document but now
it happens for all elements with scrollable overflow.
2024-04-23 11:00:35 +02:00
Shannon Booth 1ec6399c00 Everywhere: Remove uneeded short option argument where possible 2024-04-22 08:10:08 +02:00
Andreas Kling 8e56367092 LibWeb: Allow moving StyleSheets between documents without falling apart
We have to unregister link element stylesheets from the old document's
StyleSheetList when moving them into a new document.

This makes it possible to load GitHub contributor graphs. :^)
2024-04-22 06:43:05 +02:00
Dan Klishch bdfc77b725 LibELF: Treat STB_WEAK like STB_GLOBAL during global symbol lookup
This is what POSIX mandates and this also matches the behavior of modern
Linux.
2024-04-21 13:34:04 -06:00
Dan Klishch d8119c4b4a LibLocale: Statically link LibLocaleData into LibLocale 2024-04-21 13:34:04 -06:00
Andreas Kling 193fc7ef98 LibWeb: Allow cloneNode() to clone elements with weird attributes
We can't rely on Element.setAttribute() in cloneNode() since that will
throw on weird attribute names. Instead, just follow the spec and copy
attributes into cloned elements verbatim.

This fixes a crash when loading the "issues" tab on GitHub repos.
They are actually sending us unintentionally broken markup, but we
should still support cloning it. :^)
2024-04-21 19:51:24 +02:00
Aliaksandr Kalenik 23d683cf6b LibWeb: Update document url after same-document back/forward navigation
Seems like a specification bug, but other browsers update url before
popstate event is fired and so should we.

Fixes back/forward navigation on GitHub.
2024-04-21 12:41:36 +02:00
dgaston 08aaf4fb07 AK: Add methods to BufferedStream to resize the user supplied buffer
These changes allow lines of arbitrary length to be read with
BufferedStream. When the user supplied buffer is smaller than
the line, it will be resized to fit the line. When the internal
buffer in BufferedStream is smaller than the line, it will be
read into the user supplied buffer chunk by chunk with the
buffer growing accordingly.

Other behaviors match the behavior of the existing read_line method.
2024-04-21 11:46:55 +02:00
Aliaksandr Kalenik 9540af6489 LibWeb: Fix nodesToRemove collecting traversal in Range::delete_contents
With this change children are no longer skipped in tree traversal when
start node of range equals to end node of range.

Fixes https://github.com/SerenityOS/serenity/issues/24036
2024-04-20 13:32:24 +02:00
Aliaksandr Kalenik d3cfe35fbd LibWeb: Do not destroy document until whole subtree completed unloading
Fixes crashing when "unload" event handler tries to access active
document that has already been destroyed.
2024-04-20 10:22:14 +02:00
Sönke Holz 9881d10e38 LibELF: Add a small local-exec TLS test
Part 1 of this test uses a large array so we are more likely getting
segfaults when using an incorrect TLS layout.

The `volatile`s and `taint_for_optimiter`s should hopefully prevent the
compiler from optimizing the tests out.
2024-04-19 16:46:47 -06:00
Nico Weber 3568215790 Tests/JPEG2000: Add spec example as test case
This tests reading JPEG2000 codestreams that aren't embedded in
the ISOBMFF wrapper. It's also useful for debugging bitstream
internals, since the spec lists expected output for many internal
intermediate results.
2024-04-19 12:42:34 -04:00
Alex 13abb1b2c7 LibWeb: Add name validation and document check to setAttribute
Co-authored-by: Rayyan Hamid <rayyanbwp@gmail.com>
Co-authored-by: Christian Ewing <u1273549@utah.edu>
Co-authored-by: Austin Fashimpaur <austin.fashimpaur@gmail.com>
2024-04-19 06:32:41 -04:00
Andreas Kling 5ef6df79ed LibWeb: Generate a simple error page when XML decode/parse fails
This fixes a regression on Acid3, since we are not expected to "best
effort" parse XML. The test specifically checks that you don't create an
incomplete, incorrect DOM.
2024-04-19 11:44:32 +02:00
Nico Weber ea441fea95 LibGfx: Move QMArithmeticDecoder to its own file
It will be used by the JPEG2000 decoder as well.

Pure code move, no behavior change.
2024-04-19 10:59:11 +02:00
Nico Weber 5ff75ce5fb LibGfx/JBIG2: Rename JBIG2::ArithmeticDecoder to QMArithmeticDecoder
In preparation of moving it to its own file.

No behavior change.
2024-04-19 10:59:11 +02:00
PGHales 75626c6cd2 LibWeb/DOM: Implement the Document object's partial attributes 2024-04-19 10:58:45 +02:00
Aliaksandr Kalenik 7b75d0c1f0 LibWeb: Fix height distribution in "vertical-align: baseline" in TFC
This line changes padding top to align cell content to baseline:
`cell.padding_top += m_rows[cell.row_index].baseline - cell.baseline`

Which means available for distribution height `height_diff` could have
changed so it needs to be refreshed before assigning the rest of it to
padding bottom:
`cell_state.padding_bottom += height_diff;`

Fixes https://github.com/SerenityOS/serenity/issues/22032
2024-04-19 10:55:28 +02:00
Andreas Kling eb2c05e906 Tests/LibWeb: Fix rebaseline-libweb-test after RequestServer changes 2024-04-19 10:53:20 +02:00
Andreas Kling 4a795bef48 Tests/LibWeb: Fix iframe-load-event-for-bad-xml.html test
This was supposed to be an async test (and work correctly, too!)

This fixes up fa43321938
2024-04-18 21:17:01 +02:00
implicitfield 7a74805067 Tests: Avoid casting function types in LibC/TestSearch.cpp
Doing so causes a function type mismatch, which makes the test crash
when built with a new enough version of UBSan.
2024-04-18 13:14:33 -06:00
Andreas Kling fa43321938 LibWeb: Fire iframe load event for frames with badly encoded XML
When loading an XML resource into an iframe and the resource fails to
decode (e.g due to invalid UTF-8), we must still fire a load event.

This fixes the regression in subtest 69 of Acid3.
2024-04-18 15:40:16 +00:00
Aliaksandr Kalenik bad86ca6b4 LibWeb: Ignore mousewheel events in ViewportPaintable
That allow EventHandler process wheel event on corresponding navigable.
For top-level navigable that means IPC call to let chrome know about
scrollbar position update.

Fixes https://github.com/SerenityOS/serenity/issues/23599
Fixes https://github.com/SerenityOS/serenity/issues/23493
Fixes https://github.com/SerenityOS/serenity/issues/23966
2024-04-18 12:27:24 +02:00
Aliaksandr Kalenik eb4f36e5a1 Tests/LibWeb: Add a test for iframe load event when src has xml type
Reduction from Acid3 that was fixed by changing
guess_mime_type_based_on_filename() to support xml extension.
2024-04-18 08:10:05 +00:00
Aliaksandr Kalenik d876f32e5d LibWeb: Skip creating a navigable for <object> not connected to document
Navigation should not run for <object> element until it is inserted into
a document. Spec deoes not seem to explicitely say that, but that
matches other browsers behavior.

Fixes hanging after reloading in Acid3 test.
2024-04-18 08:09:51 +00:00
Andreas Kling 41667f969d LibWeb: Fix two problems where media queries didn't invalidate properly
There were two things going wrong here:

- Transformed text (via CSS text-transform) was not invalidated after a
  `@media` rule changed state.

- Removing the `style` attribute from an element didn't trigger a style
  update.

This fixes the regression in subtest 46 of Acid3.

Fixes #21777
2024-04-17 14:18:31 +02:00
Ali Mohammad Pur 06386ab2b5 LibTLS+LibHTTP: Tolerate improperly closed TLS sockets
Some really cursed servers simply drop the TCP socket on the floor when
they're trying to close an HTTP connection going through a TLS socket.
This commit makes LibTLS tolerate these silly servers, and LibHTTP
accept their idea of "EOF == connection closed".

Fixes loading wpt.live/acid/acid3/test.html.

Note that this means TLSv12::on_ready_to_read can fire with an empty
buffer signifying EOF; one test refused this behaviour, and has been
changed in this commit.
2024-04-17 07:19:03 +02:00
Andreas Kling 1cb5385a29 LibCore: Stop obsessing about tiny OOMs in Core::Timer
Work towards #20405
2024-04-17 07:16:52 +02:00
Timothy Flynn bf1c82724f LibWeb: Default to an empty string when a string attr substitution fails
When a string-type attr() substitution produces no value and no fallback
had been specified, the spec mandates we default to the empty string.
2024-04-17 07:13:26 +02:00
Timothy Flynn 4ced84a548 LibWeb: Copy the css-attr-typed-fallback ref test as a layout test
As a layout test, this verifies that the fallback attr() substitution
results in the expected layout node. For example, the fallback content
for a `string` attribute type should create a text node.
2024-04-17 07:13:26 +02:00
Tim Ledbetter 4a3497e9cd LibWeb: Support loading alternative style sheets
Alternative style sheets are now fetched and are applied to the
document if they are explicitly enabled by removing the disabled
attribute.
2024-04-17 07:12:44 +02:00
Aliaksandr Kalenik 890da021c4 LibWeb: Abort ongoing navigation before firing next navigation event
I haven't found this being mentioned in the current spec, but that is
what chromium (atm the only other Navigation API implementer) does.

Fixes crashing when location.hash is changed subsequently more than once
using JS.
2024-04-16 19:51:56 +02:00
Andreas Kling 0389f01cc8 LibWeb: Make document.createEvent("hashchangeevent") produce right type
This is supposed to return a HashChangeEvent, and now it does.
2024-04-16 19:50:45 +02:00
Aliaksandr Kalenik 768b1455d6 LibWeb: Run <object> fallback steps if data type is not supported
Progress on fixing regressed Acid2.
2024-04-16 13:47:38 +02:00
Tim Ledbetter d5cddd4696 LibWeb: Unset stylesheet properties when removing from a StyleSheetList
Previously, the parent CSS stylesheet, owner node and owner CSS rule
properties were not unset when removing a sheet from a StyleSheetList.

This change moves the methods for adding and removing sheets to and
from a StyleSheetList, directly into the StyleSheetList class and
ensures they are called as required by the CSSOM specification.
2024-04-16 07:41:33 +02:00
Tim Ledbetter beaf97bf96 Tests/LibWeb: Add a test for disabled link elements 2024-04-16 07:41:33 +02:00
Space Meyer 83020a48a8 Kernel: Add basic KCOV test and benchmark 2024-04-15 21:16:22 -06:00
Nico Weber 7296b0fa43 LibGfx/JPEG2000: Implement tag trees
A tag tree is a data structure used for deserializing JPEG2000
packet headers.

We don't use them for anything yet, except from tests.

The implementation feels a bit awkward to me, but we can always polish
it later.

The spec thankfully includes two concrete examples. The code is
correct enough to pass those -- I added them as test.
2024-04-16 00:40:16 +02:00
Tim Ledbetter 99b2eff988 LibWeb: Invalidate style when CSSStyleRule selectorText changes
Previously, any change to the selectorText of a CSSStyleRule was not
reflected in the document style.
2024-04-15 22:12:49 +02:00
Andreas Kling c08ba8ac4c LibWeb: Fix new ImageData(width, height) when width != height 2024-04-15 11:27:34 +02:00
Andreas Kling 134c4b6335 LibWeb: Fix CRC2D.getImageData() when width != height
We were mistakenly using the width as both width and height when getting
ImageData from a 2D canvas.
2024-04-15 11:27:34 +02:00
Jamie Mansfield e487f70bbf LibWeb: Support "importmap" scripts 2024-04-15 10:11:54 +02:00
Aliaksandr Kalenik ccb363c443 LibWeb: Add hashchange event support 2024-04-15 01:02:51 -07:00
Andreas Kling 20bdda7f02 LibWeb: Implement Element.removeAttributeNode() 2024-04-14 22:08:22 +02:00
Andreas Kling cf315338ec LibWeb: Don't draw image alt text frames with "rough" rect
This was an accident in 3645b676fb
2024-04-14 18:05:48 +02:00
Andreas Kling 217cb01708 LibGfx: Clip out-of-bounds pixel accesses in Painter::draw_rect() 2024-04-14 18:05:48 +02:00
Tim Ledbetter c6f070d29e LibWeb/Fetch: Don't crash when a fetch request times out
Previously, calling fetch with a signal object provided by
`AbortSignal.timeout()` would cause a crash when the signal timed out.

We now push a `TemporaryExecutionContext` to the stack when we invoke
the signal's abort steps, as an execution context is required when
calling native functions.
2024-04-14 13:36:25 +02:00
Tim Ledbetter 88f3145f8a LibWeb: Add methods to Window that must do nothing
This change adds the `captureEvents()` and `releaseEvents()` methods to
the window object. These methods are obsolete, but are still included
in the HTML specification, which says they must do nothing.
2024-04-14 10:45:43 +02:00
Tim Ledbetter 0564e06f10 LibWeb: Add methods to Document that must do nothing
This change adds the `clear()`, `captureEvents()` and `releaseEvents()`
methods to the document object. These methods are obsolete, but are
still included in the HTML specification, which says they must do
nothing.
2024-04-14 10:45:43 +02:00
Arthur Grillo 3645b676fb LibWeb: Remove RecordingPainter::paint_frame()
PaintFrame is not primitive painting command, we inherited from OS, that
is hard to replicate in GPU-painter or alternative CPU-painter API. We
should remove it as a part of refactoring towards simplifying recording
painter commands set.

Fixes: #23796
2024-04-13 20:25:48 -07:00
Aliaksandr Kalenik 91377f3ab9 LibWeb: Fix always hanging Navigable::reload()
See spec issue https://github.com/whatwg/html/issues/9869

Previous attempt on fixing reload had to be reverted because it broke
Soundcloud and GitHub, but this change does not seem to introduce new
crashes.
2024-04-13 09:19:00 -07:00
Andreas Kling f7e57881ad LibWeb: Don't limit available space during early height for inline-flex
There was no need to set an available height constraint when doing early
height calculation for inline-flex boxes. It created a situation where
the flex containers could wrongly get zero height early, and then
resolve percentages against zero instead of the real intrinsic size.

Fixes #23942
2024-04-13 14:10:10 +02:00
Aliaksandr Kalenik 69d6abc60f LibWeb: Add test when networking task is interrupted by networking task
It does fetching and uses parseFromString() DOMParser API in the fetch
callback. Following steps end up hanging before reverting
664611bae4:
1. Do fetching initiated by fetch() js call.
2. Invoke fetch callback on networking task source
3. Fetch callback does parseFromString()
4. parseFromString() invokes HTMLParser
5. HTMLLinkElement inserted into new document initiates fetching
6. Fetching callback cannot run because networking source was blocked on
   step 2.
7. HTMLParser::the_end() spins waiting for HTMLLinkElement to unblock
   load event, which will never happen because fetching callback cannot
   proceed.
2024-04-13 12:07:33 +02:00
Andreas Kling 40a914ce1a LibWeb: Use static position for abspos box axes with auto insets
When both insets in a given axis are auto, we should use the static
position for absolutely positioned elements.

By doing this correctly, we exposed a bunch of other small bugs which
had to be fixed to compensate for new test failures. Those fixes are
included here as well:
- Don't apply margins twice.
- Compute the static position containing block chain correctly.

This makes https://brave.com/ look much better. :^)
2024-04-12 09:08:07 +02:00
Aliaksandr Kalenik ee3dd7977d LibWeb: Add popstate event support
It is going to be useful in writing tests for History API.
2024-04-11 21:25:06 +02:00
Timothy Flynn 0ffc338406 LibWeb: Support dimension attributes on HTMLVideoElement 2024-04-11 18:41:57 +02:00
Aliaksandr Kalenik a73bf1607f LibWeb: Mark initial about:blank as ready to run scripts after creation
This matches how other browsers behave.

Fixes https://github.com/SerenityOS/serenity/issues/23892
2024-04-11 18:41:20 +02:00
Aliaksandr Kalenik d86ad2fcfa LibWeb: Process all task source while waiting for document population
"apply the history step" initiated by reloading or back/forward
navigation might require doing fetching while populating a document,
so it is not possible to restrict spin_until() to process only
NavigationAndTraversal task source.

"apply the history step" initiated by synchronous navigation keeps
processing only NavigationAndTraversal task source because it will
never have to populate a document. Another reason to keep synchronous
navigation blocking other task sources is that we crash if active SHE
changes in the middle of "apply the history step" initiated by sync
navigation. The new test is added to makes sure we don't regress that.
2024-04-11 09:40:45 +02:00
Andrew Kaster 4bdd4beb93 Tests/LibWeb: Add a script to create a new test, starting with Text 2024-04-10 17:17:40 -06:00
Andreas Kling 870a954e11 LibWeb: Implement Element.outerHTML
This piggybacks on the same fragment serialization code that innerHTML
uses, but instead of constructing an imaginary parent element like the
spec asks us to, we just add a separate serialization mode that includes
the context element in the serialized markup.

This makes the image carousel on https://utah.edu/ show up :^)
2024-04-09 18:17:14 -04:00
Bastiaan van der Plaat 6f84f69677 LibWeb: Add select selected options collection getter 2024-04-09 09:23:57 +02:00
Bastiaan van der Plaat 7372c01786 LibWeb: Add select and options collection remove method 2024-04-09 09:23:57 +02:00
Bastiaan van der Plaat 5decf4b33c LibWeb: Add HTMLOptionsCollection selected index property 2024-04-09 09:23:57 +02:00
Bastiaan van der Plaat 5c277144d8 LibWeb: Add select and option collection set length 2024-04-09 09:23:57 +02:00
Bastiaan van der Plaat 4e5ce7b63e LibWeb: Add select element size property 2024-04-09 09:23:57 +02:00
Bastiaan van der Plaat 4408581ee0 LibWeb: Refactor SelectItem to allow selecting options without value
Currently the `<select>` dropdown IPC uses the option value attr to
find which option is selected. This won't work when options don't
have values or when multiple options have the same value. Also the
`SelectItem` contained so weird recursive structures that are
impossible to create with HTML. So I refactored `SelectItem` as a
variant, and gave the options a unique id. The id is send back to
`HTMLSelectElement` so it can find out exactly which option element
is selected.
2024-04-08 17:24:48 -04:00
Aliaksandr Kalenik 94d72c174a LibWeb: Allow executing scripts for iframes with src=about:blank
Fixes https://github.com/SerenityOS/serenity/issues/23836
2024-04-08 21:27:34 +02:00
stelar7 0e53b87261 LibCrypto: Add OAEP 2024-04-08 09:34:49 -06:00
stelar7 73a534494c LibCrypto: Add MGF1 2024-04-08 09:34:49 -06:00
Lucas CHOLLET 7f7119c78d LibWeb: Add a test for WindowOrWorkerGlobalScope.createImageBitmap 2024-04-08 14:25:36 +02:00
Shannon Booth db0519ddc1 LibWeb: Fire a pointer event on synthetic clicks 2024-04-08 14:25:08 +02:00
Shannon Booth 1e2ddf9848 LibWeb: Add a test for construction of a PointerEvent 2024-04-08 14:25:08 +02:00
MacDue d7b77d7695 LibWeb: Split SVGFormattingContext up into functions
Doing multiple `for_each_in_subtree()` passes was kind of a hack. We
can resolve everything in a single pass with a little more control over
the layout process. This also fixes a few minor issues like the sizing
of nested `<g>` elements.

More work is needed here though as this is still fairly ad-hoc.

Note: This does regress `css-namespace-tag-name-selector.html`,
previously SVG text within `<a>` elements would appear. However, this
was only because `for_each_in_subtree()` would blindly look through the
InlineNodes from the unimplemented `SVGAElement`s.
2024-04-08 14:24:35 +02:00
Aliaksandr Kalenik a3149c1ce9 LibWeb: Wait for initial navigation to complete before modifying iframe
If initial src of an iframe is "about:blank", it does synchronous
navigation that is not supposed to be interleaved by other navigation
or usage of Document.open().

Fixes crashing in navigation on https://twinings.co.uk/
2024-04-08 09:07:18 +02:00
Kenneth Myhra 29521b50e6 Tests/LibWeb: Verify we throw when trying to pipe through locked streams 2024-04-07 14:26:34 +01:00
Kenneth Myhra 9802cf07bd Tests/LibWeb: Add test to prove we can pipe through a transform stream 2024-04-07 14:26:34 +01:00
Kenneth Myhra a0802b6e29 Tests/LibWeb: Verify we throw when trying to pipe from/to locked streams 2024-04-07 07:01:52 +02:00
Kenneth Myhra 8ff52582ce Tests/LibWeb: Add test to prove we can pipe to a WriteableStream
This proves our ability to pipe the current ReadableStream to a given
WriteableStream.
2024-04-07 07:01:52 +02:00
Shannon Booth 18520561e7 LibWeb: Fix crash for calculated transition duration/delays
As the parser was trying to directly unwrap an unresolved duration.
Currently we are outputting the wrong results for the serialized
duration, but this is still a step forwards.

Fixes a crash seen on: https://evaparish.com/blog/how-i-edit
2024-04-06 19:35:27 +01:00
Nico Weber 2d4964b945 LibGfx/JBIG2: Support custom adaptive template pixels in refinement
The implementation is very similar to #23831.

I created the test exactly like in #23713, except that I replaced the
last four lines in the ini file with:

```
-txt -Param -rATX1 10
-txt -Param -rATY1 -1
-txt -Param -rATX2 4
-txt -Param -rATY2 15
```
2024-04-05 21:32:18 +02:00
Nico Weber 200e36aad3 Tests/JBIG2: Remove test_jbig2_size
It's redundant with test_jbig2_decode nowadays.
2024-04-05 21:32:18 +02:00
Aliaksandr Kalenik 188775c4e3 LibWeb: Add a test for history.pushState() that uses setTimeout() 2024-04-05 21:28:41 +02:00
Timothy Flynn 5d5b69578f LibWeb: Handle <input> element type changing to the image button state
The spec has special steps specific to the image button state to load
the element's image URL.
2024-04-04 21:06:45 +02:00