Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / textfield-lastchange-was-useredit.html
blob0c22142d76fc2d7edeb06ccaba450cd623d50dde
1 <!DOCTYPE>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
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>
11 <script>
13 if (!window.testRunner || !window.internals)
14 testFailed('This test requires access to window.internals');
16 var textField;
17 function runTest(element) {
18 debug((textField ? '\n' : '') + element.localName);
20 textField = element;
22 shouldBeFalse('internals.wasLastChangeUserEdit(textField)');
23 shouldBeFalse('textField.value = "hello"; internals.wasLastChangeUserEdit(textField)');
25 textField.focus();
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)');
34 textField.focus();
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)');
41 textField.focus();
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]);
55 </script>
56 </body>
57 </html>