Changeset 279818 in webkit


Ignore:
Timestamp:
Jul 11, 2021 9:08:46 PM (12 months ago)
Author:
Chris Dumez
Message:

:link and :visited pseudo-class selectors should not match <link> elements
https://bugs.webkit.org/show_bug.cgi?id=227847

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

  • web-platform-tests/dom/nodes/ParentNode-querySelector-All-expected.txt:
  • web-platform-tests/dom/nodes/ParentNode-querySelector-All-xht-expected.txt:
  • web-platform-tests/html/semantics/selectors/pseudo-classes/link-expected.txt:

Source/WebCore:

:link, :visited and :any-link should only match <a> and <area> elements as per:

Blink and Gecko match the specification. However, WebKit was incorrectly matching
<link> elements too.

No new tests, rebaselined existing tests.

  • html/HTMLLinkElement.cpp:

(WebCore::HTMLLinkElement::parseAttribute):

LayoutTests:

Update / Rebaseline existing tests due to behavior change.

  • fast/css/link-basics-expected.html:
  • fast/css/link-basics.html:
  • fast/selectors/any-link-basics-expected.txt:
  • fast/selectors/link-basics-expected.txt:
  • fast/selectors/link-basics-xhtml-expected.txt:
  • fast/selectors/resources/html-link-type-tests.js:

