Modified: trunk/LayoutTests/ChangeLog (90224 => 90225)
--- trunk/LayoutTests/ChangeLog 2011-07-01 13:25:03 UTC (rev 90224)
+++ trunk/LayoutTests/ChangeLog 2011-07-01 13:58:18 UTC (rev 90225)
@@ -1,3 +1,16 @@
+2011-07-01 Kentaro Hara <[email protected]>
+
+ Reviewed by Kent Tamura.
+
+ Disallow clicking an [X] button in 'search' input forms when 'disabled' attribute or 'readonly' attribute is set.
+ https://bugs.webkit.org/show_bug.cgi?id=63709
+
+ Added a test that checks whether the content in 'search' input forms with 'disabled' attribute
+ or 'readonly' attribute is cleared or not, when an [X] button is clicked.
+
+ * fast/forms/search-disabled-readonly-expected.txt: Added.
+ * fast/forms/search-disabled-readonly.html: Added.
+
2011-07-01 Kent Tamura <[email protected]>
[Chromium] Update text expectation for Vista.
Added: trunk/LayoutTests/fast/forms/search-disabled-readonly-expected.txt (0 => 90225)
--- trunk/LayoutTests/fast/forms/search-disabled-readonly-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/search-disabled-readonly-expected.txt 2011-07-01 13:58:18 UTC (rev 90225)
@@ -0,0 +1,47 @@
+
+This tests the behavior of a cancel button in search input forms.
+
+Test on the input form with disabled=false and readonly=false
+Click the cancel button:
+PASS input.value is ""
+... and then input one character:
+PASS input.value is "b"
+Click the center of the form:
+PASS input.value is "foo"
+... and then input one character:
+PASS input.value is "foob"
+
+Test on the input form with disabled=false and readonly=true
+Click the cancel button:
+PASS input.value is "foo"
+... and then input one character:
+PASS input.value is "foo"
+Click the center of the form:
+PASS input.value is "foo"
+... and then input one character:
+PASS input.value is "foo"
+
+Test on the input form with disabled=true and readonly=false
+Click the cancel button:
+PASS input.value is "foo"
+... and then input one character:
+PASS input.value is "foo"
+Click the center of the form:
+PASS input.value is "foo"
+... and then input one character:
+PASS input.value is "foo"
+
+Test on the input form with disabled=true and readonly=true
+Click the cancel button:
+PASS input.value is "foo"
+... and then input one character:
+PASS input.value is "foo"
+Click the center of the form:
+PASS input.value is "foo"
+... and then input one character:
+PASS input.value is "foo"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/search-disabled-readonly.html (0 => 90225)
--- trunk/LayoutTests/fast/forms/search-disabled-readonly.html (rev 0)
+++ trunk/LayoutTests/fast/forms/search-disabled-readonly.html 2011-07-01 13:58:18 UTC (rev 90225)
@@ -0,0 +1,130 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<input id="search_input" type="search" />
+<div id="console">
+<p>
+This tests the behavior of a cancel button in search input forms.
+</p>
+</div>
+<script>
+function click(position) {
+ if (!eventSender)
+ return;
+ eventSender.mouseMoveTo(position.x, position.y);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(position.x, position.y);
+ eventSender.mouseUp();
+ eventSender.leapForward(1000);
+}
+
+function keydown(character) {
+ if (!eventSender)
+ return;
+ eventSender.keyDown(character);
+ eventSender.leapForward(1000);
+}
+
+function setInputAttributes(input, value, disabled, readonly) {
+ input.value = value;
+ input.disabled = disabled;
+ input.readOnly = !!readonly;
+}
+
+if (window.layoutTestController) {
+ var input = $("search_input");
+ var cancelButtonPosition = searchCancelButtonPosition(input);
+ var middleButtonPosition = {};
+ middleButtonPosition.x = input.offsetLeft + input.offsetWidth / 2;
+ middleButtonPosition.y = input.offsetTop + input.offsetHeight / 2;
+ var enabled = false;
+ var disabled = true;
+ var readonly = true;
+
+ debug("Test on the input form with disabled=false and readonly=false");
+
+ setInputAttributes(input, "foo", enabled);
+ debug("Click the cancel button:");
+ click(cancelButtonPosition);
+ shouldBe('input.value', '""');
+ debug("... and then input one character:");
+ keydown("b");
+ shouldBe('input.value', '"b"');
+
+ setInputAttributes(input, "foo", enabled);
+ debug("Click the center of the form:");
+ click(middleButtonPosition);
+ shouldBe('input.value', '"foo"');
+ debug("... and then input one character:");
+ keydown("b");
+ shouldBe('input.value', '"foob"');
+
+ debug("");
+ debug("Test on the input form with disabled=false and readonly=true");
+
+ setInputAttributes(input, "foo", enabled, readonly);
+ debug("Click the cancel button:");
+ click(cancelButtonPosition);
+ shouldBe('input.value', '"foo"');
+ debug("... and then input one character:");
+ keydown("b");
+ shouldBe('input.value', '"foo"');
+
+ setInputAttributes(input, "foo", enabled, readonly);
+ debug("Click the center of the form:");
+ click(middleButtonPosition);
+ shouldBe('input.value', '"foo"');
+ debug("... and then input one character:");
+ keydown("b");
+ shouldBe('input.value', '"foo"');
+
+ debug("");
+ debug("Test on the input form with disabled=true and readonly=false");
+
+ setInputAttributes(input, "foo", disabled);
+ debug("Click the cancel button:");
+ click(cancelButtonPosition);
+ shouldBe('input.value', '"foo"');
+ debug("... and then input one character:");
+ keydown("b");
+ shouldBe('input.value', '"foo"');
+
+ setInputAttributes(input, "foo", disabled);
+ debug("Click the center of the form:");
+ click(middleButtonPosition);
+ shouldBe('input.value', '"foo"');
+ debug("... and then input one character:");
+ keydown("b");
+ shouldBe('input.value', '"foo"');
+
+ debug("");
+ debug("Test on the input form with disabled=true and readonly=true");
+
+ setInputAttributes(input, "foo", disabled, readonly);
+ debug("Click the cancel button:");
+ click(cancelButtonPosition);
+ shouldBe('input.value', '"foo"');
+ debug("... and then input one character:");
+ keydown("b");
+ shouldBe('input.value', '"foo"');
+
+ setInputAttributes(input, "foo", disabled, readonly);
+ debug("Click the center of the form:");
+ click(middleButtonPosition);
+ shouldBe('input.value', '"foo"');
+ debug("... and then input one character:");
+ keydown("b");
+ shouldBe('input.value', '"foo"');
+
+ debug("");
+}
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (90224 => 90225)
--- trunk/Source/WebCore/ChangeLog 2011-07-01 13:25:03 UTC (rev 90224)
+++ trunk/Source/WebCore/ChangeLog 2011-07-01 13:58:18 UTC (rev 90225)
@@ -1,3 +1,18 @@
+2011-07-01 Kentaro Hara <[email protected]>
+
+ Reviewed by Kent Tamura.
+
+ Disallow clicking an [X] button in 'search' input forms when 'disabled' attribute or 'readonly' attribute is set.
+ https://bugs.webkit.org/show_bug.cgi?id=63709
+
+ Ignore a cancel button event on a 'search' input form if 'disabled' attribute or
+ 'readonly' attribute is set to the input form.
+
+ Test: fast/forms/search-disabled-readonly.html
+
+ * html/shadow/TextControlInnerElements.cpp:
+ (WebCore::SearchFieldCancelButtonElement::defaultEventHandler):
+
2011-06-30 Mikhail Naganov <[email protected]>
Reviewed by Yury Semikhatsky.
Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (90224 => 90225)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2011-07-01 13:25:03 UTC (rev 90224)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2011-07-01 13:58:18 UTC (rev 90225)
@@ -192,6 +192,12 @@
{
// If the element is visible, on mouseup, clear the value, and set selection
RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode()));
+ if (input->disabled() || input->isReadOnlyFormControl()) {
+ if (!event->defaultHandled())
+ HTMLDivElement::defaultEventHandler(event);
+ return;
+ }
+
if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (renderer() && renderer()->visibleToHitTesting()) {
if (Frame* frame = document()->frame()) {