Commit graph

648 commits

Author SHA1 Message Date
Jamie Mansfield
f82e976df4 LibWeb: Implement DOMStringList
(cherry picked from commit 75216182c9a04741b2f773eb2f26ceb7a96bfbba)
(cherry picked from commit 2a55ab13ef9c735a16674006a518c0e5acf7c88f)

Co-authored-by: Sam Atkins <atkinssj@serenityos.org>
2024-07-29 09:14:06 -04:00
Tim Ledbetter
92ef7f08df LibWeb: Set correct prototype for WorkerLocation
(cherry picked from commit 354e5a6624a92952b1f3b86f98d9b1d0cb0ec048)
2024-07-28 20:48:58 -04:00
Sam Atkins
94674c6999 LibWeb/CSS: Parse custom-idents more consistently
These have a few rules that we didn't follow in most cases:
- CSS-wide keywords are not allowed. (inherit, initial, etc)
- `default` is not allowed.
- The above and any other disallowed identifiers must be tested
  case-insensitively.

This introduces a `parse_custom_ident_value()` method, which takes a
list of disallowed identifier names, and handles the above rules.

(cherry picked from commit 6ae2b8c3d901d8a7255046a4517fddd8b0fa84c4)
2024-07-28 20:21:39 -04:00
Shannon Booth
ff5358d9b8 WebAudio: Add IDL interface for AudioDestinationNode
This is an AudioNode representing the final audio destination and is
what the user will ultimately hear.

This node is used as one of the connecting nodes in athenacrisis.com

Add a placeholder for the interface without anything backing it for now.

(cherry picked from commit 5eb80b8697d458ea2b70112a995e066f64b37ca6)
2024-07-28 20:21:18 -04:00
Jamie Mansfield
9bbf50b755 LibWeb: Stub BroadcastChannel interface
This is enough to get the 1Password login page to load :^)

(cherry picked from commit d4a7cfb68fddbcfaaaddbd7f159c502c869281bf)
2024-07-28 16:44:35 -04:00
Tim Ledbetter
f1cfe231af LibWeb: Perform DOMTokenList token validation in the correct order
(cherry picked from commit 0127190dcf7fd0ee27a935cf1f3f5c74b77c0fc9)
2024-07-28 14:13:20 -04:00
Tim Ledbetter
a88effd0fe LibWeb: Follow the specification steps to serialize a DOMTokenList
This ensures that calling `element.classList.toString()` always
produces the correct value.

(cherry picked from commit ec1f7779cb16223dab0ef9f7bf875c3f7b5724a9)
2024-07-28 14:13:20 -04:00
Tim Ledbetter
66280e96e9 LibWeb: Update Element class list is when class attribute is removed
(cherry picked from commit 21e21abeed122b8b9ebd1bb98ad2201d7edae4f7)
2024-07-28 14:13:20 -04:00
Tim Ledbetter
a439fe0d5b LibWeb: Make document.createElementNS() case-sensitive
Previously, when creating a HTML element with
`document.createElementNS()` we would convert the given local name to
lowercase before deciding which element type to return. We now no
longer perform this lower case conversion, so if an uppercase local
name is provided, an element of type `HTMLUnknownElement` will be
returned. This aligns our implementation with the specification.

(cherry picked from commit 5a796629c61221261c1856e19dd829973e6158f0)
2024-07-28 14:13:11 -04:00
Sam Atkins
1bc896fa60 LibWeb: Implement counter-[increment,reset,set] properties
These control the state of CSS counters.

Parsing code for `reversed(counter-name)` is implemented, but disabled
for now until we are able to resolve values for those.

(cherry picked from commit 017d6c3314d57d4e351764f328c1d25dbc9d033a)
2024-07-28 13:31:02 -04:00
Jamie Mansfield
b1ebaee65f LibWeb/DOM: Check if name is valid in Element.toggleAttribute
This resolves a test in https://wpt.live/dom/nodes/attributes.html.

(cherry picked from commit f774d75f890e89a8483e5c7459de4fd96ce1b479)
2024-07-28 13:17:47 -04:00
Sam Atkins
1ea6e6c395 LibWeb: Correct logic for removing end nodes from HTMLOptionsCollection
This test case would previously crash.

Found with domato.

