<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.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('input.selectionStart', '0');
shouldBe('input.selectionEnd', '9');
shouldBeEqualToString('input.value.substring(input.selectionStart, input.selectionEnd)', ' foo bar ');

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>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
