From 7fb79576dbe83e74f5e375ed887e3338b501de2a Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 19 Jan 2021 14:16:40 -0800 Subject: [PATCH] Update pseudo selector WPTs In these spec PRs [1][2], the element will no longer match :link, :visited, or :any-link, and it will no longer navigate the page when clicked. This patch also modifies the TestExpectations for one of the modified tests navigation.sub.html. There was one test case which was consistently timing out which I removed, which would stop the test from timing out. However, there are an additional two test cases which time out when run with run_web_tests.py but pass just fine with run_wpt_tests.py. In addition, the flags passed to run_web_tests.py on the trybots make it so that those two test cases which time out get written to a failure file instead of making the whole test runner time out, which would count as a failure in TestExpectations. Since the default flags for run_web_tests.py make it an actual timeout according to TestExpectations, I left the timeout expectation in there as well. Hopefully this test can just be run with run_wpt_tests.py in the future and we can get rid of this TestExpectation. [1] https://github.com/whatwg/html/pull/6269 [2] https://github.com/w3c/csswg-drafts/pull/5839 Bug: 611093 Change-Id: I7234eb6024450e28c1ca6ec1ede7fdfc8f2ece52 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628037 Reviewed-by: Domenic Denicola Reviewed-by: Mason Freed Commit-Queue: Joey Arhar Cr-Commit-Position: refs/heads/master@{#844921} --- dom/nodes/selectors.js | 4 +-- .../query-encoding/navigation.sub.html | 34 ++++++++++++++++++- .../selectors/pseudo-classes/link.html | 5 +-- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/dom/nodes/selectors.js b/dom/nodes/selectors.js index c1680cedd708d3..decc983e931925 100644 --- a/dom/nodes/selectors.js +++ b/dom/nodes/selectors.js @@ -219,7 +219,7 @@ var validSelectors = [ // Implementations may treat all visited links as unvisited, so these cannot be tested separately. // The only guarantee is that ":link,:visited" matches the set of all visited and unvisited links and that they are individually mutually exclusive sets. {name: ":link and :visited pseudo-class selectors, matching a and area elements with href attributes", selector: "#pseudo-link :link, #pseudo-link :visited", expect: ["pseudo-link-a1", "pseudo-link-a2", "pseudo-link-area1"], level: 1, testType: TEST_QSA | TEST_MATCH}, - {name: ":link and :visited pseudo-class selectors, matching link elements with href attributes", selector: "#head :link, #head :visited", expect: ["pseudo-link-link1", "pseudo-link-link2"], exclude: ["element", "fragment", "detached"], level: 1, testType: TEST_QSA | TEST_MATCH}, + {name: ":link and :visited pseudo-class selectors, matching no elements", selector: "#head :link, #head :visited", expect: [] /*no matches*/, exclude: ["element", "fragment", "detached"], level: 1, testType: TEST_QSA | TEST_MATCH}, {name: ":link and :visited pseudo-class selectors, not matching link elements with href attributes", selector: "#head :link, #head :visited", expect: [] /*no matches*/, exclude: ["document"], level: 1, testType: TEST_QSA}, {name: ":link and :visited pseudo-class selectors, chained, mutually exclusive pseudo-classes match nothing", selector: ":link:visited", expect: [] /*no matches*/, exclude: ["document"], level: 1, testType: TEST_QSA}, @@ -600,7 +600,7 @@ var scopedSelectors = [ // Implementations may treat all visited links as unvisited, so these cannot be tested separately. // The only guarantee is that ":link,:visited" matches the set of all visited and unvisited links and that they are individually mutually exclusive sets. {name: ":link and :visited pseudo-class selectors, matching a and area elements with href attributes", selector: " :link, #pseudo-link :visited", ctx: "#pseudo-link", expect: ["pseudo-link-a1", "pseudo-link-a2", "pseudo-link-area1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: ":link and :visited pseudo-class selectors, matching link elements with href attributes", selector: " :link, #head :visited", ctx: "#head", expect: ["pseudo-link-link1", "pseudo-link-link2"], exclude: ["element", "fragment", "detached"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: ":link and :visited pseudo-class selectors, matching no elements", selector: " :link, #head :visited", ctx: "#head", expect: [] /*no matches*/, exclude: ["element", "fragment", "detached"], level: 1, testType: TEST_FIND | TEST_MATCH}, {name: ":link and :visited pseudo-class selectors, not matching link elements with href attributes", selector: " :link, #head :visited", ctx: "#head", expect: [] /*no matches*/, exclude: ["document"], level: 1, testType: TEST_FIND}, {name: ":link and :visited pseudo-class selectors, chained, mutually exclusive pseudo-classes match nothing", selector: ":link:visited", ctx: "#html", expect: [] /*no matches*/, exclude: ["document"], level: 1, testType: TEST_FIND}, diff --git a/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub.html b/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub.html index bca61372b4c8b1..7808434f05a49b 100644 --- a/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub.html +++ b/html/infrastructure/urls/resolving-urls/query-encoding/navigation.sub.html @@ -81,10 +81,42 @@ }, 'follow hyperlink <'+tag+' href>'); } -'a, area, link'.split(', ').forEach(function(str) { +'a, area'.split(', ').forEach(function(str) { test_follow_link(str); }); +async_test(function() { + const iframe = document.createElement('iframe'); + iframe.name = 'test_dont_follow_link'; + document.body.appendChild(iframe); + + const link = document.createElement('link'); + link.target = iframe.name; + link.setAttribute('href', input_url_html); + document.body.appendChild(link); + + const anchor = document.createElement('a'); + anchor.target = iframe.name; + anchor.setAttribute('href', blank); + document.body.appendChild(anchor); + + this.add_cleanup(function() { + iframe.remove(); + link.remove(); + anchor.remove(); + }); + + iframe.onload = this.step_func_done(() => { + assert_equals( + iframe.contentDocument.location.pathname, + '/html/infrastructure/urls/resolving-urls/query-encoding/resources/blank.py', + 'The navigation should occur instead of the navigation.'); + }); + + anchor.click(); + link.click(); +}, `don't follow hyperlink `); + // follow hyperlink with ping attribute function test_follow_link_ping(tag) { async_test(function() { diff --git a/html/semantics/selectors/pseudo-classes/link.html b/html/semantics/selectors/pseudo-classes/link.html index 05067dd2ecf39f..e9733eca70afd2 100644 --- a/html/semantics/selectors/pseudo-classes/link.html +++ b/html/semantics/selectors/pseudo-classes/link.html @@ -17,8 +17,5 @@