(cherry picked from commit 0cec68ea996623ee652900986c7232c8d538a209)
2024-07-28 13:00:11 -04:00
Timur Sultanov
ff18de7f46 Tests: Add test for selection option in <select>
Verify that we can select option using JS

(cherry picked from commit 1ce9bbdd6dcf0f1634014e57d700b697635a79d8)
2024-07-28 12:59:58 -04:00
Timur Sultanov
9e36f7c86c LibWeb: Improve HTMLSelectElement spec compliance
Set default `size` value according to spec

(cherry picked from commit ad7b2b7c26c343504be32b9da8961e4fb5df3e86)
2024-07-28 12:59:58 -04:00
Andreas Kling
94c1066f68 LibWeb: Inherit CSS variables across shadow boundaries
This fixes a bunch of issues on https://wpt.fyi/

(cherry picked from commit de2b9eebe6012e321c85cdae0ca14b4be40de624)
2024-07-28 07:33:15 -04:00
Jamie Mansfield
a28019e98b LibWeb/HTML: Implement HTMLMediaElement.addTextTrack
Removes some noise from the console when browsing bbc.co.uk :^)

(cherry picked from commit 793248aec977d4b15006d6e55a960da2e115a734,
amended to s/UIEvents::KeyCode/KeyCode/ to resolve cherry-pick conflict)
2024-07-28 07:32:58 -04:00
doctortheemh
5d1beff35f LibWeb: Parse fill and stroke values
Use the CSS color data type using the CSS parser.

(cherry picked from commit 9cbb3fac123d0ce12bc1d0127d22ed26417dffd7)
2024-07-28 07:32:47 -04:00
Tim Ledbetter
8c56eb0743 LibWeb: Calculate length for all CharacterData type nodes correctly
We now ensure that `Node::is_character_data()` returns true for all
nodes of type character data.

Previously, calling `Node::length()` on `CDataSection` or
`ProcessingInstruction` nodes would return an incorrect value.

(cherry picked from commit 3802d9ccc4ea4428b82c6d584c3667c040cb46c7)
2024-07-28 07:32:31 -04:00
Tim Ledbetter
6a6c0ae791 LibWeb: Don't crash when cloning a CDATASection node
(cherry picked from commit 72ed62a560c654370e6a3583bc8bd078732f44db)
2024-07-28 07:32:31 -04:00
Andreas Kling
a8a5463d33 LibWeb: Make offsetTop and offsetLeft behave more like other browsers
We now follow the rules from the spec more closely, along with an
unspecified quirk for when the offsetParent is a non-positioned body
element. (Spec bug linked in a comment.)

This fixes a whole bunch of css-flexbox tests on WPT, which already had
correct layout, but the reported metrics from JS API were wrong.

(cherry picked from commit d49ae5af32044cb83bc14073b92676a1662c3bc1)
2024-07-28 07:32:17 -04:00
Tim Ledbetter
aa3f3a827a Tests: Add test for Node.nodeName
(cherry picked from commit 97436e7d6574a4fe90e27661e10a6ab4caa68ec1)
2024-07-28 07:32:04 -04:00
Andreas Kling
de66b176d1 LibWeb: Execute the correct script in XMLDocumentBuilder::element_end()
We were mistakenly executing the current node's script instead of the
document's pending parsing-blocking script.

This caused ~1000 WPT tests to time out, since we never ended up firing
a load event for XHTML pages that load multiple external scripts.

(cherry picked from commit 007c292af3202a85eb146b121720d988a66ed64b)
2024-07-28 07:30:38 -04:00
Timur Sultanov
a74e721c09 Tests: Add tests for <select> element behavior
Check that `<select>` element has options available immediately

(cherry picked from commit 2bf37cb91444dbdaa8e0ccf965b7c9e84717da12)
2024-07-28 07:30:11 -04:00
Andreas Kling
99a06079ce LibWeb: Don't proceed with Element.click() on disabled form controls
Fixes an infinite reload loop on some of the dom/events/ tests in WPT.

(cherry picked from commit 273593afba71a42f1d760ac5b6664b77f74ffb7a)
2024-07-28 07:29:46 -04:00
Kemal Zebari
ddefb5a822 LibWeb: Implement Blob::bytes()
Implements https://w3c.github.io/FileAPI/#dom-blob-bytes.

