summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/input-value-sanitization.html
blob: 9d949bd095051a7bd7e54ba0b68b63fafc38d136 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p>Tests for value sanitization algorithm.</p>
<div id="console"></div>
<script>
var input;

debug('');
debug('Email with multiple:');
input = document.createElement('input');
input.multiple = true;
input.type = 'email';
input.setAttribute('value', ' tkent@chromium.org, tkent@example.!!!  ');
shouldBe('input.value', '"tkent@chromium.org,tkent@example.!!!"');
debug('Email without multiple:');
input = document.createElement('input');
input.multiple = false;
input.type = 'email';
input.setAttribute('value', ' tkent@chromium.org, tkent@example.***  \r\n');
shouldBe('input.value', '"tkent@chromium.org, tkent@example.***"');

debug('');
debug('Number:');
input = document.createElement('input');
input.setAttribute('value', '65536');
input.type = 'number';
shouldBe('input.value', '"65536"');
shouldBe('input.value = "256"; input.value', '"256"');
shouldBe('input.value = ""; input.value', '""');


debug('');
debug('Range:');
input = document.createElement('input');
input.type = 'text';
input.value = ':)';
input.type = 'range';
shouldBe('input.value', '"50"');

debug('');
debug('Text:');
var container = document.createElement('div');
document.body.appendChild(container);
container.innerHTML = '<input type="text" id="text" value="\n\r foo bar \n\r\n">';
input = document.getElementById('text');
shouldBe('input.value', '" foo bar "');
input.focus();
document.execCommand('SelectAll');
shouldBe('document.getSelection().toString()', '" foo bar "');

input.value = String.fromCharCode(0xD800);
shouldBe('input.value', 'String.fromCharCode(0xD800)');

input.value = 'foo\0bar';
shouldBeEqualToString('input.value', 'foo\0bar');

input.value = 'foo\bbar';
shouldBeEqualToString('input.value', "foo\bbar");

input.value = 'foo\tbar';
shouldBeEqualToString('input.value', "foo\tbar");

input.value = "foo\vbar";
shouldBeEqualToString('input.value', "foo\vbar");

input.value = "foo\fbar";
shouldBeEqualToString('input.value', "foo\fbar");

// FIXME: Add more sanitization tests.
// https://bugs.webkit.org/show_bug.cgi?id=37024

container.innerHTML = '';

</script>
</body>
</html>