Commit graph

2114 commits

Author SHA1 Message Date
Timothy Flynn
7edfeb7056 LibWeb: Support committing changes to <input> elements
We currently fire the change event on <input> elements when they lose
focus. The spec allows for us to also fire the event when changes are
"committed", so long as such an action makes sense for the input type.

This patch detects when the return key is entered in an <input> element
and uses that as the commit action for text-related types. If no change
has occurred since the last commit, no change event is fired.
2023-12-02 10:34:22 +01:00
Tim Schumacher
cb03d3d78f AK: Allow rejecting BitStream reads beyond EOF 2023-12-01 12:48:18 +01:00
Tim Schumacher
270b1176de Tests: Add a test to codify BitStream behavior beyond stream limits 2023-12-01 12:48:18 +01:00
Sam Atkins
9c12112916 LibWeb: Re-enable the css-background-repeat.html ref test
Assuming that my changes to make iframes delay the load event are
correct, and that nothing else was causing the flakiness, this test
should be OK now! (Famous last words.)
2023-12-01 10:28:02 +01:00
Timothy Flynn
a7073c3f1f LibJS: Skip test262 tests with the CanBlockIsFalse flag
From test262 documentation, this flag means:

    The test file should only be run when the [[CanBlock]] property of
    the Agent Record executing the file is `false`.

This patch stubs out the accessor for that internal slot and skips tests
with the CanBlockIsFalse if that internal slot is true.
2023-11-30 09:51:46 -05:00
Timothy Flynn
ff48b7333c LibWeb: Remove shadow roots from elements that are removed from the DOM
We currently create a shadow tree once for each DOM element that renders
with a shadow tree (e.g. <input>, <details>). If such an element is
removed from the DOM, we must remove its shadow tree. Otherwise, the
shadow tree will refer to the old document in perpetuity.

If the node is added back to a DOM, then recreate the shadow tree.
2023-11-30 08:49:15 +00:00
Kenneth Myhra
e3f5bbcbbe Tests/LibWeb: Move existing XHR Text tests in under the XHR folder 2023-11-29 21:51:35 +01:00
Kenneth Myhra
3d86e16407 Tests/LibWeb: Verify instantiation behavior of Blob w/empty constructor
This verifies that a Blob instantiated with an empty constructor creates
a Blob with Blob.size equal to 0 and Blob.type equal to "".
2023-11-29 21:51:35 +01:00
Kenneth Myhra
36fddab68e Tests/LibWeb: Verify XHR.response is an instance of Blob
This verifies that XHR.response is an instance of Blob when
XHR.responseType is set to 'blob'.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
09487679eb Tests/LibWeb: Verify XHR.response is an instance of Document
This verifies that XHR.response is an instance of Document when
XHR.responseType is set to 'document' and the response contains HTML.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
990f73708d Tests/LibWeb: Verify XHR.response is an instance of ArrayBuffer
This verifies that XHR.response is an instance of ArrayBuffer when
XHR.responseType is set to 'arraybuffer'.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
68fa8f52b4 Tests/LibWeb: Verify XHR.open() throws on forbidden method
This verifies that XHR.open() throws a Security Error when 'CONNECT',
'TRACE', or 'TRACK' is passed as the method argument.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
eb6a7ccc59 Tests/LibWeb: Verify XHR.open() throws on illegal token in method arg
This verifies that XHR.open() throws a Syntax Error if an illegal token
is passed to the method argument.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
ff05f19c84 Tests/LibWeb: Verify XHR.send() throws when called twice
This verifies that XHR.send() throws an Invalid State Error when called
twice.
2023-11-29 21:51:35 +01:00
Kenneth Myhra
ac82585ae7 Tests/LibWeb: Verify XHR.send() throws when XHR.readyState is UNSENT
This verifies that an Invalid State Error is being thrown when
XHR.open() has not been called before calling XHR::send().
2023-11-29 21:51:35 +01:00
Shannon Booth
d777b279e3 LibUnicode+Tests: Remove now unused to_unicode_*_full methods
Relocating all of the tests for these in LibUnicode over to the AK
String testsuite.
2023-11-28 17:15:27 -05:00
Timothy Flynn
6aa334767f AK: Ensure assigned-to Strings are dereferenced if needed
If we assign to an existing non-short string, we must dereference its
StringData object to prevent leaking that data.
2023-11-28 16:38:18 +01:00
Michiel Visser
bc9cdd4394 LibCrypto+LibTLS: Switch to the generic SECPxxxr1 implementation 2023-11-27 09:43:07 +03:30
Michiel Visser
59c22c0349 Tests/LibCrypto: Add tests for SECP384r1 curve 2023-11-27 09:43:07 +03:30
Aliaksandr Kalenik
afe24883b7 LibWeb: Remove exit for javascript urls in anchor activation_behavior()
This early return is no longer needed because Navigable::navigate()
can process `javascript:` urls.