(cherry picked from commit c5f1e478838092dcf6e4ad8ee0bfef32a47e2d68)
2024-07-28 07:29:31 -04:00
Sam Atkins
d8dafd6b28 LibWeb: Check CanvasTextDrawingStyles.font assignment is valid
Checking that the string parsed for the `font` property is not enough,
the spec also wants to rule out CSS-wide keywords like `inherit`. The
simplest way to do so is to check if it's a ShorthandStyleValue, which
also rules out use of `var()`; this matches other browsers' behaviour.

The newly-added test would previously crash, and now doesn't. :^)

(cherry picked from commit 64d45afd8a650981d4dbab98aa49d47629568f5b)
2024-07-27 22:54:40 -04:00
Edwin Hoksberg
a4ed72afae LibWeb: Implement Element::check_visibility
(cherry picked from commit 5f154ba372f9a667351a026aa4a31306c45fd2a5)
2024-07-24 08:08:15 -04:00
Edwin Hoksberg
360cea781b LibWeb: Support content-visibility css
(cherry picked from commit 020b20d817d51dda9c0f9306543c69f4020891eb)
2024-07-23 21:15:27 -04:00
Colin Reeder
a745a849cf LibWeb: Add more legacy -webkit- aliases
(cherry picked from commit 5c315b532e4edc561f30dfc492db9b2dcb59d5de)
2024-07-23 21:15:27 -04:00
Colin Reeder
70388b5676 LibWeb: Add support for -webkit-text-fill-color
(cherry picked from commit 449f81bfbed8343cfb49fcef4a890c33922889e5)

Commit altered to fix cherry-pick issue

Co-Authored-By: circl <circl.lastname@gmail.com>
2024-07-23 21:15:27 -04:00
Kenneth Myhra
abe4428c53 Tests/LibWeb: Move existing Fetch tests in under the Fetch folder
(cherry picked from commit 92f6336fe874bd852f0b759dac4f38e45cdcae5a)
2024-07-23 13:06:46 -04:00
Kenneth Myhra
1d4e673e60 LibWeb: Implement formData() method steps for x-www-form-urlencoded
The Response interface of the Fetch API can now parse form urlencoded
bodies when Content-Type is set to 'application/x-www-form-urlencoded'.

(cherry picked from commit b8fa572c6742c0f1f63da0f63c8b86835a86988d)
2024-07-23 13:06:46 -04:00
bbb651
a732529283 LibWeb: Add new expected window properties to test
Adds `AudioBufferSourceNode` and `BiquadFilterNode` to the
all-window-properties test.

(cherry picked from commit 7b10eb722551716e94ec35a5c5113be83905e5d5)
2024-07-23 13:06:46 -04:00
Ángel Carias
0b74214a6e LibWeb: Implement Text.wholeText
This getter returns the concatenation of the data of the contiguous
Text nodes of `this` (being this plus its siblings) in tree order.

(cherry picked from commit 69da6a0ce400d4a675bfba1f1dd1d313ee1f13c0)
2024-07-23 12:45:37 -04:00
Tim Ledbetter
e399a716fa LibWeb: Ensure document.getElementsByName("") returns no elements
Previously, if a document had any element with a name attribute that
was  set to the empty string, then `document.getElementsByName("")` and
`element.getElementsByName("")` would return a collection including
those elements.

(cherry picked from commit e40352b6b59e99a9f3fd922142c2abafd9840e6c)
2024-07-23 08:44:55 -04:00
Tim Ledbetter
d3c2d2ba3f LibWeb: Ensure document.getElementsByClassName("") returns no elements
Previously, `document.getElementsByClassName("")` would return a
collection containing all elements in the given document.

(cherry picked from commit 0fceede029e6af0cab98e86f20367d8835008472)
2024-07-23 08:44:55 -04:00
Tim Ledbetter
ed4f5b88d3 LibWeb: Ensure document.getElementById("") returns null
Previously, if a document had an element whose id was the empty string,
then `document.getElementById("")` and `element.getElementById("")`
would return that element.

(cherry picked from commit f666d967d6bac289346cf19f833f81bdc22adbdb)
2024-07-23 08:44:55 -04:00
Andreas Kling
c17f7c84ef LibWeb: Use correct scope when removing style sheet inside a shadow tree
Before this change, removing a style element from inside a shadow tree
would cause it to be unregistered with the document-level list of sheets
instead of the shadow-root-level list.

