- Revision
- 94038
- Author
- [email protected]
- Date
- 2011-08-29 19:03:52 -0700 (Mon, 29 Aug 2011)
Log Message
Add a test for lastChangeWasUserEdit in HTMLInputElement and HTMLTextAreaElement
https://bugs.webkit.org/show_bug.cgi?id=67173
Reviewed by Darin Adler.
Source/WebCore:
Exposed HTMLInputElement::lastChangeWasUserEdit and HTMLTextAreaElement::lastChangeWasUserEdit
via internals.wasLastChangeUserEdit(Element*, ExceptionCode&). The first argument must be
an input element or a textarea element lastChangeWasUserEdit is called upon.
Test: fast/forms/textfield-lastchange-was-useredit.html
* testing/Internals.cpp:
(WebCore::Internals::wasLastChangeUserEdit):
* testing/Internals.h:
* testing/Internals.idl:
LayoutTests:
Added some basic test for HTMLInputElement::lastChangeWasUserEdit and
HTMLTextAreaElement::lastChangeWasUserEdit.
* fast/forms/textfield-lastchange-was-useredit-expected.txt: Added.
* fast/forms/textfield-lastchange-was-useredit.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (94037 => 94038)
--- trunk/LayoutTests/ChangeLog 2011-08-30 01:49:10 UTC (rev 94037)
+++ trunk/LayoutTests/ChangeLog 2011-08-30 02:03:52 UTC (rev 94038)
@@ -1,3 +1,16 @@
+2011-08-29 Ryosuke Niwa <[email protected]>
+
+ Add a test for lastChangeWasUserEdit in HTMLInputElement and HTMLTextAreaElement
+ https://bugs.webkit.org/show_bug.cgi?id=67173
+
+ Reviewed by Darin Adler.
+
+ Added some basic test for HTMLInputElement::lastChangeWasUserEdit and
+ HTMLTextAreaElement::lastChangeWasUserEdit.
+
+ * fast/forms/textfield-lastchange-was-useredit-expected.txt: Added.
+ * fast/forms/textfield-lastchange-was-useredit.html: Added.
+
2011-08-29 Kenji Imasaki <[email protected]>
[Chromium] Added new rebaselines for media/media-document-audio-repaint.
Added: trunk/LayoutTests/fast/forms/textfield-lastchange-was-useredit-expected.txt (0 => 94038)
--- trunk/LayoutTests/fast/forms/textfield-lastchange-was-useredit-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/textfield-lastchange-was-useredit-expected.txt 2011-08-30 02:03:52 UTC (rev 94038)
@@ -0,0 +1,28 @@
+This test ensures WebKit returns correct values for HTMLInputElement.lastChangeWasUserEdit and HTMLTextAreaElement.lastChangeWasUserEdit, which are exposed via WebKit API.
+
+input
+PASS internals.wasLastChangeUserEdit(textField) is false
+PASS textField.value = "hello"; internals.wasLastChangeUserEdit(textField) is false
+PASS document.execCommand("InsertText", false, " world"); internals.wasLastChangeUserEdit(textField) is true
+PASS textField.style.display = "none"; internals.wasLastChangeUserEdit(textField) is true
+PASS textField.value = "WebKit"; internals.wasLastChangeUserEdit(textField) is false
+PASS textField.style.display = null; internals.wasLastChangeUserEdit(textField) is false
+PASS document.execCommand("SelectAll", false, null); internals.wasLastChangeUserEdit(textField) is false
+PASS document.execCommand("Delete", false, null); internals.wasLastChangeUserEdit(textField) is true
+
+textarea
+PASS internals.wasLastChangeUserEdit(textField) is false
+PASS textField.value = "hello"; internals.wasLastChangeUserEdit(textField) is false
+PASS document.execCommand("InsertText", false, " world"); internals.wasLastChangeUserEdit(textField) is true
+PASS textField.style.display = "none"; internals.wasLastChangeUserEdit(textField) is true
+PASS textField.value = "WebKit"; internals.wasLastChangeUserEdit(textField) is false
+PASS textField.style.display = null; internals.wasLastChangeUserEdit(textField) is false
+PASS document.execCommand("SelectAll", false, null); internals.wasLastChangeUserEdit(textField) is false
+PASS document.execCommand("Delete", false, null); internals.wasLastChangeUserEdit(textField) is true
+FAIL textField.textContent = "hello\nworld"; internals.wasLastChangeUserEdit(textField) should be false. Was true.
+PASS document.execCommand("InsertText", false, "\nWebKit rocks"); internals.wasLastChangeUserEdit(textField) is true
+FAIL textField.innerText = " WebKit "; internals.wasLastChangeUserEdit(textField) should be false. Was true.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/textfield-lastchange-was-useredit.html (0 => 94038)
--- trunk/LayoutTests/fast/forms/textfield-lastchange-was-useredit.html (rev 0)
+++ trunk/LayoutTests/fast/forms/textfield-lastchange-was-useredit.html 2011-08-30 02:03:52 UTC (rev 94038)
@@ -0,0 +1,61 @@
+<!DOCTYPE>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description">This test ensures WebKit returns correct values for HTMLInputElement.lastChangeWasUserEdit and
+HTMLTextAreaElement.lastChangeWasUserEdit, which are exposed via WebKit API.</p>
+<div id="console"></div>
+<input type="text"><textarea></textarea>
+<script>
+
+if (!window.layoutTestController || !window.internals)
+ testFailed('This test requires access to window.internals');
+
+var textField;
+function runTest(element) {
+ debug((textField ? '\n' : '') + element.localName);
+
+ textField = element;
+
+ shouldBeFalse('internals.wasLastChangeUserEdit(textField)');
+ shouldBeFalse('textField.value = "hello"; internals.wasLastChangeUserEdit(textField)');
+
+ textField.focus();
+ textField.selectionStart = textField.value.length;
+ textField.selectionEnd = textField.selectionStart;
+ shouldBeTrue('document.execCommand("InsertText", false, " world"); internals.wasLastChangeUserEdit(textField)');
+
+ shouldBeTrue('textField.style.display = "none"; internals.wasLastChangeUserEdit(textField)');
+ shouldBeFalse('textField.value = "WebKit"; internals.wasLastChangeUserEdit(textField)');
+ shouldBeFalse('textField.style.display = null; internals.wasLastChangeUserEdit(textField)');
+
+ textField.focus();
+ shouldBeFalse('document.execCommand("SelectAll", false, null); internals.wasLastChangeUserEdit(textField)');
+ shouldBeTrue('document.execCommand("Delete", false, null); internals.wasLastChangeUserEdit(textField)');
+
+ if (textField.localName == 'textarea') {
+ shouldBeFalse('textField.textContent = "hello\\nworld"; internals.wasLastChangeUserEdit(textField)');
+
+ textField.focus();
+ textField.selectionStart = textField.value.length;
+ textField.selectionEnd = textField.selectionStart;
+ shouldBeTrue('document.execCommand("InsertText", false, "\\nWebKit rocks"); internals.wasLastChangeUserEdit(textField)');
+
+ shouldBeFalse('textField.innerText = " WebKit "; internals.wasLastChangeUserEdit(textField)');
+ }
+
+ textField.parentNode.removeChild(textField);
+}
+
+runTest(document.getElementsByTagName('input')[0]);
+runTest(document.getElementsByTagName('textarea')[0]);
+
+var successfullyParsed = true;
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (94037 => 94038)
--- trunk/Source/WebCore/ChangeLog 2011-08-30 01:49:10 UTC (rev 94037)
+++ trunk/Source/WebCore/ChangeLog 2011-08-30 02:03:52 UTC (rev 94038)
@@ -1,3 +1,21 @@
+2011-08-29 Ryosuke Niwa <[email protected]>
+
+ Add a test for lastChangeWasUserEdit in HTMLInputElement and HTMLTextAreaElement
+ https://bugs.webkit.org/show_bug.cgi?id=67173
+
+ Reviewed by Darin Adler.
+
+ Exposed HTMLInputElement::lastChangeWasUserEdit and HTMLTextAreaElement::lastChangeWasUserEdit
+ via internals.wasLastChangeUserEdit(Element*, ExceptionCode&). The first argument must be
+ an input element or a textarea element lastChangeWasUserEdit is called upon.
+
+ Test: fast/forms/textfield-lastchange-was-useredit.html
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::wasLastChangeUserEdit):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2011-08-29 Luke Macpherson <[email protected]>
Implement CSSPropertyWebkitColumns in CSSStyleApplyProperty.
Modified: trunk/Source/WebCore/testing/Internals.cpp (94037 => 94038)
--- trunk/Source/WebCore/testing/Internals.cpp 2011-08-30 01:49:10 UTC (rev 94037)
+++ trunk/Source/WebCore/testing/Internals.cpp 2011-08-30 02:03:52 UTC (rev 94038)
@@ -32,6 +32,9 @@
#include "DocumentMarkerController.h"
#include "Element.h"
#include "ExceptionCode.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "HTMLTextAreaElement.h"
#include "InspectorController.h"
#include "MemoryCache.h"
#include "NodeRenderingContext.h"
@@ -262,5 +265,22 @@
}
}
+bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec)
+{
+ if (!textField) {
+ ec = INVALID_ACCESS_ERR;
+ return false;
+ }
+
+ if (textField->hasTagName(HTMLNames::inputTag))
+ return static_cast<HTMLInputElement*>(textField)->lastChangeWasUserEdit();
+
+ if (textField->hasTagName(HTMLNames::textareaTag))
+ return static_cast<HTMLTextAreaElement*>(textField)->lastChangeWasUserEdit();
+
+ ec = INVALID_NODE_TYPE_ERR;
+ return false;
}
+}
+
Modified: trunk/Source/WebCore/testing/Internals.h (94037 => 94038)
--- trunk/Source/WebCore/testing/Internals.h 2011-08-30 01:49:10 UTC (rev 94037)
+++ trunk/Source/WebCore/testing/Internals.h 2011-08-30 02:03:52 UTC (rev 94038)
@@ -76,6 +76,8 @@
void setPasswordEchoEnabled(Document*, bool enabled, ExceptionCode&);
void setPasswordEchoDurationInSeconds(Document*, double durationInSeconds, ExceptionCode&);
+ bool wasLastChangeUserEdit(Element* textField, ExceptionCode&);
+
static const char* internalsId;
private:
Modified: trunk/Source/WebCore/testing/Internals.idl (94037 => 94038)
--- trunk/Source/WebCore/testing/Internals.idl 2011-08-30 01:49:10 UTC (rev 94037)
+++ trunk/Source/WebCore/testing/Internals.idl 2011-08-30 02:03:52 UTC (rev 94038)
@@ -49,6 +49,8 @@
void setPasswordEchoEnabled(in Document document, in boolean enabled) raises(DOMException);
void setPasswordEchoDurationInSeconds(in Document document, in double durationInSeconds) raises(DOMException);
+
+ boolean wasLastChangeUserEdit(in Element textField) raises (DOMException);
};
}