Truly independent web browser
LibWeb: Ignore namespaced event handler attributes
Kyle Elliott267cb5aed5e4
diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cppindex 22793f5f833..82e258fb6c9 100644--- a/Libraries/LibWeb/HTML/HTMLElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLElement.cpp@@ -861,8 +861,7 @@ void HTMLElement::attribute_changed(Utf16FlyString const& name, Optional<Utf16St}// 1. If namespace is not null, or localName is not the name of an event handler content attribute on element, then return.- // FIXME: Add the namespace part once we support attribute namespaces.- if (name.view().starts_with(u"on"sv)) {+ if (!namespace_.has_value() && name.view().starts_with(u"on"sv)) {#undef __ENUMERATE#define __ENUMERATE(attribute_name, event_name) \if (name == HTML::AttributeNames::attribute_name) { \diff --git a/Tests/LibWeb/Text/expected/HTML/namespaced-event-handler.txt b/Tests/LibWeb/Text/expected/HTML/namespaced-event-handler.txtnew file mode 100644index 00000000000..7ef22e9a431--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/namespaced-event-handler.txt@@ -0,0 +1 @@+PASSdiff --git a/Tests/LibWeb/Text/input/HTML/namespaced-event-handler.html b/Tests/LibWeb/Text/input/HTML/namespaced-event-handler.htmlnew file mode 100644index 00000000000..ae8fd1325cc--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/namespaced-event-handler.html@@ -0,0 +1,13 @@+<!doctype html>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ const message = new Promise(resolve => addEventListener("message", resolve, { once: true }));+ const button = document.createElement("button");+ button.setAttributeNS("urn:test", "onclick", 'top.postMessage("LEAK", "*")');+ button.addEventListener("click", () => top.postMessage("PASS", "*"));+ document.body.appendChild(button);+ button.click();+ println((await message).data);+ });+</script>