(testHTMLTagsForLink):

  • fast/selectors/webkit-any-link-basics-expected.txt:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r279816 r279818  
     12021-07-11  Chris Dumez  <cdumez@apple.com>
     2
     3        :link and :visited pseudo-class selectors should not match <link> elements
     4        https://bugs.webkit.org/show_bug.cgi?id=227847
     5
     6        Reviewed by Sam Weinig.
     7
     8        Update / Rebaseline existing tests due to behavior change.
     9
     10        * fast/css/link-basics-expected.html:
     11        * fast/css/link-basics.html:
     12        * fast/selectors/any-link-basics-expected.txt:
     13        * fast/selectors/link-basics-expected.txt:
     14        * fast/selectors/link-basics-xhtml-expected.txt:
     15        * fast/selectors/resources/html-link-type-tests.js:
     16        (testHTMLTagsForLink):
     17        * fast/selectors/webkit-any-link-basics-expected.txt:
     18
    1192021-07-11  Fujii Hironori  <Hironori.Fujii@sony.com>
    220
  • trunk/LayoutTests/fast/css/link-basics-expected.html

    r174878 r279818  
    1818    <p>Test styling with the :link selector. Any type the text is <em>GREEN</em>, its color should be green.</p>
    1919    <p><a>WebKit</a> <a style="color:lime" href=" ">GREEN</a> <a style="color:lime" href="http://www.webkit.org/notvisited.html">GREEN</a></p>
    20     <p><link class="webkit"> <link class="green" style="color:lime" href=" "> <link class="green" style="color:lime" href="http://www.webkit.org/notvisited.html"></p>
    2120    <p><area class="webkit"> <area class="green" style="color:lime" href=" "> <area class="green" style="color:lime" href="http://www.webkit.org/notvisited.html"></p>
    2221</body>
  • trunk/LayoutTests/fast/css/link-basics.html

    r174878 r279818  
    2121    <p>Test styling with the :link selector. Any type the text is <em>GREEN</em>, its color should be green.</p>
    2222    <p><a>WebKit</a> <a href=" ">GREEN</a> <a href="http://www.webkit.org/notvisited.html">GREEN</a></p>
    23     <p><link> <link href=" "> <link href="http://www.webkit.org/notvisited.html"></p>
    2423    <p><area> <area href=" "> <area href="http://www.webkit.org/notvisited.html"></p>
    2524</body>
  • trunk/LayoutTests/fast/selectors/any-link-basics-expected.txt

    r175301 r279818  
    11601160PASS document.querySelectorAll("#target:any-link").length is 0
    11611161PASS document.querySelectorAll(".target:any-link").length is 0
    1162 PASS document.getElementById("target").matches(":any-link") is true
    1163 PASS document.querySelectorAll("#target:any-link").length is 1
    1164 PASS document.querySelectorAll(".target:any-link").length is 1
    1165 PASS document.getElementById("target").matches(":any-link") is true
    1166 PASS document.querySelectorAll("#target:any-link").length is 1
    1167 PASS document.querySelectorAll(".target:any-link").length is 1
     1162PASS document.getElementById("target").matches(":any-link") is false
     1163PASS document.querySelectorAll("#target:any-link").length is 0
     1164PASS document.querySelectorAll(".target:any-link").length is 0
     1165PASS document.getElementById("target").matches(":any-link") is false
     1166PASS document.querySelectorAll("#target:any-link").length is 0
     1167PASS document.querySelectorAll(".target:any-link").length is 0
    11681168PASS document.getElementById("target").matches(":any-link") is false
    11691169PASS document.querySelectorAll("#target:any-link").length is 0
  • trunk/LayoutTests/fast/selectors/link-basics-expected.txt

    r175301 r279818  
    11601160PASS document.querySelectorAll("#target:link").length is 0
    11611161PASS document.querySelectorAll(".target:link").length is 0
    1162 PASS document.getElementById("target").matches(":link") is true
    1163 PASS document.querySelectorAll("#target:link").length is 1
    1164 PASS document.querySelectorAll(".target:link").length is 1
    1165 PASS document.getElementById("target").matches(":link") is true
    1166 PASS document.querySelectorAll("#target:link").length is 1
    1167 PASS document.querySelectorAll(".target:link").length is 1
     1162PASS document.getElementById("target").matches(":link") is false
     1163PASS document.querySelectorAll("#target:link").length is 0
     1164PASS document.querySelectorAll(".target:link").length is 0
     1165PASS document.getElementById("target").matches(":link") is false
     1166PASS document.querySelectorAll("#target:link").length is 0
     1167PASS document.querySelectorAll(".target:link").length is 0
    11681168PASS document.getElementById("target").matches(":link") is false
    11691169PASS document.querySelectorAll("#target:link").length is 0
  • trunk/LayoutTests/fast/selectors/link-basics-xhtml-expected.txt

    r175301 r279818  
    11601160PASS document.querySelectorAll("#target:link").length is 0
    11611161PASS document.querySelectorAll(".target:link").length is 0
    1162 PASS document.getElementById("target").matches(":link") is true
    1163 PASS document.querySelectorAll("#target:link").length is 1
    1164 PASS document.querySelectorAll(".target:link").length is 1
    1165 PASS document.getElementById("target").matches(":link") is true
    1166 PASS document.querySelectorAll("#target:link").length is 1
    1167 PASS document.querySelectorAll(".target:link").length is 1
     1162PASS document.getElementById("target").matches(":link") is false
     1163PASS document.querySelectorAll("#target:link").length is 0
     1164PASS document.querySelectorAll(".target:link").length is 0
     1165PASS document.getElementById("target").matches(":link") is false
     1166PASS document.querySelectorAll("#target:link").length is 0
     1167PASS document.querySelectorAll(".target:link").length is 0
    11681168PASS document.getElementById("target").matches(":link") is false
    11691169PASS document.querySelectorAll("#target:link").length is 0
  • trunk/LayoutTests/fast/selectors/resources/html-link-type-tests.js

    r175301 r279818  
    4141    for (var i = 0; i < htmlTags.length; ++i) {
    4242        var tag = htmlTags[i];
    43         var shouldMatch = tag === 'a' || tag === 'area' || tag === 'link';
     43        var shouldMatch = tag === 'a' || tag === 'area';
    4444        testHTMLElement(tag, selector, shouldMatch);
    4545    }
  • trunk/LayoutTests/fast/selectors/webkit-any-link-basics-expected.txt

    r175301 r279818  
    11601160PASS document.querySelectorAll("#target:-webkit-any-link").length is 0
    11611161PASS document.querySelectorAll(".target:-webkit-any-link").length is 0
    1162 PASS document.getElementById("target").matches(":-webkit-any-link") is true
    1163 PASS document.querySelectorAll("#target:-webkit-any-link").length is 1
    1164 PASS document.querySelectorAll(".target:-webkit-any-link").length is 1
    1165 PASS document.getElementById("target").matches(":-webkit-any-link") is true
    1166 PASS document.querySelectorAll("#target:-webkit-any-link").length is 1
    1167 PASS document.querySelectorAll(".target:-webkit-any-link").length is 1
     1162PASS document.getElementById("target").matches(":-webkit-any-link") is false
     1163PASS document.querySelectorAll("#target:-webkit-any-link").length is 0
     1164PASS document.querySelectorAll(".target:-webkit-any-link").length is 0
     1165PASS document.getElementById("target").matches(":-webkit-any-link") is false
     1166PASS document.querySelectorAll("#target:-webkit-any-link").length is 0
     1167PASS document.querySelectorAll(".target:-webkit-any-link").length is 0
    11681168PASS document.getElementById("target").matches(":-webkit-any-link") is false
    11691169PASS document.querySelectorAll("#target:-webkit-any-link").length is 0
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r279815 r279818  
     12021-07-11  Chris Dumez  <cdumez@apple.com>
     2
     3        :link and :visited pseudo-class selectors should not match <link> elements
     4        https://bugs.webkit.org/show_bug.cgi?id=227847
     5
     6        Reviewed by Sam Weinig.
     7
     8        Rebaseline WPT tests now that more checks are passing.
     9
     10        * web-platform-tests/dom/nodes/ParentNode-querySelector-All-expected.txt:
     11        * web-platform-tests/dom/nodes/ParentNode-querySelector-All-xht-expected.txt:
     12        * web-platform-tests/html/semantics/selectors/pseudo-classes/link-expected.txt:
     13
    1142021-07-11  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/ParentNode-querySelector-All-expected.txt

    r274167 r279818  
    596596PASS Document.querySelectorAll: :link and :visited pseudo-class selectors, matching a and area elements with href attributes: #pseudo-link :link, #pseudo-link :visited
    597597PASS Document.querySelector: :link and :visited pseudo-class selectors, matching a and area elements with href attributes: #pseudo-link :link, #pseudo-link :visited
    598 FAIL Document.querySelectorAll: :link and :visited pseudo-class selectors, matching no elements: #head :link, #head :visited assert_equals: The method should return the expected number of matches. expected 0 but got 2
    599 FAIL Document.querySelector: :link and :visited pseudo-class selectors, matching no elements: #head :link, #head :visited assert_equals: The method should not match anything. expected null but got Element node <link id="pseudo-link-link1" href=""></link>
     598PASS Document.querySelectorAll: :link and :visited pseudo-class selectors, matching no elements: #head :link, #head :visited
     599PASS Document.querySelector: :link and :visited pseudo-class selectors, matching no elements: #head :link, #head :visited
    600600PASS Document.querySelectorAll: :target pseudo-class selector, matching the element referenced by the URL fragment identifier: :target
    601601PASS Document.querySelector: :target pseudo-class selector, matching the element referenced by the URL fragment identifier: :target
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/ParentNode-querySelector-All-xht-expected.txt

    r274167 r279818  
    596596PASS Document.querySelectorAll: :link and :visited pseudo-class selectors, matching a and area elements with href attributes: #pseudo-link :link, #pseudo-link :visited
    597597PASS Document.querySelector: :link and :visited pseudo-class selectors, matching a and area elements with href attributes: #pseudo-link :link, #pseudo-link :visited
    598 FAIL Document.querySelectorAll: :link and :visited pseudo-class selectors, matching no elements: #head :link, #head :visited assert_equals: The method should return the expected number of matches. expected 0 but got 2
    599 FAIL Document.querySelector: :link and :visited pseudo-class selectors, matching no elements: #head :link, #head :visited assert_equals: The method should not match anything. expected null but got Element node <link id="pseudo-link-link1" href=""></link>
     598PASS Document.querySelectorAll: :link and :visited pseudo-class selectors, matching no elements: #head :link, #head :visited
     599PASS Document.querySelector: :link and :visited pseudo-class selectors, matching no elements: #head :link, #head :visited
    600600PASS Document.querySelectorAll: :target pseudo-class selector, matching the element referenced by the URL fragment identifier: :target
    601601PASS Document.querySelector: :target pseudo-class selector, matching the element referenced by the URL fragment identifier: :target
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/link-expected.txt

    r279223 r279818  
    11
    2 FAIL Only <a>s and <area>s that have a href attribute match ':link' assert_array_equals: lengths differ, expected array [Element node <a href="http://www.w3.org" id="link7"></a>, Element node <area href="http://www.w3.org" id="link8"></area>, Element node <a href="http://[" id="link10"></a>] length 3, got [Element node <link rel="author" title="Denis Ah-Kang" href="mailto:den..., Element node <link rel="help" href="https://html.spec.whatwg.org/multi..., Element node <link rel="stylesheet" href="non-existent.css" id="link3"..., Element node <a href="http://www.w3.org" id="link7"></a>, Element node <area href="http://www.w3.org" id="link8"></area>, Element node <link href="http://www.w3.org" id="link9"></link>, Element node <a href="http://[" id="link10"></a>] length 7
     2PASS Only <a>s and <area>s that have a href attribute match ':link'
    33
  • trunk/Source/WebCore/ChangeLog

    r279815 r279818  
     12021-07-11  Chris Dumez  <cdumez@apple.com>
     2
     3        :link and :visited pseudo-class selectors should not match <link> elements
     4        https://bugs.webkit.org/show_bug.cgi?id=227847
     5
     6        Reviewed by Sam Weinig.
     7
     8        :link, :visited and :any-link should only match <a> and <area> elements as per:
     9        - https://drafts.csswg.org/selectors/#the-any-link-pseudo
     10
     11        Blink and Gecko match the specification. However, WebKit was incorrectly matching
     12        <link> elements too.
     13
     14        No new tests, rebaselined existing tests.
     15
     16        * html/HTMLLinkElement.cpp:
     17        (WebCore::HTMLLinkElement::parseAttribute):
     18
    1192021-07-11  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r279383 r279818  
    172172    }
    173173    if (name == hrefAttr) {
    174         bool wasLink = isLink();
    175         setIsLink(!value.isNull() && !shouldProhibitLinks(this));
    176         if (wasLink != isLink())
    177             invalidateStyleForSubtree();
    178174        process();
    179175        return;
Note: See TracChangeset for help on using the changeset viewer.