Fixes https://github.com/SerenityOS/serenity/issues/22052
2023-11-25 16:33:54 +01:00
Shannon Booth
673329e1bd LibWeb: Use ArrayBufferView for ReadableStreamBYOBReader
Which means that we now have support for DataViews.

Using the ArrayBufferView class also seems to make this read a whole
bunch nicer as well.
2023-11-24 08:43:35 +01:00
timmot
9f2ee86e4d Tests/LibWeb: Test canvas fillStyle parsing of rgb strings 2023-11-24 08:42:18 +01:00
Andrew Kaster
1602663b9e LibWeb+WebWorker: Implement a first cut of post_message for Workers
This implementation completely ignores MessagePorts, and manually plumbs
data through LocalSockets.
2023-11-24 08:41:38 +01:00
Andrew Kaster
79fa892ca1 Tests: Add stub for the internals object when not running in test mode
This allows developers to open LibWeb test html files in Ladybird or in
other browsers to observe their behavior without the internals object.
2023-11-24 08:41:38 +01:00
Timothy Flynn
b5162ceabd LibWeb: Remove special handling of disclosure-open/closed markers
Setting the marker's content width here is causing the text that follows
the marker to be indented a bit too much. This is noticeable when a line
with a disclosure marker is followed by a line with any other marker. It
previously would look something like:

    >    Text inline with disclosure-closed marker
    * Text inline with circle marker
    # Text inline with square marker

Now the disclosure marker line matches other marker types:

    > Text inline with disclosure-closed marker
    * Text inline with circle marker
    # Text inline with square marker
2023-11-24 08:37:19 +01:00
Martin Janiczek
58d0577a02 AK: Fix bugs in Complex += -= + - * / operators
There were two issues:

1) the C+=R and C-=R operators expected arithmetic types to have .real()

2) the R+C, R-C, R*C and R/C operators applied the operation in wrong
   order (did C+R, C-R, C*R and C/R instead). This wouldn't matter for
   + and * which are commutative, but is incorrect for - and /.
2023-11-23 19:54:39 -05:00
Sam Atkins
8fe38f04a3 LibWeb: Skip flakey ref test for now
We currently do not wait for iframes to finish loading before triggering
the document's load event, which creates a race condition for any ref
tests that include iframes. Until that gets fixed, let's skip the one
affected test.

See issue #22012.
2023-11-23 18:50:58 +00:00
Shannon Booth
decc071060 LibWeb: Return a scroll offset of 0 for colgroup elements
Ideally we would not create a layout node at all for these elements so
that every layout node would always have a paintable associated with it.
But for now, to fix the crash, just leave a FIXME and special case this
element.

Also leave a VERIFY to make it easier to debug this type of crash in the
future.

Fixes a crash seen on codecov.io for my 'patch' project.
2023-11-23 13:06:48 +01:00
Andreas Kling
ef809eea1e LibWeb: Don't assume IO.unobserve() called on observed element
It's perfectly possible for JavaScript to call unobserve() on an element
that hasn't been observed. Let's stop asserting if that happens. :^)

Fixes #22020
2023-11-23 09:37:12 +01:00
Nico Weber
57e2b5ef59 LibPDF+Tests: Correctly decode text strings without explicit encoding 2023-11-22 09:08:06 -07:00
Nico Weber
8ee0c75f43 LibPDF: Add (automated!) test for outline encoding
Manually added an Outlines dict with three items, one each for
every text string encoding in its title.

