Commit Graph

182 Commits

Author SHA1 Message Date
Luke Wilde
a7b4b170ed LibWeb: Make MessageEvents from {Window,MessagePort}.postMessage trusted
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)
2024-11-17 15:18:20 -05:00
Andreas Kling
23fd706ea9 LibWeb: Fire navigation event as required in History.pushState()
(cherry picked from commit a1519e67fb7a47755d12ff1e8ce2a7de28087933)
2024-11-17 13:47:42 -05:00
Andreas Kling
3e5f37f983 LibWeb: Allow changing the query of file:// URL via history.pushState()
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)
2024-11-17 13:47:42 -05:00
sin-ack
23e49f2835 BindingsGenerator: Handle global interfaces without named properties
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)
2024-11-14 17:46:06 -05:00
Arhcout
0845de1018 LibWeb: Don't trigger onchange event when setting <select> value
(cherry picked from commit 5d00211a8605b0fab9f330082699f6f089961052)
2024-11-14 17:46:06 -05:00
Luke Wilde
c1767b1964 LibWeb: Make iframe insertion steps check the shadow including root
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)
2024-11-13 19:32:02 -05:00
Andreas Kling
337b113e68 LibWeb: Use the correct document URL in DOMParser.parseFromString()
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)
2024-11-13 10:17:34 -05:00
Benjamin Bjerken
a3c986021d LibWeb: Add SVGImageElement load and error events
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)
2024-11-13 10:17:34 -05:00
Benjamin Bjerken
6268e8f559 LibWeb: Fix CloseWatcher constructor for detached iframes
This fixes the last subtest in /close-watcher/frame-removal.html :)

(cherry picked from commit 63d9ed9d8c4fafd569e042e0698bd5dc844a1b29)
2024-11-13 10:17:34 -05:00
Tim Ledbetter
05e8835555 LibWeb: Follow spec steps to set the selectionDirection attribute value
(cherry picked from commit d0b97873d421d092eb41e3b7a7d8959347b3b436)
2024-11-12 22:26:21 -05:00
Tim Ledbetter
be7110a3a4 LibWeb: Map dimension attributes for table elements
(cherry picked from commit 140dc95e6769a41542f98abef333d5bc32b86e39)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
ea8914aeac LibWeb: Map embedded content element attributes to dimension properties
(cherry picked from commit 728236f4d20b4dbabfe0936b79a2f63ac80f4da3)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
8dee6b9ebd Libweb: Map marquee attributes to dimension properties
(cherry picked from commit baca0e5e5568b1b9b301cefa7d6cc8312b39be28)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
7e456212c7 LibWeb: Map hr width attribute to the width dimension property
(cherry picked from commit 4c3101e021e323b487e8ab10026a14fdf40fa2f0)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
bb798071a0 LibWeb: Treat dates and times with repeated separators as invalid
These would previously be treated as valid by the value sanitization
algorithm.

(cherry picked from commit f9282f65d3a4daf7df2c6033b03c70a56130aa72)
2024-11-12 19:57:55 -05:00
Tim Ledbetter
c7a699ed73 LibWeb: Make input type state change handling specification compliant
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)
2024-11-12 10:45:53 -05:00
Tim Ledbetter
6db07d132f LibWeb: Use correct value when parsing datetime-local input type
(cherry picked from commit eb4e40bc49d2ad78335d0e95482a9c702764a8c9)
2024-11-12 10:45:53 -05:00
Tim Ledbetter
a77b65d46a LibWeb: Don't attempt to set selection if control has no selectable text
(cherry picked from commit 2c8fb4957871bca5694fc9e9f8932c9769967bd1)
2024-11-12 10:45:53 -05:00
Totto16
c1b0ac6376 LibWeb: Reject Promise in createImageBitmap for Not Implemented Types
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)
2024-11-11 19:54:09 -05:00
Tim Ledbetter
f9158f4210 LibWeb: Fire iframe load event on document close
This matches the behavior of other browsers.

(cherry picked from commit e1eeb93cc6095a47371d23db0bbf55eb30215cee)
2024-11-11 19:54:09 -05:00
Shannon Booth
9150241db9 LibWeb: Throw a SyntaxError on invalid URL for Location href setter
Aligning with a spec update, fixing 195 tests for:

