Tests: Create a test for :dir() parsing/serialization

Submitted to WPT as https://github.com/web-platform-tests/wpt/pull/52598
but in the meantime here's a local version.

The spec for this isn't super thorough, so the tests are based on how
Chrome and Firefox behave. Specifically, Firefox returns the ltr/rtl
keyword in lowercase but Chrome keeps the original case for it.

We currently fail most of these but that will be fixed in subsequent
commits.
This commit is contained in:
Sam Atkins 2025-05-16 14:21:28 +01:00 committed by Andreas Kling
commit 5f144f366d
Notes: github-actions[bot] 2025-05-16 22:32:06 +00:00
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="../wpt-import/resources/testharness.js"></script>
<script src="../wpt-import/resources/testharnessreport.js"></script>
<script src="../wpt-import/css/support/parsing-testcommon.js"></script>
<script>
test_valid_selector(':dir(rtl)');
test_valid_selector(':dir( rtl )', ':dir(rtl)');
test_valid_selector(':dir(ltr):dir(rtl)');
// Firefox converts this to lowercase but Chrome keeps the original casing. Interop issue?
test_valid_selector('foo:dir(RTL)', ['foo:dir(rtl)', 'foo:dir(RTL)']);
// Values other than ltr and rtl are not invalid, but do not match anything.
test_valid_selector(':dir(auto)');
test_valid_selector(':dir(none)');
test_valid_selector(':dir(something-made-up)');
test_invalid_selector(':dir()');
test_invalid_selector(':dir("ltr")');
test_invalid_selector(':dir(ltr, rtl)');
</script>