Files
sousa-gecko/testing/web-platform/tests/css/selectors/old-tests/css3-modsel-29.xml
T
Kent Tamura 3f32057f84 Bug 2049834 [wpt PR 60821] - css/selectors: Automate a part of legacy selectors tests (20 to 39), a=testonly
Automatic update from web-platform-tests
css/selectors: Automate a part of legacy selectors tests (20 to 39)

Introduce common.js to provide assert_background_color(),
assert_not_background_color(), LIME, and RED.

Change-Id: Ibfc1a0fecfc25a9fc60280edbacb5b21d9d2feda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7960878
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Auto-Submit: Kent Tamura <tkent@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1650778}

--

wpt-commits: 49ff34625b3fa0f882a3ec88b276a5bcd6f1e23a
wpt-pr: 60821
2026-06-25 17:03:34 +00:00

110 lines
3.1 KiB
XML

<!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>:nth-last-child() pseudo-class</title>
<style type="text/css"><![CDATA[.red { background-color : red }
ul > li:nth-last-child(odd) { background-color : green }
ol > li:nth-last-child(even) { background-color : green }
table.t1 tr:nth-last-child(-n+4) { background-color : green }
table.t2 td:nth-last-child(3n+1) { background-color : green }]]></style>
<link rel="author" title="Daniel Glazman" href="http://glazman.org/"/>
<link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch"/>
<link rel="help" href="https://www.w3.org/TR/css3-selectors/#selectors"/> <!-- bogus link to make sure it gets found -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
</head>
<body>
<ul>
<li>First list item</li>
<li class="red" id="t1">This second list item should have a green background</li>
<li>Third list item</li>
<li class="red" id="t2">This fourth list item should have a green background</li>
<li>Fifth list item</li>
<li class="red" id="t3">This sixth list item should have a green background</li>
</ul>
<ol>
<li class="red" id="t4">This first list item should have a green background</li>
<li>Second list item</li>
<li class="red" id="t5">This third list item should have a green background</li>
<li>Fourth list item</li>
<li class="red" id="t6">This fifth list item should have a green background</li>
<li>Sixth list item</li>
</ol>
<div>
<table border="1" class="t1">
<tr>
<td>1.1</td>
<td>1.2</td>
<td>1.3</td>
</tr>
<tr>
<td>2.1</td>
<td>2.2</td>
<td>2.3</td>
</tr>
<tr class="red" id="t7">
<td>Green row : 3.1</td>
<td>3.2</td>
<td>3.3</td>
</tr>
<tr class="red" id="t8">
<td>Green row : 4.1</td>
<td>4.2</td>
<td>4.3</td>
</tr>
<tr class="red" id="t9">
<td>Green row : 5.1</td>
<td>5.2</td>
<td>5.3</td>
</tr>
<tr class="red" id="t10">
<td>Green row : 6.1</td>
<td>6.2</td>
<td>6.3</td>
</tr>
</table>
<p></p>
<table class="t2" border="1">
<tr>
<td>1.1</td>
<td class="red" id="t11">green cell</td>
<td>1.3</td>
<td>1.4</td>
<td class="red" id="t12">green cell</td>
<td>1.6</td>
<td>1.7</td>
<td class="red" id="t13">green cell</td>
</tr>
<tr>
<td>2.1</td>
<td class="red" id="t14">green cell</td>
<td>2.3</td>
<td>2.4</td>
<td class="red" id="t15">green cell</td>
<td>2.6</td>
<td>2.7</td>
<td class="red" id="t16">green cell</td>
</tr>
<tr>
<td>3.1</td>
<td class="red" id="t17">green cell</td>
<td>3.3</td>
<td>3.4</td>
<td class="red" id="t18">green cell</td>
<td>3.6</td>
<td>3.7</td>
<td class="red" id="t19">green cell</td>
</tr>
</table>
</div>
<script><![CDATA[
test(function() {
for (let i = 1; i <= 19; ++i) {
assert_background_color(`t${i}`, 'rgb(0, 128, 0)', `Element t${i} should have green background`);
}
}, 'nth-last-child matching elements should have green background');
]]></script>
</body>
</html>