Skip to content

Commit

Permalink
Move :dir()/:lang() pseudo-class tests to WPT
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=250602
rdar://104245215

Reviewed by Simon Fraser.

They're useful tests, and it would be nice to have for Interop 2023.

- Renamed the tests to match naming in respective folders
- Use the common ref-filled-green-100px-square.xht upstream file in <link rel="match"> to avoid duplication
- Used testharness.js for some :lang() tests.
- Also moved 2 :lang() tests that were in css/css-pseudo into css/selectors

* LayoutTests/fast/css/dir-pseudo-container-query-expected.html: Removed.
* LayoutTests/fast/css/dir-pseudo-container-query-invalidation-expected.html: Removed.
* LayoutTests/fast/css/lang-pseudo-container-query-document-element-invalidation-expected.html: Removed.
* LayoutTests/fast/css/lang-pseudo-container-query-invalidation-expected.html: Removed.
* LayoutTests/fast/css/lang-pseudo-container-query-invalidation-xhtml-expected.html: Removed.
* LayoutTests/fast/css/lang-pseudo-container-query-multiple-document-elements-invalidation-expected.html: Removed.
* LayoutTests/fast/css/lang-pseudo-disconnected-expected.txt: Removed.
* LayoutTests/fast/css/lang-pseudo-disconnected.html: Removed.
* LayoutTests/fast/css/lang-selector-empty-attribute-expected.txt: Removed.
* LayoutTests/fast/css/lang-selector-empty-attribute.xhtml: Removed.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/dir-pseudo-in-has-expected.xht: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/dir-pseudo-in-has.html: Renamed from LayoutTests/fast/css/dir-pseudo-container-query.html.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/i18n/lang-pseudo-class-across-shadow-boundaries-expected.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/lang-pseudo-class-across-shadow-boundaries-expected.html.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/i18n/lang-pseudo-class-across-shadow-boundaries-ref.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/lang-pseudo-class-across-shadow-boundaries-ref.html.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/i18n/lang-pseudo-class-across-shadow-boundaries.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/lang-pseudo-class-across-shadow-boundaries.html.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/i18n/lang-pseudo-class-disconnected-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/i18n/lang-pseudo-class-disconnected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/i18n/lang-pseudo-class-empty-attribute-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/i18n/lang-pseudo-class-empty-attribute.xhtml: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/dir-pseudo-class-in-has-expected.xht: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/dir-pseudo-class-in-has.html: Renamed from LayoutTests/fast/css/dir-pseudo-container-query-invalidation.html.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/lang-pseudo-class-in-has-document-element-expected.xht: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/lang-pseudo-class-in-has-document-element.html: Renamed from LayoutTests/fast/css/lang-pseudo-container-query-document-element-invalidation.html.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/lang-pseudo-class-in-has-expected.xht: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/lang-pseudo-class-in-has-multiple-document-elements-expected.xht: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/lang-pseudo-class-in-has-multiple-document-elements.html: Renamed from LayoutTests/fast/css/lang-pseudo-container-query-multiple-document-elements-invalidation.html.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/lang-pseudo-class-in-has-xhtml-expected.xht: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/lang-pseudo-class-in-has-xhtml.xhtml: Renamed from LayoutTests/fast/css/lang-pseudo-container-query-invalidation-xhtml.xhtml.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/lang-pseudo-class-in-has.html: Renamed from LayoutTests/fast/css/lang-pseudo-container-query-invalidation.html.

Canonical link: https://commits.webkit.org/258903@main
  • Loading branch information
nt1m committed Jan 14, 2023
1 parent 024c5b0 commit e70da52
Show file tree
Hide file tree
Showing 29 changed files with 217 additions and 121 deletions.
6 changes: 0 additions & 6 deletions LayoutTests/fast/css/dir-pseudo-container-query-expected.html

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions LayoutTests/fast/css/lang-pseudo-disconnected-expected.txt

This file was deleted.

20 changes: 0 additions & 20 deletions LayoutTests/fast/css/lang-pseudo-disconnected.html

This file was deleted.

This file was deleted.

44 changes: 0 additions & 44 deletions LayoutTests/fast/css/lang-selector-empty-attribute.xhtml

This file was deleted.

@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Reftest Reference</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
<style type="text/css"><![CDATA[
div
{
background-color: green;
height: 100px;
width: 100px;
}
]]></style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div></div>
</body>
</html>
@@ -1,6 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<link rel="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"/>
<link rel="help" href="https://drafts.csswg.org/selectors/#relational"/>
<link rel="help" href="https://drafts.csswg.org/selectors/#dir-pseudo"/>
<link rel="match" href="../reference/ref-filled-green-100px-square.xht"/>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<section><div class="ltr"><span></span></div></section>
<section><div dir="ltr" class="ltr"><span></span></div></section>
<section dir="ltr"><div class="ltr"><span></span></div></section>
Expand Down
@@ -0,0 +1,3 @@