https://wpt.live/url/failure.html
(cherry picked from commit ea971792b5da5f10cadb4f88f49c9722d88b32f6)
2024-11-11 17:22:42 -05:00
samu698
a37e4092bc LibWeb/HTML: Implement inner text set according to spec
Replaced the ad-hoc implementation with a spec compliant one.
This change fixes 36 WPT tests.

(cherry picked from commit 50f642613de54c73473c216fdc4d7e607e712679)
2024-11-10 21:48:40 -05:00
Tim Ledbetter
fa08ac3631 LibWeb: Fire error event when script has an execution error
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)
2024-11-10 10:46:01 -05:00
Andreas Kling
adad01a830 LibWeb: Always flush character insertions before exiting HTML parser
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)
2024-11-10 10:46:01 -05:00
Tim Ledbetter
961272cf60 LibWeb: Don't crash when determining slot element auto directionality
(cherry picked from commit 0de314507153b6ae17d15f3b03df10a7844ed224)
2024-11-09 16:08:01 -05:00
Jamie Mansfield
ee8de58b98 LibWeb/HTML: Implement DataTransferItem.webkitGetAsEntry()
(cherry picked from commit 2e9aec984cc3c75f10ea3e6f50ea2ed34f4bd2b6)
2024-11-09 16:08:01 -05:00
Khaled Lakehal
71a01c8122 LibWeb: Add setter implementation for location.search
This commit implements the setter for `location.search`, allowing
updates to the query string of the URL.

(cherry picked from commit 514a2a1757b10b9b4ff020237c84f70ba5a79c4b)
2024-11-09 16:08:01 -05:00
Tim Ledbetter
943f47fa97 LibWeb: Implement the setter for location.protocol
(cherry picked from commit 1365289d984c32ca7bc076b7892dd56041ab26e2)
2024-11-09 07:30:40 -05:00
Tim Ledbetter
892c6c0439 LibWeb: Return empty string if object element data URL is invalid
(cherry picked from commit c61262684b51864618de99f8b302567c932455be)
2024-11-09 07:30:40 -05:00
Tim Ledbetter
760fea7ffa LibWeb: Return empty string if image element currentSrc URL is invalid
(cherry picked from commit 4f7a4d9c578429b156f4dab78f4f8b0601be9f39)
2024-11-09 07:30:40 -05:00
Jamie Mansfield
89d7ae75b2 LibWeb/SVG: Implement default_tab_index_value for a element
Another FIXME bites the dust :^)

(cherry picked from commit 9c4e80a3eca8329e5fd9e9fe75eac816b5666069)
2024-11-09 07:30:40 -05:00
Tim Ledbetter
51854c4ffd LibWeb: Resolve HTMLFormElement.action relative to document base URL
Rather than returning a relative URL, an absolutized URL is now
returned relative to the document base URL

(cherry picked from commit 48e5d28ec985aeaee565d06a625a0d664b6975d3)
2024-11-09 07:29:52 -05:00
Tim Ledbetter
ec91831999 LibWeb: Implement HTMLInputElement.formAction
(cherry picked from commit 33c62be7f96eec887d8f65552bbd61439b09a346)
2024-11-09 07:29:52 -05:00
Tim Ledbetter
42d17fb875 LibWeb: Return document URL if formAction attribute is missing or empty
This change also ensures that relative URLs are resolved relative to
the document's base URL.

(cherry picked from commit c25dda767eb43d1620602ccc2c955bc56ef1745b)
2024-11-09 07:29:52 -05:00
Timothy Flynn
7fbe1f8db9 LibWeb: Implement DataTransferItem.prototype.getAsString()
(cherry picked from commit 181ece4d9c64bdd97c19a7c10ed54cdd0e59b43f)
2024-11-08 22:32:11 -05:00
Timothy Flynn
a3b3221607 LibWeb: Implement DataTransferItem.prototype.getAsFile()
This is used on imgur after drag-and-dropping an image onto its page.

