Title: [280479] trunk
Revision
280479
Author
[email protected]
Date
2021-07-30 09:41:37 -0700 (Fri, 30 Jul 2021)

Log Message

Clicking an HTMLLinkElement should not trigger a navigation
https://bugs.webkit.org/show_bug.cgi?id=228618

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaseline WPT test now that more checks are passing.

* web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub-expected.txt:

Source/WebCore:

Clicking an HTMLLinkElement should not trigger a navigation because HTMLLinkElement has no activation
behavior as per the HTML specification:
- https://html.spec.whatwg.org/multipage/semantics.html#htmllinkelement

Firefox and Chrome follow the specification here.

No new tests, updated/rebaselined existing tests.

* html/HTMLLinkElement.cpp:
* html/HTMLLinkElement.h:

LayoutTests:

Update existing tests to reflect behavior change. I verified that the tests were failing
in both Firefox and Chrome prior to me updating them.

* fast/dom/html-link-element-activation-behavior-on-element-click-expected.txt:
* fast/dom/html-link-element-activation-behavior-on-element-click.html:
* fast/dom/html-link-element-activation-behavior-on-mouse-click-expected.txt:
* fast/dom/html-link-element-activation-behavior-on-mouse-click.html:
* fast/dom/resources/html-link-element-activation-behavior-on-element-click-step1.html:
* fast/dom/resources/html-link-element-activation-behavior-on-mouse-click-step1.html:
* fast/dom/resources/html-link-element-activation-behavior-target.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280478 => 280479)


--- trunk/LayoutTests/ChangeLog	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/ChangeLog	2021-07-30 16:41:37 UTC (rev 280479)
@@ -1,3 +1,21 @@
+2021-07-30  Chris Dumez  <[email protected]>
+
+        Clicking an HTMLLinkElement should not trigger a navigation
+        https://bugs.webkit.org/show_bug.cgi?id=228618
+
+        Reviewed by Sam Weinig.
+
+        Update existing tests to reflect behavior change. I verified that the tests were failing
+        in both Firefox and Chrome prior to me updating them.
+
+        * fast/dom/html-link-element-activation-behavior-on-element-click-expected.txt:
+        * fast/dom/html-link-element-activation-behavior-on-element-click.html:
+        * fast/dom/html-link-element-activation-behavior-on-mouse-click-expected.txt:
+        * fast/dom/html-link-element-activation-behavior-on-mouse-click.html:
+        * fast/dom/resources/html-link-element-activation-behavior-on-element-click-step1.html:
+        * fast/dom/resources/html-link-element-activation-behavior-on-mouse-click-step1.html:
+        * fast/dom/resources/html-link-element-activation-behavior-target.html:
+
 2021-07-30  Dean Jackson  <[email protected]>
 
         [Media Controls] Add an option for having no scrubber on the time control and parameterize margin

Modified: trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-element-click-expected.txt (280478 => 280479)


--- trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-element-click-expected.txt	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-element-click-expected.txt	2021-07-30 16:41:37 UTC (rev 280479)
@@ -1,4 +1,4 @@
-This tests html link element activation behavior on DOM click
+This tests that html link element has no activation behavior on DOM click.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 

Modified: trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-element-click.html (280478 => 280479)


--- trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-element-click.html	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-element-click.html	2021-07-30 16:41:37 UTC (rev 280479)
@@ -7,7 +7,7 @@
 <div id="master"></div>
 <iframe id="frame" src=""
 <script>
-description("This tests html link element activation behavior on DOM click");
+description("This tests that html link element has no activation behavior on DOM click.");
 function start(){
     frame.postMessage("element:click", "*");
 }
@@ -22,4 +22,4 @@
 </script>
 <script src=""
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-mouse-click-expected.txt (280478 => 280479)


--- trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-mouse-click-expected.txt	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-mouse-click-expected.txt	2021-07-30 16:41:37 UTC (rev 280479)
@@ -1,4 +1,4 @@
-This tests html link element activation behavior on mouse click
+This tests that html link element has no activation behavior on mouse click
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 

Modified: trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-mouse-click.html (280478 => 280479)


--- trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-mouse-click.html	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-mouse-click.html	2021-07-30 16:41:37 UTC (rev 280479)
@@ -7,7 +7,7 @@
 <div id="master"></div>
 <iframe id="frame" src=""
 <script>
-description("This tests html link element activation behavior on mouse click");
+description("This tests that html link element has no activation behavior on mouse click");
 function start(){
     frame.postMessage("mouse:click", "*");
 }
@@ -22,4 +22,4 @@
 </script>
 <script src=""
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-on-element-click-step1.html (280478 => 280479)


--- trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-on-element-click-step1.html	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-on-element-click-step1.html	2021-07-30 16:41:37 UTC (rev 280479)
@@ -13,6 +13,9 @@
 <script>
 function elementClick(){
     document.getElementById("target").click();
+    setTimeout(() => {
+        window.parent.postMessage("test:ok", "*");
+    }, 100);
 }
 window.addEventListener("message", elementClick);
-</script>
\ No newline at end of file
+</script>

Modified: trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-on-mouse-click-step1.html (280478 => 280479)


--- trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-on-mouse-click-step1.html	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-on-mouse-click-step1.html	2021-07-30 16:41:37 UTC (rev 280479)
@@ -16,7 +16,10 @@
         eventSender.mouseMoveTo(50, 140);
         eventSender.mouseDown();
         eventSender.mouseUp();
-    }	
+    }
+    setTimeout(() => {
+        window.parent.postMessage("test:ok", "*");
+    }, 100);
 }
 window.addEventListener("message", mouseClick);
-</script>
\ No newline at end of file
+</script>

Modified: trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-target.html (280478 => 280479)


--- trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-target.html	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-target.html	2021-07-30 16:41:37 UTC (rev 280479)
@@ -1,10 +1,10 @@
 <head>
 <script>
-function ok(){
-    window.parent.postMessage("test:ok", "*");
+function fail(){
+    window.parent.postMessage("test:fail", "*");
 }
 </script>
 </head>
-<body _onload_="ok()">
+<body _onload_="fail()">
 <h1>target</h1>
-</body>
\ No newline at end of file
+</body>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (280478 => 280479)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-30 16:41:37 UTC (rev 280479)
@@ -1,5 +1,16 @@
 2021-07-30  Chris Dumez  <[email protected]>
 
+        Clicking an HTMLLinkElement should not trigger a navigation
+        https://bugs.webkit.org/show_bug.cgi?id=228618
+
+        Reviewed by Sam Weinig.
+
+        Rebaseline WPT test now that more checks are passing.
+
+        * web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub-expected.txt:
+
+2021-07-30  Chris Dumez  <[email protected]>
+
         postMessage() should throw if any duplicate transferable is found in transferList
         https://bugs.webkit.org/show_bug.cgi?id=228608
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub-expected.txt (280478 => 280479)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub-expected.txt	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub-expected.txt	2021-07-30 16:41:37 UTC (rev 280479)
@@ -1,7 +1,7 @@
 
 PASS follow hyperlink <a href>
 PASS follow hyperlink <area href>
-FAIL don't follow hyperlink <link href> assert_equals: The <a> navigation should occur instead of the <link> navigation. expected "/html/infrastructure/urls/resolving-urls/query-encoding/resources/blank.py" but got "/html/infrastructure/urls/resolving-urls/query-encoding/resources/resource.py"
+PASS don't follow hyperlink <link href>
 PASS hyperlink auditing <a ping>
 PASS hyperlink auditing <area ping>
 PASS meta refresh

Modified: trunk/Source/WebCore/ChangeLog (280478 => 280479)


--- trunk/Source/WebCore/ChangeLog	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/Source/WebCore/ChangeLog	2021-07-30 16:41:37 UTC (rev 280479)
@@ -1,3 +1,21 @@
+2021-07-30  Chris Dumez  <[email protected]>
+
+        Clicking an HTMLLinkElement should not trigger a navigation
+        https://bugs.webkit.org/show_bug.cgi?id=228618
+
+        Reviewed by Sam Weinig.
+
+        Clicking an HTMLLinkElement should not trigger a navigation because HTMLLinkElement has no activation
+        behavior as per the HTML specification:
+        - https://html.spec.whatwg.org/multipage/semantics.html#htmllinkelement
+
+        Firefox and Chrome follow the specification here.
+
+        No new tests, updated/rebaselined existing tests.
+
+        * html/HTMLLinkElement.cpp:
+        * html/HTMLLinkElement.h:
+
 2021-07-30  Dean Jackson  <[email protected]>
 
         [Media Controls] Add an option for having no scrubber on the time control and parameterize margin

Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (280478 => 280479)


--- trunk/Source/WebCore/html/HTMLLinkElement.cpp	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp	2021-07-30 16:41:37 UTC (rev 280479)
@@ -565,27 +565,6 @@
     return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribute(attribute);
 }
 
-void HTMLLinkElement::defaultEventHandler(Event& event)
-{
-    if (MouseEvent::canTriggerActivationBehavior(event)) {
-        handleClick(event);
-        return;
-    }
-    HTMLElement::defaultEventHandler(event);
-}
-
-void HTMLLinkElement::handleClick(Event& event)
-{
-    event.setDefaultHandled();
-    URL url = ""
-    if (url.isNull())
-        return;
-    RefPtr<Frame> frame = document().frame();
-    if (!frame)
-        return;
-    frame->loader().changeLocation(url, target(), &event, ReferrerPolicy::EmptyString, document().shouldOpenExternalURLsPolicyToPropagate());
-}
-
 URL HTMLLinkElement::href() const
 {
     return document().completeURL(attributeWithoutSynchronization(hrefAttr));

Modified: trunk/Source/WebCore/html/HTMLLinkElement.h (280478 => 280479)


--- trunk/Source/WebCore/html/HTMLLinkElement.h	2021-07-30 16:35:11 UTC (rev 280478)
+++ trunk/Source/WebCore/html/HTMLLinkElement.h	2021-07-30 16:41:37 UTC (rev 280479)
@@ -114,9 +114,6 @@
 
     bool isURLAttribute(const Attribute&) const final;
 
-    void defaultEventHandler(Event&) final;
-    void handleClick(Event&);
-
     HTMLLinkElement(const QualifiedName&, Document&, bool createdByParser);
 
     void addSubresourceAttributeURLs(ListHashSet<URL>&) const final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to