blob: c4627800ce264a0cc6b1fac8b32587051cfeb33e [file] [log] [blame]
<!doctype HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div id="text">
Testing
CSS white-space property
</div>
<textarea id="textarea" rows="4" cols="40"></textarea>
<script>
var textForCopy = document.getElementById('text');
var textarea = document.getElementById('textarea');
function defocus() {
eventSender.mouseMoveTo(0, 0);
eventSender.mouseDown();
eventSender.mouseUp();
}
function copyAndPaste(whiteSpaceValue) {
defocus();
textarea.value ='';
textForCopy.style.whiteSpace = whiteSpaceValue;
var selection = window.getSelection();
selection.removeAllRanges();
var range = document.createRange();
range.selectNode(textForCopy);
selection.addRange(range);
document.execCommand('copy');
textarea.focus();
document.execCommand('paste');
return whiteSpaceValue;
}
test(function() {
assert_equals(textarea.value, '\n \tTesting \nCSS white-space property\n');
}, copyAndPaste('pre'));
test(function() {
assert_equals(textarea.value, '\n \tTesting \nCSS white-space property\n');
}, copyAndPaste('pre-wrap'));
test(function() {
assert_equals(textarea.value, 'Testing CSS white-space property\n');
}, copyAndPaste('normal'));
test(function() {
assert_equals(textarea.value, 'Testing CSS white-space property\n');
}, copyAndPaste('nowrap'));
test(function() {
assert_equals(textarea.value, '\nTesting\nCSS white-space property\n');
}, copyAndPaste('pre-line'));
</script>