Previously, the list was copied when constructing the FormData object,
then the original list was passed to the event, meaning any changes to
the list that happened within the event would not be reflected outside
of it.
(cherry picked from commit ea0e434d1d6b464ab0a56c4b7150950be78ae7d3)
Previously, attempting to parse a floating point number with an integer
part larger than `(2 ^ 31) - 1` would cause the browser to crash. We now
avoid this by converting the integer part of the number to a `double`
rather than an `i32`.
(cherry picked from commit 21a32e4b6dc594c2fe8dd3ee11c829c250a103ad)
The spec says that "isTrusted is a convenience that indicates whether
an event is dispatched by the user agent (as opposed to using
dispatchEvent())"
But when dispatching a pageshow event the flag was incorrectly set
to false.
This fixes https://wpt.fyi/results/html/syntax/parsing/the-end.html
(cherry picked from commit d2fbbabd893d84a6b8b68a8bc8034e4d6dc4da4a)
Fixes at least one WPT test that was previously timing out:
- html/semantics/document-metadata/the-base-element/base_target_does_not_affect_iframe_src_navigation.html
(cherry picked from commit 0b403d30d765ab8e5db3b7443ebeca7f85c3acf2)
For example, in the following abbreviated test HTML:
<span>some text</span>
<script>println("whf")</script>
We would have to craft the expectation file to include the "some text"
segment, usually with some leading whitespace. This is a bit annoying,
and makes it difficult to manually craft expectation files.
So instead of comparing the expectation against the entire DOM inner
text, we now send the inner text of just the <pre> element containing
the test output when we invoke `internals.signalTextTestIsDone`.
(cherry picked from commit bf668696de9a68bbcd6adfeaac809a475da015dc;
amended a bit but not as much as one might think -- see PR for details)
The events tested here are decidedly async. We also can't really write
sync tests of the form "test(async () => {})". Nothing will await the
async callback.
(cherry picked from commit c9cbaeb59d6f699b33bf3924688987b3ca917fee)
Web specs do not return through javascript percent decoded URL path
components - but we were doing this in a number of places due to the
default behaviour of URL::serialize_path.
Since percent encoded URL paths may not contain valid UTF-8 - this was
resulting in us crashing in these places.
For example - on an HTMLAnchorElement when retrieving the pathname for
the URL of:
http://ladybird.org/foo%C2%91%91
To fix this make the URL class only return the percent encoded
serialized path, matching the URL spec. When the decoded path is
required instead explicitly call URL::percent_decode.
This fixes a crash running WPT URL tests for the anchor element on:
https://wpt.live/url/a-element.html
(cherry picked from commit cc557323326ba55514ef2a8a6e0efd7f09330f06;
amended heavily to call `URL::percent_decode()` on all results of
`url.serialize_path()` in the rest of serenity -- except in
LibGemini, where it looked incorrect, and in LibHTTP, where
LadybirdBrowser/ladybird#983 will add it.)
This removes a long-standing source of flakiness seen for example in
WPT's /referrer-policy/ tests.
(cherry picked from commit 063cd68bf472061ec35cf9b8970aa6e614632c9b)
This is required by mini Cloudflare invisible challenges, as it will
only run if the readyState is not "loading". If it is "loading", then
it waits for readystatechange to check that it's not "loading" anymore.
Initial about:blank iframes do not go through the full navigation and
thus don't go through HTMLParser::the_end, which sets the ready state
to something other than "loading". Therefore, the challenge would never
run, as readyState would never change.
Seen on https://discord.com/login
(cherry picked from commit f638f84185938c74a47f5691e8d7c5e1d4dca07c)
The MessagePort one in particular is required by Cloudflare Turnstile,
as the method it takes to run JS in a worker is to `eval` the contents
of `MessageEvent.data`. However, it will only do this if
`MessageEvent.isTrusted` is true, `MessageEvent.origin` is the empty
string and `MessageEvent.source` is `null`.
The Window version is a quick fix whilst in the vicinity, as its
MessageEvent should also be trusted.
(cherry picked from commit 079c28d5e68ad983340c02f3d043acfdf2846d18)
Previously, if there was an unhandled exception in an async test, it
might fail to call done() and timeout. Now we have a default "error"
handler to catch unhandled exceptions and fail the test. A few tests
want to actually test the behavior of window.onerror, so they need an
escape hatch.
(cherry picked from commit 8edaec79dea2f39a31ee97738dfa2e74911efe26)
The spec didn't match how other browsers behave, and we dutifully did
what the spec said. A spec bug has been filed, so let's fix this locally
for now with a FIXME.
(cherry picked from commit e3408c4a7f2fe2ce2435d34e816e9b5b7e58f4af)
DedicatedWorkerGlobalScope is an object with a Global extended
attribute, but does not define any named property getters. This needs to
be handled by setting the prototype chain to:
DedicatedWorkerGlobalScope
^ DedicatedWorkerGlobalScopePrototype
^ WorkerGlobalScopePrototype
(This is different from something like Window, where there is an
intermediate WindowProperties object for named properties.)
Previously, we treated the GlobalMixin object as if it was a simple
prototype object, accidentally setting DedicatedWorkerGlobalScope's
prototype to WorkerGlobalScopePrototype. This caused the expression
self instanceof DedicatedWorkerGlobalScope
to return false inside workers.
This makes us pass many more of the "/xhr/idlharness.any.worker" WPT
tests than before, rather than failing early.
(cherry picked from commit d5948709cd499ef0e7bfa3c24e8c03befed115fe)
The insertion steps for iframes were following an old version of the
spec, where it was checking if the iframe was "in a document tree",
which doesn't cross shadow root boundaries. The spec has since been
updated to check the shadow including root instead.
This is now needed for Cloudflare Turnstile iframe widgets to appear,
as they are now inserted into a shadow root.
(cherry picked from commit 4dd14d812f73377cb1efa5a8e8a114912a90b5af)
We were hard-coding "about:blank" as the document URL for parsed HTML
documents, which was definitely not correct.
This fixes a bunch of WPT tests under /domparsing/ :^)
(cherry picked from commit 55f58eea99c0429dcc39cd0430fafa60eecf5542)
This resolves all WPT timeouts in html/canvas/element/manual/imagebitmap
We can now run an additional 6 tests and 126 subtests :)
This also adds regression tests for this behavior.
(cherry picked from commit 0c04bd66764dfbe8f6da515d09b076683c61e93c)
This change ensures that the value sanitization algorithm is run and
the text cursor is set to the correct position when the type attribute
of an input is changed.
(cherry picked from commit 1b74104c17726018788034f2ad66201889ce6225)
If we don't reject the Promise, it lasts forever,
so rejecting non implemented Promises is essential,
to not timeout in e.g. WPT tests
(cherry picked from commit aab5a9e944f8b1c1a9de321047556bbcaa282a56)
Aligning with a spec update, fixing 195 tests for:
https://wpt.live/url/failure.html
(cherry picked from commit ea971792b5da5f10cadb4f88f49c9722d88b32f6)
Replaced the ad-hoc implementation with a spec compliant one.
This change fixes 36 WPT tests.
(cherry picked from commit 50f642613de54c73473c216fdc4d7e607e712679)
This ensures the HTML parser completes running if it previously stopped
at an insertion point during a call to `document.write`.
(cherry picked from commit 230314238655204b89dd0736da4537b475eb252a)
We now use the "report an exception" AO when a script has an execution
error. This has mostly replaced the older "report the exception" AO in
various specifications. Using this newer AO ensures that
`window.onerror` is invoked when a script has an execution error.
(cherry picked from commit 579a289d3db849657987c3310e7b1d71d290b566)
This fixes an issue where document.write() with only text input would
leave all the character data as unflushed text in the parser.
This fixes many of the WPT tests for document.write().
(cherry picked from commit a0ed12e839f14b3ac80caca0e18a09ca256fd99d)
This commit implements the setter for `location.search`, allowing
updates to the query string of the URL.
(cherry picked from commit 514a2a1757b10b9b4ff020237c84f70ba5a79c4b)
Rather than returning a relative URL, an absolutized URL is now
returned relative to the document base URL
(cherry picked from commit 48e5d28ec985aeaee565d06a625a0d664b6975d3)
This change also ensures that relative URLs are resolved relative to
the document's base URL.
(cherry picked from commit c25dda767eb43d1620602ccc2c955bc56ef1745b)
The spec says to just call the XML serialization algorithm, but it
returns the "outer serialization", and we need the "inner" one. Let's
just concatenate serializations of children; then the result produced is
similar to one from Blink or Gecko.
(cherry picked from commit 9eb568eacbcb36e6c1ffd6e61ebf8242a4422119)