blob: 646e6d8ddde904c6a38edf4f615115f149954609 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.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;
shouldBeEqualToString('input.pattern', 'null');
shouldBeEqualToString('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>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>