Fix an assertion failure in CalendarPickerElement::hostInput().
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 04:18:19 +0000 (04:18 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 04:18:19 +0000 (04:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91568

Reviewed by Hajime Morita.

Source/WebCore:

Test: fast/forms/date/calendar-picker-type-change-onclick.html

* html/shadow/CalendarPickerElement.cpp:
(WebCore::CalendarPickerElement::defaultEventHandler):
It's possible that this function is called when the element is detached
from the document tree.

LayoutTests:

* fast/forms/date/calendar-picker-type-change-onclick-expected.txt: Added.
* fast/forms/date/calendar-picker-type-change-onclick.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@122918 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/date/calendar-picker-type-change-onclick-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/date/calendar-picker-type-change-onclick.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/shadow/CalendarPickerElement.cpp

index 09af57c..d13009c 100644 (file)
@@ -1,3 +1,13 @@
+2012-07-17  Kent Tamura  <tkent@chromium.org>
+
+        Fix an assertion failure in CalendarPickerElement::hostInput().
+        https://bugs.webkit.org/show_bug.cgi?id=91568
+
+        Reviewed by Hajime Morita.
+
+        * fast/forms/date/calendar-picker-type-change-onclick-expected.txt: Added.
+        * fast/forms/date/calendar-picker-type-change-onclick.html: Added.
+
 2012-07-17  MORITA Hajime <morrita@google.com>
 
         [Shadow DOM] Some distribution invalidation can drop necessary reattachment.
diff --git a/LayoutTests/fast/forms/date/calendar-picker-type-change-onclick-expected.txt b/LayoutTests/fast/forms/date/calendar-picker-type-change-onclick-expected.txt
new file mode 100644 (file)
index 0000000..4eb47e1
--- /dev/null
@@ -0,0 +1,10 @@
+Check if we have no crash in a case that the input type is changed by clicking the calendar picker indicator.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS unless crash or assertion failure
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/date/calendar-picker-type-change-onclick.html b/LayoutTests/fast/forms/date/calendar-picker-type-change-onclick.html
new file mode 100644 (file)
index 0000000..a55807e
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<body>
+<script src="../../js/resources/js-test-pre.js"></script>
+<input type="date" onclick="changeType(this)" />
+<script>
+description('Check if we have no crash in a case that the input type is changed by clicking the calendar picker indicator.');
+
+function changeType(input) {
+    input.type = 'text';
+    testPassed('unless crash or assertion failure');
+    finishJSTest();
+}
+
+jsTestIsAsync = true;
+if (!window.eventSender) {
+    debug('Click on the triangle in the input field.');
+} else {
+    setTimeout(function() {
+        var dateInput = document.getElementsByTagName('input')[0];
+        eventSender.mouseMoveTo(dateInput.offsetLeft + dateInput.offsetWidth - 6,
+                                dateInput.offsetTop + dateInput.offsetHeight / 2);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }, 0);
+}
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
index eaaf8b4..de81da8 100644 (file)
@@ -1,5 +1,19 @@
 2012-07-17  Kent Tamura  <tkent@chromium.org>
 
+        Fix an assertion failure in CalendarPickerElement::hostInput().
+        https://bugs.webkit.org/show_bug.cgi?id=91568
+
+        Reviewed by Hajime Morita.
+
+        Test: fast/forms/date/calendar-picker-type-change-onclick.html
+
+        * html/shadow/CalendarPickerElement.cpp:
+        (WebCore::CalendarPickerElement::defaultEventHandler):
+        It's possible that this function is called when the element is detached
+        from the document tree.
+
+2012-07-17  Kent Tamura  <tkent@chromium.org>
+
         Form state: Make a new class handling HashMap<FormElementKey, Deque<>>
         https://bugs.webkit.org/show_bug.cgi?id=91480
 
index 5358cca..b4176b2 100644 (file)
@@ -88,6 +88,8 @@ inline HTMLInputElement* CalendarPickerElement::hostInput()
 
 void CalendarPickerElement::defaultEventHandler(Event* event)
 {
+    if (!renderer())
+        return;
     HTMLInputElement* input = hostInput();
     if (input->readOnly() || input->disabled())
         return;