blob: c529efb6a4267011b134342754e346912417c875 [file] [log] [blame]
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script src="spellcheck_test.js"></script>
<script>
function pasteHTMLToDest(document, html)
{
document.getSelection().setClipboardData(html);
document.getElementById('dest').focus();
document.execCommand('Paste');
}
spellcheck_test(
'<div contenteditable id="dest">|</div>',
document => pasteHTMLToDest(document, 'You has the right.'),
'<div contenteditable id="dest">You ~has~ the right.</div>',
'Paste plain text into editable <div>.');
spellcheck_test(
'<div contenteditable id="dest">|</div>',
document => pasteHTMLToDest(document,
'I have a<b>n ki</b>wi. I have no idea.'),
[
'<div contenteditable id="dest">',
'I have ~a~<b>~n~ ki</b>wi. I have no idea.',
'</div>'
].join(''),
'Paste decorated text into editable <div>.');
spellcheck_test(
'<div contenteditable id="dest">|</div>',
document => pasteHTMLToDest(
document, 'I have an grape. I have an muscat. I don\'t know.'),
[
'<div contenteditable id="dest">',
'I have ~an~ grape. I have ~an~ muscat. I don\'t know.',
'</div>'
].join(''),
'Paste text with multiple errors into editable <div>.');
spellcheck_test(
'<input id="dest" type="text">|',
document => pasteHTMLToDest(document, 'You has the right.'),
'<input id="dest" type="text" value="You ~has~ the right.">',
'Paste plain text into <input>.');
spellcheck_test(
'<input id="dest" type="text">|',
document => pasteHTMLToDest(document,
'I have a<b>n ki</b>wi. I have no idea.'),
'<input id="dest" type="text" value="I have ~an~ kiwi. I have no idea.">',
'Paste decorated text into <input>.');
spellcheck_test(
'<input id="dest" type="text">|',
document => pasteHTMLToDest(
document, 'I have an grape. I have an muscat. I don\'t know.'),
'<input id="dest" type="text" ' +
'value="I have ~an~ grape. I have ~an~ muscat. I don\'t know.">',
'Paste text with multiple errors into <input>.');
spellcheck_test(
'<textarea id="dest">|</textarea>',
document => pasteHTMLToDest(document, 'You has the right.'),
'<textarea id="dest">You ~has~ the right.</textarea>',
'Paste plain text into <textarea>.');
spellcheck_test(
'<textarea id="dest">|</textarea>',
document => pasteHTMLToDest(document,
'I have a<b>n ki</b>wi. I have no idea.'),
'<textarea id="dest">I have ~an~ kiwi. I have no idea.</textarea>',
'Paste decorated text into <textarea>.');
spellcheck_test(
'<textarea id="dest">|</textarea>',
document => pasteHTMLToDest(
document, 'I have an grape. I have an muscat. I don\'t know.'),
[
'<textarea id="dest">',
'I have ~an~ grape. I have ~an~ muscat. I don\'t know.',
'</textarea>'
].join(''),
'Paste text with multiple errors into <textarea>.');
</script>