This would eventually lead to a verification failure if someone tried to
update the text contents of that style element, since it was still in
the shadow-root-level list, but now with a null owner element.

Fixes a crash on https://www.swedbank.se/

(cherry picked from commit 3b7534b3628641244b0998fd5061c6fa75a61cf5)
2024-07-23 08:15:57 -04:00
Tim Ledbetter
098a2ad2e9 LibWeb/SVG: Ensure SVG transform has an inverse before using it
This avoids a crash that occurred when calling `getBBox()` on an SVG
element that had a transform with no inverse.

Found by Domato.

(cherry picked from commit d417b7568360f20487e4182e52872b82c8fbbf60)
2024-07-22 18:27:26 -04:00
Tim Ledbetter
949ca71b31 LibWeb: Clamp paintable box maximum scroll offset to 0
Previously calling `PaintableBox::set_scroll_offset()` with a
PaintableBox whose content size was larger than its scrollble overflow
rect would cause a crash.

Found by Domato.

(cherry picked from commit 604f6040a180ac409cf338045c8709a171d920d5)
2024-07-22 18:27:26 -04:00
Tim Ledbetter
1146284d86 LibWeb: Implement Node.isDefaultNamespace()
This method accepts a namespace URI as an argument and returns true if
the given URI is the default namespace on the given node, false
otherwise.

(cherry picked from commit 055c902a375bb34b8c0e31f015c2815fe935c6a9)
2024-07-21 16:55:51 -04:00
Tim Ledbetter
e81cb6d41d LibWeb: Implement Node.lookupNamespaceURI()
This method takes a prefix and returns the namespace URI associated
with it on the given node, or null if no namespace is found.

(cherry picked from commit 27d429a85f359b9c87bf9807e4dea33f7092308a)
2024-07-21 16:55:51 -04:00
Jamie Mansfield
2ad1fa17fb LibWeb/SVG: Implement SVGAElement.relList
(cherry picked from commit 6ca4c2beb08a81bc4aaa2571ee8c5b3207d0b3a2)
2024-07-21 16:55:11 -04:00
Jamie Mansfield
40eaf964d2 LibWeb/SVG: Implement SVGElement.ownerSVGElement
(cherry picked from commit 6f3c5f5ae9f0ee055c44ace5efab0c443626bb5d)
2024-07-21 16:55:11 -04:00
Tim Ledbetter
f05163b00e Tests/LibWeb: Add some tests for Node.isEqualNode
(cherry picked from commit 7e8d71f7fcd530edafef7f4f4356cd233ed2d20b)
2024-07-21 16:54:29 -04:00
Andreas Kling
c6038071a4 LibWeb: Allow splitting surrogate pairs in CharacterData.replaceData()
We're expected to handle this situation gracefully, and certainly not
by falling apart like we were.

Found by Domato.

(cherry picked from commit 33207174a9c1c87657e2ae0875cc85cbf41075f8)
2024-07-21 14:07:57 -04:00
Andreas Kling
1484dbffae LibWeb: Don't try to set selection with anchor/focus in different roots
If the anchor and focus nodes are not within the same document, we can't
use them for a selection range.

Found by Domato.

(cherry picked from commit 416c4788763baa778465d1d004080d322462c0bf)
2024-07-21 14:07:57 -04:00
Andreas Kling
7ddd8bac62 LibWeb: Cap HTML dimension values at 17895700 (same as Firefox)
Instead of allowing arbitrarily large values (which could eventually
overflow an i32), let's just cap them at the same limit as Firefox does.

Found by Domato.

(cherry picked from commit 4e0edd42b95abf8ad707c64414dbe618313ce89e)
2024-07-21 14:07:57 -04:00
Andreas Kling
e99c005c80 LibWeb: Propagate exceptions from setAttribute() in DOMStringMap setter
We were incorrectly assuming that setAttribute() could never fail here,
even when passed an invalid name.

Found by Domato.

(cherry picked from commit 093f1dd805f699801079f55d0d490d80b463ccbb)
2024-07-21 14:07:57 -04:00
Andreas Kling
d2ae01f8ad LibWeb: Fix StringView OOB access when parsing 3-character legacy color
Found by Domato.

(cherry picked from commit 1c00e5688d3330626f809e758bb63c8348776971)
2024-07-21 14:07:57 -04:00