(cherry picked from commit b978dba8bdb53f0a1e54b74dde3031242ec268f9)
2024-11-08 22:32:11 -05:00
Jamie Mansfield
38dc317291 LibWeb: Implement HTMLTableCellElement.cellIndex
See:
 - http://wpt.live/html/semantics/tabular-data/attributes-common-to-td-and-th-elements/cellIndex.html
(cherry picked from commit fa5800ebc52a51ad66ddbf5a97ffb9fbb5424b70)
2024-11-08 21:51:25 -05:00
Jamie Mansfield
d81af2f5f5 LibWeb: Set script force async to false when async changes
(cherry picked from commit bedb626c29913f4e355dfd50c29194e15ed71561)
2024-11-08 21:51:25 -05:00
Jamie Mansfield
ceebaac9ef LibWeb: Script force async flag should default to true
See:
 - http://wpt.live/html/semantics/scripting-1/the-script-element/async_001.htm
(cherry picked from commit 77c41a82bec370ae7c8998aa939bd1117a29b31a)
2024-11-08 21:51:25 -05:00
Maciej
1e3bb7dbe1 LibWeb: Make innerHTML for XML nodes actually return inner HTML
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)
2024-11-08 21:51:25 -05:00
Tim Ledbetter
8537cd76f3 LibWeb: Limit HTMLProgressElement.max to positive values
Previously, 0 was returned if `HTMLProgressElement.max` was set to a
negative value.

(cherry picked from commit 353e3e75dcff05f05a65cfc3c70d1cff8db5d50c)
2024-11-07 22:42:20 -05:00
Shannon Booth
51b710bce1 LibWeb: Actually perform "update the href steps"
We completely missed this step, which made setters not actually do
anything!

Fixes 336 test failures on:

https://wpt.live/url/url-setters-a-area.window.html
(cherry picked from commit deff8df2c79af718f08f16bc47f5a22ac6add553)
2024-11-07 21:52:13 -05:00
Tim Ledbetter
95527fd7aa LibWeb: Implement cloning steps for HTMLTextAreaElement
(cherry picked from commit d3e076f963716222787903a9613e0678d909a7ab)
2024-11-04 13:39:53 -05:00
Tim Ledbetter
3710a5b1fb LibWeb: Implement cloning steps for HTMLInputElement
(cherry picked from commit 71cfa705d1eab052e773e6a695c438bab87ec8b0)
2024-11-04 13:39:53 -05:00
Tim Ledbetter
3d130ee6ef LibWeb: Don't group radio buttons from different trees together
Previously, we were searching for other radio buttons from the document
root, rather than the element root.

(cherry picked from commit 67981af276cf55d69d51a872ec83e5b59d793b6c)
2024-11-04 12:29:19 -05:00
Jamie Mansfield
c45292e1aa LibWeb: Don't crash with invalid import maps
See:
 - http://wpt.live/import-maps/multiple-import-maps/with-errors.html
(cherry picked from commit c891b83fc079ee0c34ea9ccc71cfed67e3b14cd2)
2024-11-02 06:45:48 -04:00
Andreas Kling
00e187e0a9 LibWeb: Fix crash when setting innerHTML inside iframe srcdoc document
In particular, there was an assertion failure due to the temporary
parser document's "about base URL" being empty when trying to "parse a
URL" during parsing.

We fix this by copying the context element's document's about base URL
to the temporary parsing document while parsing a fragment.

This fixes a crash when loading search results on https://amazon.com/

(cherry picked from commit b64df59cc61f31b8a0aab91abb4630b3ecb1dcee)
2024-11-02 06:45:38 -04:00
Timothy Flynn
cd69ebdecd LibWeb: Implement the DataTransferItem kind and type attributes
(cherry picked from commit 001d8384e5ea51e2a435517814d299174d65d786)
2024-11-01 22:04:14 -04:00
Timothy Flynn
695771695d LibWeb: Implement the DataTransferItemList length attribute
(cherry picked from commit 843f8f04a518ec0968e4f39ce27264efe0546fa9)
2024-11-01 22:04:14 -04:00
Timothy Flynn
cf1bdd72ac LibWeb: Implement DataTransferItemList.prototype.add()
(cherry picked from commit 74d9cfbf2a2ef84e8634dafc78fc56e6cb153b6b)
2024-11-01 22:04:14 -04:00