Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / input-value-sanitization.html
blob9d949bd095051a7bd7e54ba0b68b63fafc38d136
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p>Tests for value sanitization algorithm.</p>
8 <div id="console"></div>
9 <script>
10 var input;
12 debug('');
13 debug('Email with multiple:');
14 input = document.createElement('input');
15 input.multiple = true;
16 input.type = 'email';
17 input.setAttribute('value', ' tkent@chromium.org, tkent@example.!!! ');
18 shouldBe('input.value', '"tkent@chromium.org,tkent@example.!!!"');
19 debug('Email without multiple:');
20 input = document.createElement('input');
21 input.multiple = false;
22 input.type = 'email';
23 input.setAttribute('value', ' tkent@chromium.org, tkent@example.*** \r\n');
24 shouldBe('input.value', '"tkent@chromium.org, tkent@example.***"');
26 debug('');
27 debug('Number:');
28 input = document.createElement('input');
29 input.setAttribute('value', '65536');
30 input.type = 'number';
31 shouldBe('input.value', '"65536"');
32 shouldBe('input.value = "256"; input.value', '"256"');
33 shouldBe('input.value = ""; input.value', '""');
36 debug('');
37 debug('Range:');
38 input = document.createElement('input');
39 input.type = 'text';
40 input.value = ':)';
41 input.type = 'range';
42 shouldBe('input.value', '"50"');
44 debug('');
45 debug('Text:');
46 var container = document.createElement('div');
47 document.body.appendChild(container);
48 container.innerHTML = '<input type="text" id="text" value="\n\r foo bar \n\r\n">';
49 input = document.getElementById('text');
50 shouldBe('input.value', '" foo bar "');
51 input.focus();
52 document.execCommand('SelectAll');
53 shouldBe('document.getSelection().toString()', '" foo bar "');
55 input.value = String.fromCharCode(0xD800);
56 shouldBe('input.value', 'String.fromCharCode(0xD800)');
58 input.value = 'foo\0bar';
59 shouldBeEqualToString('input.value', 'foo\0bar');
61 input.value = 'foo\bbar';
62 shouldBeEqualToString('input.value', "foo\bbar");
64 input.value = 'foo\tbar';
65 shouldBeEqualToString('input.value', "foo\tbar");
67 input.value = "foo\vbar";
68 shouldBeEqualToString('input.value', "foo\vbar");
70 input.value = "foo\fbar";
71 shouldBeEqualToString('input.value', "foo\fbar");
73 // FIXME: Add more sanitization tests.
74 // https://bugs.webkit.org/show_bug.cgi?id=37024
76 container.innerHTML = '';
78 </script>
79 </body>
80 </html>