Changeset 280479 in webkit


Ignore:
Timestamp:
Jul 30, 2021 9:41:37 AM (12 months ago)
Author:
Chris Dumez
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:

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:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280477 r280479  
     12021-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Clicking an HTMLLinkElement should not trigger a navigation
     4        https://bugs.webkit.org/show_bug.cgi?id=228618
     5
     6        Reviewed by Sam Weinig.
     7
     8        Update existing tests to reflect behavior change. I verified that the tests were failing
     9        in both Firefox and Chrome prior to me updating them.
     10
     11        * fast/dom/html-link-element-activation-behavior-on-element-click-expected.txt:
     12        * fast/dom/html-link-element-activation-behavior-on-element-click.html:
     13        * fast/dom/html-link-element-activation-behavior-on-mouse-click-expected.txt:
     14        * fast/dom/html-link-element-activation-behavior-on-mouse-click.html:
     15        * fast/dom/resources/html-link-element-activation-behavior-on-element-click-step1.html:
     16        * fast/dom/resources/html-link-element-activation-behavior-on-mouse-click-step1.html:
     17        * fast/dom/resources/html-link-element-activation-behavior-target.html:
     18
    1192021-07-30  Dean Jackson  <dino@apple.com>
    220
  • trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-element-click-expected.txt

    r174637 r280479  
    1 This tests html link element activation behavior on DOM click
     1This tests that html link element has no activation behavior on DOM click.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-element-click.html

    r174637 r280479  
    88<iframe id="frame" src="resources/html-link-element-activation-behavior-on-element-click-step1.html"></iframe>
    99<script>
    10 description("This tests html link element activation behavior on DOM click");
     10description("This tests that html link element has no activation behavior on DOM click.");
    1111function start(){
    1212    frame.postMessage("element:click", "*");
  • trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-mouse-click-expected.txt

    r174637 r280479  
    1 This tests html link element activation behavior on mouse click
     1This tests that html link element has no activation behavior on mouse click
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/fast/dom/html-link-element-activation-behavior-on-mouse-click.html

    r174637 r280479  
    88<iframe id="frame" src="resources/html-link-element-activation-behavior-on-mouse-click-step1.html"></iframe>
    99<script>
    10 description("This tests html link element activation behavior on mouse click");
     10description("This tests that html link element has no activation behavior on mouse click");
    1111function start(){
    1212    frame.postMessage("mouse:click", "*");
  • trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-on-element-click-step1.html

    r174637 r280479  
    1414function elementClick(){
    1515    document.getElementById("target").click();
     16    setTimeout(() => {
     17        window.parent.postMessage("test:ok", "*");
     18    }, 100);
    1619}
    1720window.addEventListener("message", elementClick);
  • trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-on-mouse-click-step1.html

    r174637 r280479  
    1717        eventSender.mouseDown();
    1818        eventSender.mouseUp();
    19     }   
     19    }
     20    setTimeout(() => {
     21        window.parent.postMessage("test:ok", "*");
     22    }, 100);
    2023}
    2124window.addEventListener("message", mouseClick);
  • trunk/LayoutTests/fast/dom/resources/html-link-element-activation-behavior-target.html

    r174637 r280479  
    11<head>
    22<script>
    3 function ok(){
    4     window.parent.postMessage("test:ok", "*");
     3function fail(){
     4    window.parent.postMessage("test:fail", "*");
    55}
    66</script>
    77</head>
    8 <body onload="ok()">
     8<body onload="fail()">
    99<h1>target</h1>
    1010</body>
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r280476 r280479  
     12021-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Clicking an HTMLLinkElement should not trigger a navigation
     4        https://bugs.webkit.org/show_bug.cgi?id=228618
     5
     6        Reviewed by Sam Weinig.
     7
     8        Rebaseline WPT test now that more checks are passing.
     9
     10        * web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub-expected.txt:
     11
    1122021-07-30  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub-expected.txt

    r279427 r280479  
    22PASS follow hyperlink <a href>
    33PASS follow hyperlink <area href>
    4 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"
     4PASS don't follow hyperlink <link href>
    55PASS hyperlink auditing <a ping>
    66PASS hyperlink auditing <area ping>
  • trunk/Source/WebCore/ChangeLog

    r280477 r280479  
     12021-07-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Clicking an HTMLLinkElement should not trigger a navigation
     4        https://bugs.webkit.org/show_bug.cgi?id=228618
     5
     6        Reviewed by Sam Weinig.
     7
     8        Clicking an HTMLLinkElement should not trigger a navigation because HTMLLinkElement has no activation
     9        behavior as per the HTML specification:
     10        - https://html.spec.whatwg.org/multipage/semantics.html#htmllinkelement
     11
     12        Firefox and Chrome follow the specification here.
     13
     14        No new tests, updated/rebaselined existing tests.
     15
     16        * html/HTMLLinkElement.cpp:
     17        * html/HTMLLinkElement.h:
     18
    1192021-07-30  Dean Jackson  <dino@apple.com>
    220
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r279847 r280479  
    566566}
    567567
    568 void HTMLLinkElement::defaultEventHandler(Event& event)
    569 {
    570     if (MouseEvent::canTriggerActivationBehavior(event)) {
    571         handleClick(event);
    572         return;
    573     }
    574     HTMLElement::defaultEventHandler(event);
    575 }
    576 
    577 void HTMLLinkElement::handleClick(Event& event)
    578 {
    579     event.setDefaultHandled();
    580     URL url = href();
    581     if (url.isNull())
    582         return;
    583     RefPtr<Frame> frame = document().frame();
    584     if (!frame)
    585         return;
    586     frame->loader().changeLocation(url, target(), &event, ReferrerPolicy::EmptyString, document().shouldOpenExternalURLsPolicyToPropagate());
    587 }
    588 
    589568URL HTMLLinkElement::href() const
    590569{
  • trunk/Source/WebCore/html/HTMLLinkElement.h

    r279847 r280479  
    115115    bool isURLAttribute(const Attribute&) const final;
    116116
    117     void defaultEventHandler(Event&) final;
    118     void handleClick(Event&);
    119 
    120117    HTMLLinkElement(const QualifiedName&, Document&, bool createdByParser);
    121118
Note: See TracChangeset for help on using the changeset viewer.