4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description">This test ensures WebKit returns correct values for HTMLInputElement.lastChangeWasUserEdit and
8 HTMLTextAreaElement.lastChangeWasUserEdit, which are exposed via WebKit API.
</p>
9 <div id=
"console"></div>
10 <input type=
"text"><textarea></textarea>
13 if (!window
.testRunner
|| !window
.internals
)
14 testFailed('This test requires access to window.internals');
17 function runTest(element
) {
18 debug((textField
? '\n' : '') + element
.localName
);
22 shouldBeFalse('internals.wasLastChangeUserEdit(textField)');
23 shouldBeFalse('textField.value = "hello"; internals.wasLastChangeUserEdit(textField)');
26 textField
.selectionStart
= textField
.value
.length
;
27 textField
.selectionEnd
= textField
.selectionStart
;
28 shouldBeTrue('document.execCommand("InsertText", false, " world"); internals.wasLastChangeUserEdit(textField)');
30 shouldBeTrue('textField.style.display = "none"; internals.wasLastChangeUserEdit(textField)');
31 shouldBeFalse('textField.value = "WebKit"; internals.wasLastChangeUserEdit(textField)');
32 shouldBeFalse('textField.style.display = null; internals.wasLastChangeUserEdit(textField)');
35 shouldBeFalse('document.execCommand("SelectAll", false, null); internals.wasLastChangeUserEdit(textField)');
36 shouldBeTrue('document.execCommand("Delete", false, null); internals.wasLastChangeUserEdit(textField)');
38 if (textField
.localName
== 'textarea') {
39 shouldBeFalse('textField.textContent = "hello\\nworld"; internals.wasLastChangeUserEdit(textField)');
42 textField
.selectionStart
= textField
.value
.length
;
43 textField
.selectionEnd
= textField
.selectionStart
;
44 shouldBeTrue('document.execCommand("InsertText", false, "\\nWebKit rocks"); internals.wasLastChangeUserEdit(textField)');
46 shouldBeFalse('textField.innerText = " WebKit "; internals.wasLastChangeUserEdit(textField)');
49 textField
.parentNode
.removeChild(textField
);
52 runTest(document
.getElementsByTagName('input')[0]);
53 runTest(document
.getElementsByTagName('textarea')[0]);