From afe24883b7cfe02688e7c7bf253b3c2a0927a334 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sat, 25 Nov 2023 13:58:13 +0100 Subject: [PATCH] LibWeb: Remove exit for javascript urls in anchor activation_behavior() This early return is no longer needed because Navigable::navigate() can process `javascript:` urls. Fixes https://github.com/SerenityOS/serenity/issues/22052 --- .../anchor-element-with-javascript-url-href.txt | 1 + .../anchor-element-with-javascript-url-href.html | 14 ++++++++++++++ .../Libraries/LibWeb/HTML/HTMLAnchorElement.cpp | 5 ----- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/anchor-element-with-javascript-url-href.txt create mode 100644 Tests/LibWeb/Text/input/anchor-element-with-javascript-url-href.html diff --git a/Tests/LibWeb/Text/expected/anchor-element-with-javascript-url-href.txt b/Tests/LibWeb/Text/expected/anchor-element-with-javascript-url-href.txt new file mode 100644 index 0000000000..055269e2a0 --- /dev/null +++ b/Tests/LibWeb/Text/expected/anchor-element-with-javascript-url-href.txt @@ -0,0 +1 @@ + link clicked! \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/anchor-element-with-javascript-url-href.html b/Tests/LibWeb/Text/input/anchor-element-with-javascript-url-href.html new file mode 100644 index 0000000000..389a519ee8 --- /dev/null +++ b/Tests/LibWeb/Text/input/anchor-element-with-javascript-url-href.html @@ -0,0 +1,14 @@ + + + + diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index acbae7971e..b3d1da2b29 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -57,11 +57,6 @@ void HTMLAnchorElement::activation_behavior(Web::DOM::Event const&) if (href().is_empty()) return; - // AD-HOC: follow_the_hyperlink currently doesn't navigate properly with javascript urls - // EventHandler::handle_mouseup performs the navigation steps for javascript urls instead - if (href().starts_with_bytes("javascript:"sv)) - return; - // 2. Let hyperlinkSuffix be null. Optional hyperlink_suffix {};