From 5296503e7b47b240c6f281924407f3286b256623 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sun, 2 Feb 2025 14:44:17 +0000 Subject: [PATCH 1/3] LibWeb: Add missing elements to valid local name map Previously, attempting to create a custom element that extended any of these elements would fail. --- Libraries/LibWeb/DOM/ElementFactory.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp index e7f6e3236481..ad0db96c8708 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -177,6 +177,8 @@ ErrorOr> valid_local_names_for_given_html_element_interfac return FixedArray::create({ HTML::TagNames::input }); if (html_element_interface_name == "HTMLLabelElement"sv) return FixedArray::create({ HTML::TagNames::label }); + if (html_element_interface_name == "HTMLLegendElement"sv) + return FixedArray::create({ HTML::TagNames::legend }); if (html_element_interface_name == "HTMLLIElement"sv) return FixedArray::create({ HTML::TagNames::li }); if (html_element_interface_name == "HTMLLinkElement"sv) @@ -199,6 +201,8 @@ ErrorOr> valid_local_names_for_given_html_element_interfac return FixedArray::create({ HTML::TagNames::object }); if (html_element_interface_name == "HTMLOptGroupElement"sv) return FixedArray::create({ HTML::TagNames::optgroup }); + if (html_element_interface_name == "HTMLOptionElement"sv) + return FixedArray::create({ HTML::TagNames::option }); if (html_element_interface_name == "HTMLOutputElement"sv) return FixedArray::create({ HTML::TagNames::output }); if (html_element_interface_name == "HTMLParagraphElement"sv) @@ -231,6 +235,8 @@ ErrorOr> valid_local_names_for_given_html_element_interfac return FixedArray::create({ HTML::TagNames::td, HTML::TagNames::th }); if (html_element_interface_name == "HTMLTableColElement"sv) return FixedArray::create({ HTML::TagNames::colgroup, HTML::TagNames::col }); + if (html_element_interface_name == "HTMLTableRowElement"sv) + return FixedArray::create({ HTML::TagNames::tr }); if (html_element_interface_name == "HTMLTableElement"sv) return FixedArray::create({ HTML::TagNames::table }); if (html_element_interface_name == "HTMLTableSectionElement"sv) From be775d120d36d9ef5215c36b2515bb9797667f56 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sun, 2 Feb 2025 14:45:26 +0000 Subject: [PATCH 2/3] LibWeb: Set `is` value when creating a customized built-in element --- Libraries/LibWeb/DOM/ElementFactory.cpp | 1 + .../custom-elements/builtin-coverage.txt | 449 ++++++++++++++++++ .../custom-elements/builtin-coverage.html | 182 +++++++ 3 files changed, 632 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/custom-elements/builtin-coverage.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/custom-elements/builtin-coverage.html diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp index ad0db96c8708..cdb07303a80d 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -545,6 +545,7 @@ WebIDL::ExceptionOr> create_element(Document& document, FlyStri // namespace prefix set to prefix, local name set to localName, custom element state set to "undefined", custom element definition set to null, // is value set to is, and node document set to document. auto element = create_html_element(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }); + element->set_is_value(is_value); // 3. If the synchronous custom elements flag is set, then run this step while catching any exceptions: if (synchronous_custom_elements_flag) { diff --git a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/builtin-coverage.txt b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/builtin-coverage.txt new file mode 100644 index 000000000000..194f4aa78f2c --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/builtin-coverage.txt @@ -0,0 +1,449 @@ +Harness status: OK + +Found 444 tests + +444 Pass +Pass a: Define a customized built-in element +Pass a: Operator 'new' should instantiate a customized built-in element +Pass a: document.createElement() should instantiate a customized built-in element +Pass a: innerHTML should instantiate a customized built-in element +Pass abbr: Define a customized built-in element +Pass abbr: Operator 'new' should instantiate a customized built-in element +Pass abbr: document.createElement() should instantiate a customized built-in element +Pass abbr: innerHTML should instantiate a customized built-in element +Pass address: Define a customized built-in element +Pass address: Operator 'new' should instantiate a customized built-in element +Pass address: document.createElement() should instantiate a customized built-in element +Pass address: innerHTML should instantiate a customized built-in element +Pass area: Define a customized built-in element +Pass area: Operator 'new' should instantiate a customized built-in element +Pass area: document.createElement() should instantiate a customized built-in element +Pass area: innerHTML should instantiate a customized built-in element +Pass article: Define a customized built-in element +Pass article: Operator 'new' should instantiate a customized built-in element +Pass article: document.createElement() should instantiate a customized built-in element +Pass article: innerHTML should instantiate a customized built-in element +Pass aside: Define a customized built-in element +Pass aside: Operator 'new' should instantiate a customized built-in element +Pass aside: document.createElement() should instantiate a customized built-in element +Pass aside: innerHTML should instantiate a customized built-in element +Pass audio: Define a customized built-in element +Pass audio: Operator 'new' should instantiate a customized built-in element +Pass audio: document.createElement() should instantiate a customized built-in element +Pass audio: innerHTML should instantiate a customized built-in element +Pass b: Define a customized built-in element +Pass b: Operator 'new' should instantiate a customized built-in element +Pass b: document.createElement() should instantiate a customized built-in element +Pass b: innerHTML should instantiate a customized built-in element +Pass base: Define a customized built-in element +Pass base: Operator 'new' should instantiate a customized built-in element +Pass base: document.createElement() should instantiate a customized built-in element +Pass base: innerHTML should instantiate a customized built-in element +Pass bdi: Define a customized built-in element +Pass bdi: Operator 'new' should instantiate a customized built-in element +Pass bdi: document.createElement() should instantiate a customized built-in element +Pass bdi: innerHTML should instantiate a customized built-in element +Pass bdo: Define a customized built-in element +Pass bdo: Operator 'new' should instantiate a customized built-in element +Pass bdo: document.createElement() should instantiate a customized built-in element +Pass bdo: innerHTML should instantiate a customized built-in element +Pass blockquote: Define a customized built-in element +Pass blockquote: Operator 'new' should instantiate a customized built-in element +Pass blockquote: document.createElement() should instantiate a customized built-in element +Pass blockquote: innerHTML should instantiate a customized built-in element +Pass body: Define a customized built-in element +Pass body: Operator 'new' should instantiate a customized built-in element +Pass body: document.createElement() should instantiate a customized built-in element +Pass body: document parser should instantiate a customized built-in element +Pass br: Define a customized built-in element +Pass br: Operator 'new' should instantiate a customized built-in element +Pass br: document.createElement() should instantiate a customized built-in element +Pass br: innerHTML should instantiate a customized built-in element +Pass button: Define a customized built-in element +Pass button: Operator 'new' should instantiate a customized built-in element +Pass button: document.createElement() should instantiate a customized built-in element +Pass button: innerHTML should instantiate a customized built-in element +Pass canvas: Define a customized built-in element +Pass canvas: Operator 'new' should instantiate a customized built-in element +Pass canvas: document.createElement() should instantiate a customized built-in element +Pass canvas: innerHTML should instantiate a customized built-in element +Pass caption: Define a customized built-in element +Pass caption: Operator 'new' should instantiate a customized built-in element +Pass caption: document.createElement() should instantiate a customized built-in element +Pass caption: innerHTML should instantiate a customized built-in element +Pass cite: Define a customized built-in element +Pass cite: Operator 'new' should instantiate a customized built-in element +Pass cite: document.createElement() should instantiate a customized built-in element +Pass cite: innerHTML should instantiate a customized built-in element +Pass code: Define a customized built-in element +Pass code: Operator 'new' should instantiate a customized built-in element +Pass code: document.createElement() should instantiate a customized built-in element +Pass code: innerHTML should instantiate a customized built-in element +Pass col: Define a customized built-in element +Pass col: Operator 'new' should instantiate a customized built-in element +Pass col: document.createElement() should instantiate a customized built-in element +Pass col: innerHTML should instantiate a customized built-in element +Pass colgroup: Define a customized built-in element +Pass colgroup: Operator 'new' should instantiate a customized built-in element +Pass colgroup: document.createElement() should instantiate a customized built-in element +Pass colgroup: innerHTML should instantiate a customized built-in element +Pass data: Define a customized built-in element +Pass data: Operator 'new' should instantiate a customized built-in element +Pass data: document.createElement() should instantiate a customized built-in element +Pass data: innerHTML should instantiate a customized built-in element +Pass dd: Define a customized built-in element +Pass dd: Operator 'new' should instantiate a customized built-in element +Pass dd: document.createElement() should instantiate a customized built-in element +Pass dd: innerHTML should instantiate a customized built-in element +Pass del: Define a customized built-in element +Pass del: Operator 'new' should instantiate a customized built-in element +Pass del: document.createElement() should instantiate a customized built-in element +Pass del: innerHTML should instantiate a customized built-in element +Pass details: Define a customized built-in element +Pass details: Operator 'new' should instantiate a customized built-in element +Pass details: document.createElement() should instantiate a customized built-in element +Pass details: innerHTML should instantiate a customized built-in element +Pass dfn: Define a customized built-in element +Pass dfn: Operator 'new' should instantiate a customized built-in element +Pass dfn: document.createElement() should instantiate a customized built-in element +Pass dfn: innerHTML should instantiate a customized built-in element +Pass div: Define a customized built-in element +Pass div: Operator 'new' should instantiate a customized built-in element +Pass div: document.createElement() should instantiate a customized built-in element +Pass div: innerHTML should instantiate a customized built-in element +Pass dl: Define a customized built-in element +Pass dl: Operator 'new' should instantiate a customized built-in element +Pass dl: document.createElement() should instantiate a customized built-in element +Pass dl: innerHTML should instantiate a customized built-in element +Pass dt: Define a customized built-in element +Pass dt: Operator 'new' should instantiate a customized built-in element +Pass dt: document.createElement() should instantiate a customized built-in element +Pass dt: innerHTML should instantiate a customized built-in element +Pass em: Define a customized built-in element +Pass em: Operator 'new' should instantiate a customized built-in element +Pass em: document.createElement() should instantiate a customized built-in element +Pass em: innerHTML should instantiate a customized built-in element +Pass embed: Define a customized built-in element +Pass embed: Operator 'new' should instantiate a customized built-in element +Pass embed: document.createElement() should instantiate a customized built-in element +Pass embed: innerHTML should instantiate a customized built-in element +Pass fieldset: Define a customized built-in element +Pass fieldset: Operator 'new' should instantiate a customized built-in element +Pass fieldset: document.createElement() should instantiate a customized built-in element +Pass fieldset: innerHTML should instantiate a customized built-in element +Pass figcaption: Define a customized built-in element +Pass figcaption: Operator 'new' should instantiate a customized built-in element +Pass figcaption: document.createElement() should instantiate a customized built-in element +Pass figcaption: innerHTML should instantiate a customized built-in element +Pass figure: Define a customized built-in element +Pass figure: Operator 'new' should instantiate a customized built-in element +Pass figure: document.createElement() should instantiate a customized built-in element +Pass figure: innerHTML should instantiate a customized built-in element +Pass footer: Define a customized built-in element +Pass footer: Operator 'new' should instantiate a customized built-in element +Pass footer: document.createElement() should instantiate a customized built-in element +Pass footer: innerHTML should instantiate a customized built-in element +Pass form: Define a customized built-in element +Pass form: Operator 'new' should instantiate a customized built-in element +Pass form: document.createElement() should instantiate a customized built-in element +Pass form: innerHTML should instantiate a customized built-in element +Pass h1: Define a customized built-in element +Pass h1: Operator 'new' should instantiate a customized built-in element +Pass h1: document.createElement() should instantiate a customized built-in element +Pass h1: innerHTML should instantiate a customized built-in element +Pass h2: Define a customized built-in element +Pass h2: Operator 'new' should instantiate a customized built-in element +Pass h2: document.createElement() should instantiate a customized built-in element +Pass h2: innerHTML should instantiate a customized built-in element +Pass h3: Define a customized built-in element +Pass h3: Operator 'new' should instantiate a customized built-in element +Pass h3: document.createElement() should instantiate a customized built-in element +Pass h3: innerHTML should instantiate a customized built-in element +Pass h4: Define a customized built-in element +Pass h4: Operator 'new' should instantiate a customized built-in element +Pass h4: document.createElement() should instantiate a customized built-in element +Pass h4: innerHTML should instantiate a customized built-in element +Pass h5: Define a customized built-in element +Pass h5: Operator 'new' should instantiate a customized built-in element +Pass h5: document.createElement() should instantiate a customized built-in element +Pass h5: innerHTML should instantiate a customized built-in element +Pass h6: Define a customized built-in element +Pass h6: Operator 'new' should instantiate a customized built-in element +Pass h6: document.createElement() should instantiate a customized built-in element +Pass h6: innerHTML should instantiate a customized built-in element +Pass header: Define a customized built-in element +Pass header: Operator 'new' should instantiate a customized built-in element +Pass header: document.createElement() should instantiate a customized built-in element +Pass header: innerHTML should instantiate a customized built-in element +Pass hgroup: Define a customized built-in element +Pass hgroup: Operator 'new' should instantiate a customized built-in element +Pass hgroup: document.createElement() should instantiate a customized built-in element +Pass hgroup: innerHTML should instantiate a customized built-in element +Pass hr: Define a customized built-in element +Pass hr: Operator 'new' should instantiate a customized built-in element +Pass hr: document.createElement() should instantiate a customized built-in element +Pass hr: innerHTML should instantiate a customized built-in element +Pass html: Define a customized built-in element +Pass html: Operator 'new' should instantiate a customized built-in element +Pass html: document.createElement() should instantiate a customized built-in element +Pass html: document parser should instantiate a customized built-in element +Pass i: Define a customized built-in element +Pass i: Operator 'new' should instantiate a customized built-in element +Pass i: document.createElement() should instantiate a customized built-in element +Pass i: innerHTML should instantiate a customized built-in element +Pass iframe: Define a customized built-in element +Pass iframe: Operator 'new' should instantiate a customized built-in element +Pass iframe: document.createElement() should instantiate a customized built-in element +Pass iframe: innerHTML should instantiate a customized built-in element +Pass img: Define a customized built-in element +Pass img: Operator 'new' should instantiate a customized built-in element +Pass img: document.createElement() should instantiate a customized built-in element +Pass img: innerHTML should instantiate a customized built-in element +Pass input: Define a customized built-in element +Pass input: Operator 'new' should instantiate a customized built-in element +Pass input: document.createElement() should instantiate a customized built-in element +Pass input: innerHTML should instantiate a customized built-in element +Pass ins: Define a customized built-in element +Pass ins: Operator 'new' should instantiate a customized built-in element +Pass ins: document.createElement() should instantiate a customized built-in element +Pass ins: innerHTML should instantiate a customized built-in element +Pass kbd: Define a customized built-in element +Pass kbd: Operator 'new' should instantiate a customized built-in element +Pass kbd: document.createElement() should instantiate a customized built-in element +Pass kbd: innerHTML should instantiate a customized built-in element +Pass label: Define a customized built-in element +Pass label: Operator 'new' should instantiate a customized built-in element +Pass label: document.createElement() should instantiate a customized built-in element +Pass label: innerHTML should instantiate a customized built-in element +Pass legend: Define a customized built-in element +Pass legend: Operator 'new' should instantiate a customized built-in element +Pass legend: document.createElement() should instantiate a customized built-in element +Pass legend: innerHTML should instantiate a customized built-in element +Pass li: Define a customized built-in element +Pass li: Operator 'new' should instantiate a customized built-in element +Pass li: document.createElement() should instantiate a customized built-in element +Pass li: innerHTML should instantiate a customized built-in element +Pass link: Define a customized built-in element +Pass link: Operator 'new' should instantiate a customized built-in element +Pass link: document.createElement() should instantiate a customized built-in element +Pass link: innerHTML should instantiate a customized built-in element +Pass main: Define a customized built-in element +Pass main: Operator 'new' should instantiate a customized built-in element +Pass main: document.createElement() should instantiate a customized built-in element +Pass main: innerHTML should instantiate a customized built-in element +Pass map: Define a customized built-in element +Pass map: Operator 'new' should instantiate a customized built-in element +Pass map: document.createElement() should instantiate a customized built-in element +Pass map: innerHTML should instantiate a customized built-in element +Pass mark: Define a customized built-in element +Pass mark: Operator 'new' should instantiate a customized built-in element +Pass mark: document.createElement() should instantiate a customized built-in element +Pass mark: innerHTML should instantiate a customized built-in element +Pass menu: Define a customized built-in element +Pass menu: Operator 'new' should instantiate a customized built-in element +Pass menu: document.createElement() should instantiate a customized built-in element +Pass menu: innerHTML should instantiate a customized built-in element +Pass meta: Define a customized built-in element +Pass meta: Operator 'new' should instantiate a customized built-in element +Pass meta: document.createElement() should instantiate a customized built-in element +Pass meta: innerHTML should instantiate a customized built-in element +Pass meter: Define a customized built-in element +Pass meter: Operator 'new' should instantiate a customized built-in element +Pass meter: document.createElement() should instantiate a customized built-in element +Pass meter: innerHTML should instantiate a customized built-in element +Pass nav: Define a customized built-in element +Pass nav: Operator 'new' should instantiate a customized built-in element +Pass nav: document.createElement() should instantiate a customized built-in element +Pass nav: innerHTML should instantiate a customized built-in element +Pass noscript: Define a customized built-in element +Pass noscript: Operator 'new' should instantiate a customized built-in element +Pass noscript: document.createElement() should instantiate a customized built-in element +Pass noscript: innerHTML should instantiate a customized built-in element +Pass object: Define a customized built-in element +Pass object: Operator 'new' should instantiate a customized built-in element +Pass object: document.createElement() should instantiate a customized built-in element +Pass object: innerHTML should instantiate a customized built-in element +Pass ol: Define a customized built-in element +Pass ol: Operator 'new' should instantiate a customized built-in element +Pass ol: document.createElement() should instantiate a customized built-in element +Pass ol: innerHTML should instantiate a customized built-in element +Pass optgroup: Define a customized built-in element +Pass optgroup: Operator 'new' should instantiate a customized built-in element +Pass optgroup: document.createElement() should instantiate a customized built-in element +Pass optgroup: innerHTML should instantiate a customized built-in element +Pass option: Define a customized built-in element +Pass option: Operator 'new' should instantiate a customized built-in element +Pass option: document.createElement() should instantiate a customized built-in element +Pass option: innerHTML should instantiate a customized built-in element +Pass output: Define a customized built-in element +Pass output: Operator 'new' should instantiate a customized built-in element +Pass output: document.createElement() should instantiate a customized built-in element +Pass output: innerHTML should instantiate a customized built-in element +Pass p: Define a customized built-in element +Pass p: Operator 'new' should instantiate a customized built-in element +Pass p: document.createElement() should instantiate a customized built-in element +Pass p: innerHTML should instantiate a customized built-in element +Pass param: Define a customized built-in element +Pass param: Operator 'new' should instantiate a customized built-in element +Pass param: document.createElement() should instantiate a customized built-in element +Pass param: innerHTML should instantiate a customized built-in element +Pass picture: Define a customized built-in element +Pass picture: Operator 'new' should instantiate a customized built-in element +Pass picture: document.createElement() should instantiate a customized built-in element +Pass picture: innerHTML should instantiate a customized built-in element +Pass pre: Define a customized built-in element +Pass pre: Operator 'new' should instantiate a customized built-in element +Pass pre: document.createElement() should instantiate a customized built-in element +Pass pre: innerHTML should instantiate a customized built-in element +Pass progress: Define a customized built-in element +Pass progress: Operator 'new' should instantiate a customized built-in element +Pass progress: document.createElement() should instantiate a customized built-in element +Pass progress: innerHTML should instantiate a customized built-in element +Pass q: Define a customized built-in element +Pass q: Operator 'new' should instantiate a customized built-in element +Pass q: document.createElement() should instantiate a customized built-in element +Pass q: innerHTML should instantiate a customized built-in element +Pass rp: Define a customized built-in element +Pass rp: Operator 'new' should instantiate a customized built-in element +Pass rp: document.createElement() should instantiate a customized built-in element +Pass rp: innerHTML should instantiate a customized built-in element +Pass rt: Define a customized built-in element +Pass rt: Operator 'new' should instantiate a customized built-in element +Pass rt: document.createElement() should instantiate a customized built-in element +Pass rt: innerHTML should instantiate a customized built-in element +Pass ruby: Define a customized built-in element +Pass ruby: Operator 'new' should instantiate a customized built-in element +Pass ruby: document.createElement() should instantiate a customized built-in element +Pass ruby: innerHTML should instantiate a customized built-in element +Pass s: Define a customized built-in element +Pass s: Operator 'new' should instantiate a customized built-in element +Pass s: document.createElement() should instantiate a customized built-in element +Pass s: innerHTML should instantiate a customized built-in element +Pass samp: Define a customized built-in element +Pass samp: Operator 'new' should instantiate a customized built-in element +Pass samp: document.createElement() should instantiate a customized built-in element +Pass samp: innerHTML should instantiate a customized built-in element +Pass script: Define a customized built-in element +Pass script: Operator 'new' should instantiate a customized built-in element +Pass script: document.createElement() should instantiate a customized built-in element +Pass script: innerHTML should instantiate a customized built-in element +Pass section: Define a customized built-in element +Pass section: Operator 'new' should instantiate a customized built-in element +Pass section: document.createElement() should instantiate a customized built-in element +Pass section: innerHTML should instantiate a customized built-in element +Pass select: Define a customized built-in element +Pass select: Operator 'new' should instantiate a customized built-in element +Pass select: document.createElement() should instantiate a customized built-in element +Pass select: innerHTML should instantiate a customized built-in element +Pass small: Define a customized built-in element +Pass small: Operator 'new' should instantiate a customized built-in element +Pass small: document.createElement() should instantiate a customized built-in element +Pass small: innerHTML should instantiate a customized built-in element +Pass source: Define a customized built-in element +Pass source: Operator 'new' should instantiate a customized built-in element +Pass source: document.createElement() should instantiate a customized built-in element +Pass source: innerHTML should instantiate a customized built-in element +Pass span: Define a customized built-in element +Pass span: Operator 'new' should instantiate a customized built-in element +Pass span: document.createElement() should instantiate a customized built-in element +Pass span: innerHTML should instantiate a customized built-in element +Pass strong: Define a customized built-in element +Pass strong: Operator 'new' should instantiate a customized built-in element +Pass strong: document.createElement() should instantiate a customized built-in element +Pass strong: innerHTML should instantiate a customized built-in element +Pass style: Define a customized built-in element +Pass style: Operator 'new' should instantiate a customized built-in element +Pass style: document.createElement() should instantiate a customized built-in element +Pass style: innerHTML should instantiate a customized built-in element +Pass sub: Define a customized built-in element +Pass sub: Operator 'new' should instantiate a customized built-in element +Pass sub: document.createElement() should instantiate a customized built-in element +Pass sub: innerHTML should instantiate a customized built-in element +Pass summary: Define a customized built-in element +Pass summary: Operator 'new' should instantiate a customized built-in element +Pass summary: document.createElement() should instantiate a customized built-in element +Pass summary: innerHTML should instantiate a customized built-in element +Pass sup: Define a customized built-in element +Pass sup: Operator 'new' should instantiate a customized built-in element +Pass sup: document.createElement() should instantiate a customized built-in element +Pass sup: innerHTML should instantiate a customized built-in element +Pass table: Define a customized built-in element +Pass table: Operator 'new' should instantiate a customized built-in element +Pass table: document.createElement() should instantiate a customized built-in element +Pass table: innerHTML should instantiate a customized built-in element +Pass tbody: Define a customized built-in element +Pass tbody: Operator 'new' should instantiate a customized built-in element +Pass tbody: document.createElement() should instantiate a customized built-in element +Pass tbody: innerHTML should instantiate a customized built-in element +Pass td: Define a customized built-in element +Pass td: Operator 'new' should instantiate a customized built-in element +Pass td: document.createElement() should instantiate a customized built-in element +Pass td: innerHTML should instantiate a customized built-in element +Pass template: Define a customized built-in element +Pass template: Operator 'new' should instantiate a customized built-in element +Pass template: document.createElement() should instantiate a customized built-in element +Pass template: innerHTML should instantiate a customized built-in element +Pass textarea: Define a customized built-in element +Pass textarea: Operator 'new' should instantiate a customized built-in element +Pass textarea: document.createElement() should instantiate a customized built-in element +Pass textarea: innerHTML should instantiate a customized built-in element +Pass tfoot: Define a customized built-in element +Pass tfoot: Operator 'new' should instantiate a customized built-in element +Pass tfoot: document.createElement() should instantiate a customized built-in element +Pass tfoot: innerHTML should instantiate a customized built-in element +Pass th: Define a customized built-in element +Pass th: Operator 'new' should instantiate a customized built-in element +Pass th: document.createElement() should instantiate a customized built-in element +Pass th: innerHTML should instantiate a customized built-in element +Pass thead: Define a customized built-in element +Pass thead: Operator 'new' should instantiate a customized built-in element +Pass thead: document.createElement() should instantiate a customized built-in element +Pass thead: innerHTML should instantiate a customized built-in element +Pass time: Define a customized built-in element +Pass time: Operator 'new' should instantiate a customized built-in element +Pass time: document.createElement() should instantiate a customized built-in element +Pass time: innerHTML should instantiate a customized built-in element +Pass title: Define a customized built-in element +Pass title: Operator 'new' should instantiate a customized built-in element +Pass title: document.createElement() should instantiate a customized built-in element +Pass title: innerHTML should instantiate a customized built-in element +Pass tr: Define a customized built-in element +Pass tr: Operator 'new' should instantiate a customized built-in element +Pass tr: document.createElement() should instantiate a customized built-in element +Pass tr: innerHTML should instantiate a customized built-in element +Pass track: Define a customized built-in element +Pass track: Operator 'new' should instantiate a customized built-in element +Pass track: document.createElement() should instantiate a customized built-in element +Pass track: innerHTML should instantiate a customized built-in element +Pass u: Define a customized built-in element +Pass u: Operator 'new' should instantiate a customized built-in element +Pass u: document.createElement() should instantiate a customized built-in element +Pass u: innerHTML should instantiate a customized built-in element +Pass ul: Define a customized built-in element +Pass ul: Operator 'new' should instantiate a customized built-in element +Pass ul: document.createElement() should instantiate a customized built-in element +Pass ul: innerHTML should instantiate a customized built-in element +Pass var: Define a customized built-in element +Pass var: Operator 'new' should instantiate a customized built-in element +Pass var: document.createElement() should instantiate a customized built-in element +Pass var: innerHTML should instantiate a customized built-in element +Pass video: Define a customized built-in element +Pass video: Operator 'new' should instantiate a customized built-in element +Pass video: document.createElement() should instantiate a customized built-in element +Pass video: innerHTML should instantiate a customized built-in element +Pass wbr: Define a customized built-in element +Pass wbr: Operator 'new' should instantiate a customized built-in element +Pass wbr: document.createElement() should instantiate a customized built-in element +Pass wbr: innerHTML should instantiate a customized built-in element +Pass datalist: Define a customized built-in element +Pass datalist: Operator 'new' should instantiate a customized built-in element +Pass datalist: document.createElement() should instantiate a customized built-in element +Pass datalist: innerHTML should instantiate a customized built-in element +Pass dialog: Define a customized built-in element +Pass dialog: Operator 'new' should instantiate a customized built-in element +Pass dialog: document.createElement() should instantiate a customized built-in element +Pass dialog: innerHTML should instantiate a customized built-in element +Pass slot: Define a customized built-in element +Pass slot: Operator 'new' should instantiate a customized built-in element +Pass slot: document.createElement() should instantiate a customized built-in element +Pass slot: innerHTML should instantiate a customized built-in element \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/custom-elements/builtin-coverage.html b/Tests/LibWeb/Text/input/wpt-import/custom-elements/builtin-coverage.html new file mode 100644 index 000000000000..bebffbc8aa16 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/custom-elements/builtin-coverage.html @@ -0,0 +1,182 @@ + + + + + + + + + +
+ + + From b8b3c085d5c50d7611f884b3231c549cf0f3b95d Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sun, 2 Feb 2025 14:47:12 +0000 Subject: [PATCH 3/3] LibWeb: Update `create_element()` to follow the latest specification --- Libraries/LibWeb/DOM/ElementFactory.cpp | 33 +++++++++---------- .../cross-realm-callback-report-exception.txt | 5 ++- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp index cdb07303a80d..c74795ef7487 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include @@ -526,19 +527,13 @@ WebIDL::ExceptionOr> create_element(Document& document, FlyStri { auto& realm = document.realm(); - // 1. If prefix was not given, let prefix be null. - // NOTE: This is already taken care of by `prefix` having a default value. - - // 2. If is was not given, let is be null. - // NOTE: This is already taken care of by `is` having a default value. - - // 3. Let result be null. + // 1. Let result be null. // NOTE: We collapse this into just returning an element where necessary. - // 4. Let definition be the result of looking up a custom element definition given document, namespace, localName, and is. + // 2. Let definition be the result of looking up a custom element definition given document, namespace, localName, and is. auto definition = document.lookup_custom_element_definition(namespace_, local_name, is_value); - // 5. If definition is non-null, and definition’s name is not equal to its local name (i.e., definition represents a customized built-in element), then: + // 3. If definition is non-null, and definition’s name is not equal to its local name (i.e., definition represents a customized built-in element), then: if (definition && definition->name() != definition->local_name()) { // 1. Let interface be the element interface for localName and the HTML namespace. // 2. Set result to a new element that implements interface, with no attributes, namespace set to the HTML namespace, @@ -554,8 +549,9 @@ WebIDL::ExceptionOr> create_element(Document& document, FlyStri // If this step threw an exception, then: if (upgrade_result.is_throw_completion()) { - // 1. Report the exception. - HTML::report_exception(upgrade_result, realm); + // 1. Report exception for definition’s constructor’s corresponding JavaScript object’s associated realm’s global object. + auto& window_or_worker = as(HTML::relevant_global_object(definition->constructor().callback)); + window_or_worker.report_an_exception(upgrade_result.error_value()); // 2. Set result’s custom element state to "failed". element->set_custom_element_state(CustomElementState::Failed); @@ -570,9 +566,9 @@ WebIDL::ExceptionOr> create_element(Document& document, FlyStri return element; } - // 6. Otherwise, if definition is non-null, then: + // 4. Otherwise, if definition is non-null, then: if (definition) { - // 1. If the synchronous custom elements flag is set, then run these steps while catching any exceptions: + // 1. If synchronousCustomElements is true, then run these steps while catching any exceptions: if (synchronous_custom_elements_flag) { auto synchronously_upgrade_custom_element = [&]() -> JS::ThrowCompletionOr> { // 1. Let C be definition’s constructor. @@ -625,8 +621,9 @@ WebIDL::ExceptionOr> create_element(Document& document, FlyStri // If any of these steps threw an exception, then: if (result.is_throw_completion()) { - // 1. Report the exception. - HTML::report_exception(result, realm); + // 1. Report exception for definition’s constructor’s corresponding JavaScript object’s associated realm’s global object. + auto& window_or_worker = as(HTML::relevant_global_object(definition->constructor().callback)); + window_or_worker.report_an_exception(result.error_value()); // 2. Set result to a new element that implements the HTMLUnknownElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix, // local name set to localName, custom element state set to "failed", custom element definition set to null, is value set to null, and node document set to document. @@ -649,7 +646,7 @@ WebIDL::ExceptionOr> create_element(Document& document, FlyStri return element; } - // 7. Otherwise: + // 5. Otherwise: // 1. Let interface be the element interface for localName and namespace. // 2. Set result to a new element that implements interface, with no attributes, namespace set to namespace, namespace prefix set to prefix, // local name set to localName, custom element state set to "uncustomized", custom element definition set to null, is value set to is, @@ -684,8 +681,8 @@ WebIDL::ExceptionOr> create_element(Document& document, FlyStri return element; } - // 8. Return result. - // NOTE: See step 3. + // 6. Return result. + // NOTE: See step 1. // https://dom.spec.whatwg.org/#concept-element-interface // The element interface for any name and namespace is Element, unless stated otherwise. diff --git a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/cross-realm-callback-report-exception.txt b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/cross-realm-callback-report-exception.txt index f8866dd7d64e..1aeb1ebbab43 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/cross-realm-callback-report-exception.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/cross-realm-callback-report-exception.txt @@ -2,9 +2,8 @@ Harness status: OK Found 5 tests -4 Pass -1 Fail -Fail constructor +5 Pass +Pass constructor Pass connectedCallback Pass disconnectedCallback Pass attributeChangedCallback