summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/input-pattern.html
blob: a41bc4ad1cdd936b46d8d803aacf09d2c463a29f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Test the behavior of pattern attribute and pattern DOM property.');

var input = document.createElement('input');
input.type = 'text';

// No pattern attribute.
shouldBe('input.pattern', '""');

// Set a string value.
input.pattern = 'foo';
shouldBe('input.getAttribute("pattern")', '"foo"');
input.setAttribute('pattern', 'bar');
shouldBe('input.pattern', '"bar"');

// Null.
input.pattern = null;
shouldBe('input.pattern', '"null"');
shouldBe('input.getAttribute("pattern")', '"null"');
input.setAttribute('pattern', null);
shouldBe('input.pattern', '"null"');

// Undefined.
input.pattern = undefined;
shouldBe('input.pattern', '"undefined"');
shouldBe('input.getAttribute("pattern")', '"undefined"');
input.setAttribute('pattern', undefined);
shouldBe('input.pattern', '"undefined"');

// Non-string.
input.pattern = 256;
shouldBe('input.pattern', '"256"');
shouldBe('input.getAttribute("pattern")', '"256"');
input.setAttribute('pattern', 256);
shouldBe('input.pattern', '"256"');
</script>
</body>
</html>