PASS :lang pseudo class should work in a disconnected subtree

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<link rel="help" href="https://drafts.csswg.org/selectors/#lang-pseudo"/>
<body>
<div id="container" lang="zh"><span></span></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
let target = container.querySelector('span');
assert_true(target.matches(":lang(zh)"));
target.parentNode.remove();
assert_true(target.matches(":lang(zh)"));

const anotherContainer = document.createElement('div');
anotherContainer.innerHTML = '<div lang="fr"><span></span></div>';
target = anotherContainer.querySelector('span');
assert_true(target.matches(":lang(fr)"));
document.body.append(target.parentNode);
assert_true(target.matches(":lang(fr)"));
}, ":lang pseudo class should work in a disconnected subtree");
</script>
</body>
</html>
@@ -0,0 +1,5 @@
Tests if empty language declarations are supported


PASS Test if empty language attributes are supported

@@ -0,0 +1,26 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="help" href="https://drafts.csswg.org/selectors/#lang-pseudo"/>
<style type="text/css">
span {background: white;display:none}
span:lang(de) {background: red}
</style>
</head>
<body>
<p>Tests if empty language declarations are supported</p>
<p xml:lang="de">
<span lang="" id="emptyLang"/>
<span xml:lang="" id="emptyXmlLang"/>
<span id="noLang"/>
</p>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_equals(getComputedStyle(document.getElementById("emptyLang")).backgroundColor, "rgb(255, 255, 255)");
assert_equals(getComputedStyle(document.getElementById("emptyXmlLang")).backgroundColor, "rgb(255, 255, 255)");
assert_equals(getComputedStyle(document.getElementById("noLang")).backgroundColor, "rgb(255, 0, 0)");
}, "Test if empty language attributes are supported");
</script>
</body>
</html>
@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Reftest Reference</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
<style type="text/css"><![CDATA[
div
{
background-color: green;
height: 100px;
width: 100px;
}
]]></style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div></div>
</body>
</html>
@@ -1,6 +1,13 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<link rel="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"/>
<link rel="help" href="https://drafts.csswg.org/selectors/#relational"/>
<link rel="help" href="https://drafts.csswg.org/selectors/#dir-pseudo"/>
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"/>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<section><div id="ltr1" class="ltr"></div></section>
<section id="ltr2" dir="rtl"><div class="ltr"><span></span></div></section>
<section dir="ltr"><div class="ltr"><span></span></div></section>
Expand Down
@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Reftest Reference</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
<style type="text/css"><![CDATA[
div
{
background-color: green;
height: 100px;
width: 100px;
}
]]></style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div></div>
</body>
</html>
@@ -1,9 +1,14 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<meta http-equiv="content-language" content="fr">
<link rel="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"/>
<link rel="help" href="https://drafts.csswg.org/selectors/#relational">
<link rel="help" href="https://drafts.csswg.org/selectors/#lang-pseudo">
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
<meta http-equiv="content-language" content="fr">
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div><span></span></div>
<style>
div { width: 100px; height: 100px; }
Expand Down
@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Reftest Reference</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
<style type="text/css"><![CDATA[
div
{
background-color: green;
height: 100px;
width: 100px;
}
]]></style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div></div>
</body>
</html>
@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Reftest Reference</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
<style type="text/css"><![CDATA[
div
{
background-color: green;
height: 100px;
width: 100px;
}
]]></style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div></div>
</body>
</html>
@@ -1,7 +1,13 @@
<!DOCTYPE html>
<html lang="fr" class="reftest-wait">
<link rel="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"/>
<link rel="help" href="https://drafts.csswg.org/selectors/#relational">
<link rel="help" href="https://drafts.csswg.org/selectors/#lang-pseudo">
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div><span></span></div>
<script>

const test = document.querySelector('div').matches('*:has(:lang(fr))') ? 'PASS' : 'FAIL';

const newDocumentElement = document.createElement('html');
Expand All @@ -18,8 +24,9 @@
</style>
</head>
<body>
<div><span class="${test}">${test}</span></div>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div><span class="${test.toLowerCase()}">${test}</span></div>
</body>`;

</script>
</body>
</html>
@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Reftest Reference</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />
<style type="text/css"><![CDATA[
div
{
background-color: green;
height: 100px;
width: 100px;
}
]]></style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div></div>
</body>
</html>

0 comments on commit e70da52

Please sign in to comment.