(Preview.app apparently can't handle UTF-8 in outlines either.)
2023-11-22 09:08:06 -07:00
Nico Weber
d345c5b793 LibPDF: Add (automated!) test for info dict encoding
Manually added an info dict with the three text string encoding
methods to encoding.pdf.

(Preview.app apparently can't handle UTF-8 in info dicts!)
2023-11-22 09:08:06 -07:00
Nico Weber
65b895595a LibPDF: Add an encoding test file
For now, this uses UTF-16BE and UTF-8 marked strings in page body text.
These markings should be ignored in body text.

Hand-written, with `set fenc=latin1` and `set binary` in vim, and
xref etc fixed up by running

    mutool clean Tests/LibPDF/encoding.pdf  Tests/LibPDF/encoding.pdf

as usual.
2023-11-22 09:08:06 -07:00
Nico Weber
4c6afd4763 Tests: Install recently added PDF test files
These aren't needed for any automated tests, but it's still nice to have
them in the OS for manual testing.
2023-11-22 09:08:06 -07:00
Sam Atkins
6cd6186399 LibWeb: Don't assume grid size is always Function or Token
This stops `grid-template-columns: minmax({},{})` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
1a17b8a304 LibWeb: Don't assume grid-area parts are Tokens
This stops `grid-area: {}` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
ab9d39bf4a LibWeb: Don't assume grid-row/grid-column parts are Tokens
This stops `grid-column: {}` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
314a30b12e LibWeb: Don't assume grid-line parts are Tokens
This stops `grid-row-start: {}` from crashing.

Also tidy up the parsing code a little.
2023-11-22 09:45:51 +01:00
Sam Atkins
1f6e13d8fe LibWeb: Don't assume repeat() contents are Tokens
This stops `grid-template-rows: repeat({})` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
5e54ff1858 LibWeb: Don't assume rect() contents are Tokens
This stops `clip: rect({});` from crashing.
2023-11-22 09:45:51 +01:00
implicitfield
00c1da8cbc LibWeb: Support cellpadding attribute on table elements 2023-11-21 16:54:02 +01:00
implicitfield
3d1fbcb26b LibWeb: Support valign attribute on tr elements 2023-11-21 16:54:02 +01:00
implicitfield
468b2a5ace LibWeb: Support size attribute on font elements 2023-11-21 16:54:02 +01:00
implicitfield
5df52a5082 LibWeb: Use LibwebLeft and LibwebRight to align table cells 2023-11-21 16:54:02 +01:00
implicitfield
ccea69ad40 LibWeb: Add special handling for text-align when applied to tables
This matches what other engines do, and stops table content from being
misaligned.
2023-11-21 16:54:02 +01:00
implicitfield
a54e62bea0 LibWeb: Support align attribute on table elements 2023-11-21 16:54:02 +01:00
implicitfield
7a766bdb83 LibWeb: Respect the document's link_color for Linktext identifiers 2023-11-21 16:54:02 +01:00
Sam Atkins
19da17f07e LibWeb: Allow calc() in CSS position values 2023-11-21 01:29:26 +01:00
Andreas Kling
cc9de38ea4 LibWeb: Fix null pointer dereference in DOM::Node::remove()
Instead of blindly dereferencing m_registered_observer_list, just use
the add_registered_observer() helper.

Fixes #22005
2023-11-20 20:50:53 +01:00
Nico Weber
eedd978974 Tests: Add a type3 test pdf
A manual test, but better than nothing.

I hand-wrote the file, and used mutool to fix up xref and stream
lengths:

    mutool clean Tests/LibPDF/type3.pdf Tests/LibPDF/type3.pdf

The file contains one `d1` character which per spec shouldn't
contain color statements, and if it does it should be ignored,
and one `d0` character which can contain color.

The text then sets a color before rendering the text.

Per spec, the text color should affect the `d1` character but
not the `d0` one. We get this wrong, but so does Preview.app.
(PDFium gets it right.)

But independent of the colors, just rendering the glyphs at all
at the right position is already good :^)
2023-11-19 22:33:34 +01:00