Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add <input pattern> tests for RegExp u flag #38281

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions html/semantics/forms/the-input-element/pattern_attribute.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>pattern attribute</title>
<meta name=viewport content="width=device-width">
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
<link rel="author" title="Mathias Bynens" href="https://mathiasbynens.be/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-input-pattern">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h1><code>pattern</code> attribute</h1>
<div style="display: none">
<input pattern="[a-z]{3}" value="abcd" title="three letters max">
<input pattern="[a-z]{3}" value="abcd" id="basic">
<input pattern="a.b" value="a&#x1D306;b" id="unicode-code-points">
<input pattern="\p{ASCII_Hex_Digit}+" value="c0ff33" id="unicode-property-escape">
</div>
<div id="log"></div>
<script>
test(function() {
const input = document.querySelector("input");
test(() => {
const input = document.querySelector("#basic");

assert_idl_attribute(input, "pattern");
assert_equals(input.pattern, "[a-z]{3}");
Expand All @@ -22,5 +26,17 @@ <h1><code>pattern</code> attribute</h1>
assert_false(input.validity.valid);

assert_true(input.matches(":invalid"));
}, "pattern attribute support on input element");
}, "basic <input pattern> support");

test(() => {
const input = document.querySelector("#unicode-code-points");
assert_true(input.validity.valid);
assert_true(input.matches(":valid"));
}, "<input pattern> is Unicode code point-aware");

test(() => {
const input = document.querySelector("#unicode-property-escape");
assert_true(input.validity.valid);
assert_true(input.matches(":valid"));
}, "<input pattern> supports Unicode property escape syntax");
</script>