Skip to content
Permalink
Browse files
2010-07-22 Kent Tamura <tkent@chromium.org>
        Reviewed by Ojan Vafai.

        Cancel button of search input field should fire input/change events
        https://bugs.webkit.org/show_bug.cgi?id=34393

        * fast/forms/script-tests/search-cancel-button-events.js: Added.
        * fast/forms/search-cancel-button-events-expected.txt: Added.
        * fast/forms/search-cancel-button-events.html: Added.
2010-07-22  Kent Tamura  <tkent@chromium.org>

        Reviewed by Ojan Vafai.

        Cancel button of search input field should fire input/change events
        https://bugs.webkit.org/show_bug.cgi?id=34393

        Test: fast/forms/search-cancel-button-events.html

        * rendering/TextControlInnerElements.cpp:
        (WebCore::SearchFieldCancelButtonElement::defaultEventHandler):

Canonical link: https://commits.webkit.org/54765@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
tkent-google committed Jul 23, 2010
1 parent 138046e commit 7569ad70f576c2ea40985d5d1db337e2e12324ae
@@ -1,3 +1,14 @@
2010-07-22 Kent Tamura <tkent@chromium.org>

Reviewed by Ojan Vafai.

Cancel button of search input field should fire input/change events
https://bugs.webkit.org/show_bug.cgi?id=34393

* fast/forms/script-tests/search-cancel-button-events.js: Added.
* fast/forms/search-cancel-button-events-expected.txt: Added.
* fast/forms/search-cancel-button-events.html: Added.

2010-07-22 Kent Tamura <tkent@chromium.org>

Reviewed by Ojan Vafai.
@@ -0,0 +1,37 @@
description('Test for event dipatching by search cancel button.');

var parent = document.createElement('div');
document.body.appendChild(parent);
parent.innerHTML = '<input type=search id=search value=foo><input id=another>';
var search = document.getElementById('search');
var anotherInput = document.getElementById('another');
var inputEventCounter = 0;
var changeEventCounter = 0;

search.onchange = function() { changeEventCounter++; };
search.oninput = function() { inputEventCounter++; };

if (window.eventSender) {
debug('Initial state');
shouldBe('changeEventCounter', '0');
shouldBe('inputEventCounter', '0');

debug('Click the cancel button');
eventSender.mouseMoveTo(search.offsetLeft + search.offsetWidth - 8, search.offsetTop + search.offsetHeight / 2);
eventSender.mouseDown();
eventSender.mouseUp();
shouldBe('search.value', '""');
shouldBe('changeEventCounter', '0');
shouldBe('inputEventCounter', '1');

debug('Focus on another field');
anotherInput.focus();
shouldBe('changeEventCounter', '1');
shouldBe('inputEventCounter', '1');

parent.innerHTML = '';
} else {
document.getElementById('console').innerHTML = 'No eventSender';
}

var successfullyParsed = true;
@@ -0,0 +1,19 @@
Test for event dipatching by search cancel button.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


Initial state
PASS changeEventCounter is 0
PASS inputEventCounter is 0
Click the cancel button
PASS search.value is ""
PASS changeEventCounter is 0
PASS inputEventCounter is 1
Focus on another field
PASS changeEventCounter is 1
PASS inputEventCounter is 1
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/search-cancel-button-events.js"></script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
@@ -1,3 +1,15 @@
2010-07-22 Kent Tamura <tkent@chromium.org>

Reviewed by Ojan Vafai.

Cancel button of search input field should fire input/change events
https://bugs.webkit.org/show_bug.cgi?id=34393

Test: fast/forms/search-cancel-button-events.html

* rendering/TextControlInnerElements.cpp:
(WebCore::SearchFieldCancelButtonElement::defaultEventHandler):

2010-07-22 Sam Weinig <sam@webkit.org>

Reviewed by Maciej Stachowiak.
@@ -232,7 +232,13 @@ void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
m_capturing = false;
}
if (hovered()) {
RefPtr<HTMLInputElement> protector(input);
String oldValue = input->value();
input->setValue("");
if (!oldValue.isEmpty()) {
toRenderTextControl(input->renderer())->setChangedSinceLastChangeEvent(true);
input->dispatchEvent(Event::create(eventNames().inputEvent, true, false));
}
input->onSearch();
event->setDefaultHandled();
}

0 comments on commit 7569ad7

Please sign in to comment.