Implement AutocompleteErrorEvent#reason
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 22:40:15 +0000 (22:40 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 22:40:15 +0000 (22:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105568

Source/WebCore:

Patch by Dan Beam <dbeam@chromium.org> on 2013-01-10
Reviewed by Adam Barth.

Test: fast/events/constructors/autocomplete-error-event-constructor.html

* WebCore.gypi: Added AutocompleteErrorEvent.idl and AutocompleteErrorEvent.h for chromium port's build.
* dom/AutocompleteErrorEvent.h: Added.
(WebCore): Added new type of error named AutocompleteErrorEvent.
(AutocompleteErrorEventInit): Added init params for AutocompleteErrorEvents (so initEvent() can be used).
(AutocompleteErrorEvent): Added a new error event that inherits from Event but also has a reason for failure.
(WebCore::AutocompleteErrorEvent::create): Factory function to create AutocompleteErrorEvents.
(WebCore::AutocompleteErrorEvent::reason): The reason why a requestAutocomplete() invocation failed. Can be
                                           "disabled", "cancel", or "invalid".
(WebCore::AutocompleteErrorEvent::interfaceName): The name of the event's interface (for event.toString()).
(WebCore::AutocompleteErrorEvent::AutocompleteErrorEvent): Various ways of constructing the error event.
* dom/AutocompleteErrorEvent.idl: Added.
* dom/EventNames.in: Added AutocompleteError to this list, based on REQUEST_AUTOCOMPLETE conditional.
* html/HTMLFormElement.cpp: Updated form elements to dispatch AutocompleteErrorEvents on errors and to give
                            more details (event.reason) when the request fails.
(WebCore::HTMLFormElement::requestAutocomplete): Changed to newly added failure type "disabled".
(WebCore::HTMLFormElement::finishRequestAutocomplete): Changed
* html/HTMLFormElement.h: Added new results (ErrorDisabled, ErrorCancel, ErrorInvalid).
* page/DOMWindow.idl: Added global event constructor for new AutocompleteErrorEvent() style event creation.

Source/WebKit/chromium:

Patch by Dan Beam <dbeam@chromium.org> on 2013-01-10
Reviewed by Adam Barth.

* public/WebFormElement.h: Added matching enum values for public chromium WebKit API.
* src/AssertMatchingEnums.cpp: Updated compile assert that WebKit and WebCore enums match.

LayoutTests:

Added tests to verify event creation and global event constructor existence of AutocompleteErrorEvent
and updated the existing tests to make sure errors received are of the right type and have the right reason.

Patch by Dan Beam <dbeam@chromium.org> on 2013-01-10
Reviewed by Adam Barth.

* fast/events/constructors/autocomplete-error-event-constructor-expected.txt: Added.
* fast/events/constructors/autocomplete-error-event-constructor.html: Added.
* fast/events/event-creation.html: Added new AutocompleteErrorEvent() test case.
* fast/forms/form-request-autocomplete.html: Updated 'autocompleteerror' listeners to check event.reason.
* fast/js/constructor-length.html: Added AutocompleteErrorEvent to list.
* fast/js/script-tests/global-constructors.js: Added AutocompleteErrorEvent to list.
* platform/blackberry/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
* platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt: Added.
* platform/chromium/fast/forms/form-request-autocomplete-expected.txt: Updated passing expectations.
* platform/chromium/fast/js/constructor-length-expected.txt: Added expected 0 length result.
* platform/gtk/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
* platform/mac/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
* platform/qt/fast/js/constructor-length-expected.txt: Added expected ReferenceError.

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

25 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/constructors/autocomplete-error-event-constructor-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/constructors/autocomplete-error-event-constructor.html [new file with mode: 0644]
LayoutTests/fast/events/event-creation.html
LayoutTests/fast/forms/form-request-autocomplete.html
LayoutTests/fast/js/constructor-length.html
LayoutTests/fast/js/script-tests/global-constructors.js
LayoutTests/platform/blackberry/fast/js/constructor-length-expected.txt
LayoutTests/platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/forms/form-request-autocomplete-expected.txt
LayoutTests/platform/chromium/fast/js/constructor-length-expected.txt
LayoutTests/platform/gtk/fast/js/constructor-length-expected.txt
LayoutTests/platform/mac/fast/js/constructor-length-expected.txt
LayoutTests/platform/qt/fast/js/constructor-length-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/dom/AutocompleteErrorEvent.h [new file with mode: 0644]
Source/WebCore/dom/AutocompleteErrorEvent.idl [new file with mode: 0644]
Source/WebCore/dom/EventNames.in
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLFormElement.h
Source/WebCore/page/DOMWindow.idl
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebFormElement.h
Source/WebKit/chromium/src/AssertMatchingEnums.cpp

index e063a58..5128098 100644 (file)
@@ -1,3 +1,27 @@
+2013-01-10  Dan Beam  <dbeam@chromium.org>
+
+        Implement AutocompleteErrorEvent#reason
+        https://bugs.webkit.org/show_bug.cgi?id=105568
+
+        Added tests to verify event creation and global event constructor existence of AutocompleteErrorEvent
+        and updated the existing tests to make sure errors received are of the right type and have the right reason.
+
+        Reviewed by Adam Barth.
+
+        * fast/events/constructors/autocomplete-error-event-constructor-expected.txt: Added.
+        * fast/events/constructors/autocomplete-error-event-constructor.html: Added.
+        * fast/events/event-creation.html: Added new AutocompleteErrorEvent() test case.
+        * fast/forms/form-request-autocomplete.html: Updated 'autocompleteerror' listeners to check event.reason.
+        * fast/js/constructor-length.html: Added AutocompleteErrorEvent to list.
+        * fast/js/script-tests/global-constructors.js: Added AutocompleteErrorEvent to list.
+        * platform/blackberry/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
+        * platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt: Added.
+        * platform/chromium/fast/forms/form-request-autocomplete-expected.txt: Updated passing expectations.
+        * platform/chromium/fast/js/constructor-length-expected.txt: Added expected 0 length result.
+        * platform/gtk/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
+        * platform/mac/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
+        * platform/qt/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
+
 2013-01-10  Roger Fong  <roger_fong@apple.com>
 
         Unreviewed rebaselines. Apple Windows port.
diff --git a/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor-expected.txt b/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor-expected.txt
new file mode 100644 (file)
index 0000000..7d7a5fc
--- /dev/null
@@ -0,0 +1,10 @@
+This tests the constructor for the AutocompleteErrorEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+FAIL no AutocompleteErrorEvent
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor.html b/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor.html
new file mode 100644 (file)
index 0000000..db1cec7
--- /dev/null
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+description("This tests the constructor for the AutocompleteErrorEvent DOM class.");
+
+if (!window.AutocompleteErrorEvent) {
+    testFailed('no AutocompleteErrorEvent');
+    finishJSTest();
+} else {
+    // No initializer is passed.
+    shouldBe("new AutocompleteErrorEvent('eventType').bubbles", "false");
+    shouldBe("new AutocompleteErrorEvent('eventType').cancelable", "false");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType').reason", "");
+
+    // bubbles is passed.
+    shouldBe("new AutocompleteErrorEvent('eventType', { bubbles: false }).bubbles", "false");
+    shouldBe("new AutocompleteErrorEvent('eventType', { bubbles: true }).bubbles", "true");
+
+    // cancelable is passed.
+    shouldBe("new AutocompleteErrorEvent('eventType', { cancelable: false }).cancelable", "false");
+    shouldBe("new AutocompleteErrorEvent('eventType', { cancelable: true }).cancelable", "true");
+
+    // reason is passed.
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: 'doremi' }).reason", "doremi");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: '' }).reason", "");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: undefined }).reason", "undefined");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: null }).reason", "null");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: false }).reason", "false");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: true }).reason", "true");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: 12345 }).reason", "12345");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: 18446744073709551615 }).reason", "18446744073709552000");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: NaN }).reason", "NaN");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: [] }).reason", "");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: [1, 2, 3] }).reason", "1,2,3");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: {doremi: 12345} }).reason", "[object Object]");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: {valueOf: function () { return 'doremi'; } } }).reason", "[object Object]");
+
+    // All initializers are passed.
+    shouldBe("new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: 'doremi' }).bubbles", "true");
+    shouldBe("new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: 'doremi' }).cancelable", "true");
+    shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: 'doremi' }).reason", "doremi");
+}
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 2d7263d..3117bfa 100644 (file)
     // shouldBeTrue("document.createEvent('OrientationEvent') instanceof window.Event");
     // shouldBeTrue("document.createEvent('OrientationEvent').constructor === window.Event");
 
+    // #if ENABLE(REQUEST_AUTOCOMPLETE)
+    // AutocompleteErrorEvent
+    // shouldBeTrue("document.createEvent('AutocompleteErrorEvent') instanceof window.AutocompleteErrorEvent");
+    // shouldBeTrue("document.createEvent('AutocompleteErrorEvent') instanceof window.Event");
+    // shouldBeTrue("document.createEvent('AutocompleteErrorEvent').constructor === window.AutocompleteErrorEvent");
+
 
     // We test both a hard coded set and the automated set below (using enumeration) to ensure that a constructor being removed
     // from the window is caught a regression.
index 066d6d2..77b471b 100644 (file)
@@ -18,6 +18,7 @@ function runTests()
 
     checkDynamicAttributes();
     checkParsedAttributes();
+    checkNonUserGesture();
 }
 
 function checkForEnumerableProperties(form)
@@ -40,6 +41,9 @@ function checkParsedAttributes()
 
     var form = document.forms[0];
     checkForEnumerableProperties(form);
+
+    // Currently Chrome just immediately dispatches an error.
+    form.onautocompleteerror = errorWithReason('disabled');
     form.requestAutocomplete();
 }
 
@@ -51,7 +55,7 @@ function checkDynamicAttributes()
     checkForEnumerableProperties(form);
 
     form.autocomplete = 'off';
-    form.onautocompleteerror = onError;
+    form.onautocompleteerror = errorWithReason('disabled');
     form.requestAutocomplete();
 }
 
@@ -61,7 +65,7 @@ function checkNonUserGesture()
 
     var form = document.createElement('form');
     checkForEnumerableProperties(form);
-    form.onautocompleteerror = onError;
+    form.onautocompleteerror = errorWithReason('disabled');
 
     setTimeout(function()
     {
@@ -69,6 +73,23 @@ function checkNonUserGesture()
     }, 0);
 }
 
+function errorWithReason(reason)
+{
+    return function(event) {
+        if (event instanceof AutocompleteErrorEvent)
+            testPassed('event is an AutocompleteErrorEvent');
+        else
+            testFailed('expected an AutocompleteErrorEvent');
+
+        if (event.reason == reason)
+            testPassed('got expected reason: ' + reason);
+        else
+            testFailed('wrong reason, expected: ' + reason + ', got: ' + event.reason);
+
+        onError();
+    };
+}
+
 function onError()
 {
     numErrors += 1;
index f30924d..1d4e46a 100644 (file)
@@ -9,6 +9,7 @@ description("This tests the length property of constructors.");
 
 shouldBe('ArrayBuffer.length', '1');
 shouldBe('AudioContext.length', '0');
+shouldBe('AutocompleteErrorEvent.length', '2');
 shouldBe('BeforeLoadEvent.length', '2');
 shouldBe('Blob.length', '2');
 shouldBe('CloseEvent.length', '2');
index 43d4336..ae72ca2 100644 (file)
@@ -39,7 +39,8 @@ for (var x in constructorNames) {
         name == "Float32Array" ||
         name == "Float64Array" ||
         name == "FileError" ||
-        name == "FileReader")
+        name == "FileReader" ||
+        name == "AutocompleteErrorEvent")
         continue;
 
     if (name == "XMLDocument")
index 9dbffc9..39127d1 100644 (file)
@@ -5,6 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS ArrayBuffer.length is 1
 FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
+FAIL AutocompleteErrorEvent.length should be 2. Threw exception ReferenceError: Can't find variable: AutocompleteErrorEvent
 PASS BeforeLoadEvent.length is 2
 PASS Blob.length is 2
 PASS CloseEvent.length is 2
diff --git a/LayoutTests/platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt b/LayoutTests/platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt
new file mode 100644 (file)
index 0000000..f799d99
--- /dev/null
@@ -0,0 +1,32 @@
+This tests the constructor for the AutocompleteErrorEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new AutocompleteErrorEvent('eventType').bubbles is false
+PASS new AutocompleteErrorEvent('eventType').cancelable is false
+PASS new AutocompleteErrorEvent('eventType').reason is ""
+PASS new AutocompleteErrorEvent('eventType', { bubbles: false }).bubbles is false
+PASS new AutocompleteErrorEvent('eventType', { bubbles: true }).bubbles is true
+PASS new AutocompleteErrorEvent('eventType', { cancelable: false }).cancelable is false
+PASS new AutocompleteErrorEvent('eventType', { cancelable: true }).cancelable is true
+PASS new AutocompleteErrorEvent('eventType', { reason: 'doremi' }).reason is "doremi"
+PASS new AutocompleteErrorEvent('eventType', { reason: '' }).reason is ""
+PASS new AutocompleteErrorEvent('eventType', { reason: undefined }).reason is "undefined"
+PASS new AutocompleteErrorEvent('eventType', { reason: null }).reason is "null"
+PASS new AutocompleteErrorEvent('eventType', { reason: false }).reason is "false"
+PASS new AutocompleteErrorEvent('eventType', { reason: true }).reason is "true"
+PASS new AutocompleteErrorEvent('eventType', { reason: 12345 }).reason is "12345"
+PASS new AutocompleteErrorEvent('eventType', { reason: 18446744073709551615 }).reason is "18446744073709552000"
+PASS new AutocompleteErrorEvent('eventType', { reason: NaN }).reason is "NaN"
+PASS new AutocompleteErrorEvent('eventType', { reason: [] }).reason is ""
+PASS new AutocompleteErrorEvent('eventType', { reason: [1, 2, 3] }).reason is "1,2,3"
+PASS new AutocompleteErrorEvent('eventType', { reason: {doremi: 12345} }).reason is "[object Object]"
+PASS new AutocompleteErrorEvent('eventType', { reason: {valueOf: function () { return 'doremi'; } } }).reason is "[object Object]"
+PASS new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: 'doremi' }).bubbles is true
+PASS new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: 'doremi' }).cancelable is true
+PASS new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: 'doremi' }).reason is "doremi"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
index 5d19c20..60bfc9e 100644 (file)
@@ -4,7 +4,14 @@ For this test to pass, you should see all PASSED below.
 
 PASS no enumerable properties on HTMLFormElement
 PASS no enumerable properties on HTMLFormElement
-PASS got expected number of error events (2)
+PASS no enumerable properties on HTMLFormElement
+PASS event is an AutocompleteErrorEvent
+PASS got expected reason: disabled
+PASS event is an AutocompleteErrorEvent
+PASS got expected reason: disabled
+PASS event is an AutocompleteErrorEvent
+PASS got expected reason: disabled
+PASS got expected number of error events (3)
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 8d1b7e7..6fc3b33 100644 (file)
@@ -5,6 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 FAIL ArrayBuffer.length should be 1. Was 0.
 FAIL AudioContext.length should be 0. Threw exception ReferenceError: AudioContext is not defined
+FAIL AutocompleteErrorEvent.length should be 2. Was 0.
 FAIL BeforeLoadEvent.length should be 2. Was 0.
 FAIL Blob.length should be 2. Was 0.
 FAIL CloseEvent.length should be 2. Was 0.
index 319d4c2..9628a7b 100644 (file)
@@ -5,6 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS ArrayBuffer.length is 1
 FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
+FAIL AutocompleteErrorEvent.length should be 2. Threw exception ReferenceError: Can't find variable: AutocompleteErrorEvent
 PASS BeforeLoadEvent.length is 2
 PASS Blob.length is 2
 PASS CloseEvent.length is 2
index 319d4c2..9628a7b 100644 (file)
@@ -5,6 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS ArrayBuffer.length is 1
 FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
+FAIL AutocompleteErrorEvent.length should be 2. Threw exception ReferenceError: Can't find variable: AutocompleteErrorEvent
 PASS BeforeLoadEvent.length is 2
 PASS Blob.length is 2
 PASS CloseEvent.length is 2
index 103ef4a..90db111 100644 (file)
@@ -5,6 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS ArrayBuffer.length is 1
 FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
+FAIL AutocompleteErrorEvent.length should be 2. Threw exception ReferenceError: Can't find variable: AutocompleteErrorEvent
 PASS BeforeLoadEvent.length is 2
 PASS Blob.length is 2
 PASS CloseEvent.length is 2
index db07c66..73a669e 100644 (file)
@@ -1,3 +1,31 @@
+2013-01-10  Dan Beam  <dbeam@chromium.org>
+
+        Implement AutocompleteErrorEvent#reason
+        https://bugs.webkit.org/show_bug.cgi?id=105568
+
+        Reviewed by Adam Barth.
+
+        Test: fast/events/constructors/autocomplete-error-event-constructor.html
+
+        * WebCore.gypi: Added AutocompleteErrorEvent.idl and AutocompleteErrorEvent.h for chromium port's build.
+        * dom/AutocompleteErrorEvent.h: Added.
+        (WebCore): Added new type of error named AutocompleteErrorEvent.
+        (AutocompleteErrorEventInit): Added init params for AutocompleteErrorEvents (so initEvent() can be used).
+        (AutocompleteErrorEvent): Added a new error event that inherits from Event but also has a reason for failure.
+        (WebCore::AutocompleteErrorEvent::create): Factory function to create AutocompleteErrorEvents.
+        (WebCore::AutocompleteErrorEvent::reason): The reason why a requestAutocomplete() invocation failed. Can be
+                                                   "disabled", "cancel", or "invalid".
+        (WebCore::AutocompleteErrorEvent::interfaceName): The name of the event's interface (for event.toString()).
+        (WebCore::AutocompleteErrorEvent::AutocompleteErrorEvent): Various ways of constructing the error event.
+        * dom/AutocompleteErrorEvent.idl: Added.
+        * dom/EventNames.in: Added AutocompleteError to this list, based on REQUEST_AUTOCOMPLETE conditional.
+        * html/HTMLFormElement.cpp: Updated form elements to dispatch AutocompleteErrorEvents on errors and to give
+                                    more details (event.reason) when the request fails.
+        (WebCore::HTMLFormElement::requestAutocomplete): Changed to newly added failure type "disabled".
+        (WebCore::HTMLFormElement::finishRequestAutocomplete): Changed
+        * html/HTMLFormElement.h: Added new results (ErrorDisabled, ErrorCancel, ErrorInvalid).
+        * page/DOMWindow.idl: Added global event constructor for new AutocompleteErrorEvent() style event creation.
+
 2013-01-10  Yong Li  <yoli@rim.com>
 
         HTMLMediaElement::resume() should schedule a load rather than load immediately
index 60b09c4..fd0a7e5 100644 (file)
             'css/WebKitCSSTransformValue.idl',
             'css/WebKitCSSViewportRule.idl',
             'dom/Attr.idl',
+            'dom/AutocompleteErrorEvent.idl',
             'dom/BeforeLoadEvent.idl',
             'dom/CDATASection.idl',
             'dom/CharacterData.idl',
             'dom/AncestorChainWalker.cpp',
             'dom/AncestorChainWalker.h',
             'dom/Attr.cpp',
+            'dom/AutocompleteErrorEvent.h',
             'dom/BeforeLoadEvent.h',
             'dom/BeforeTextInsertedEvent.cpp',
             'dom/BeforeTextInsertedEvent.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAudioBuffer.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAudioBufferSourceNode.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAudioBufferSourceNode.h',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAutocompleteErrorEvent.cpp',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAutocompleteErrorEvent.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSChannelMergerNode.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSChannelMergerNode.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSChannelSplitterNode.cpp',
diff --git a/Source/WebCore/dom/AutocompleteErrorEvent.h b/Source/WebCore/dom/AutocompleteErrorEvent.h
new file mode 100644 (file)
index 0000000..7c6b8a5
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AutocompleteErrorEvent_h
+#define AutocompleteErrorEvent_h
+
+#if ENABLE(REQUEST_AUTOCOMPLETE)
+
+#include "Event.h"
+#include "EventNames.h"
+
+namespace WebCore {
+
+struct AutocompleteErrorEventInit : public EventInit {
+    String reason;
+};
+
+class AutocompleteErrorEvent : public Event {
+public:
+    static PassRefPtr<AutocompleteErrorEvent> create()
+    {
+        return adoptRef(new AutocompleteErrorEvent);
+    }
+
+    static PassRefPtr<AutocompleteErrorEvent> create(const String& reason)
+    {
+        return adoptRef(new AutocompleteErrorEvent(reason));
+    }
+
+    static PassRefPtr<AutocompleteErrorEvent> create(const AtomicString& eventType, const AutocompleteErrorEventInit& initializer)
+    {
+        return adoptRef(new AutocompleteErrorEvent(eventType, initializer));
+    }
+
+    const String& reason() const { return m_reason; }
+
+    virtual const AtomicString& interfaceName() const { return eventNames().interfaceForAutocompleteErrorEvent; }
+
+private:
+    AutocompleteErrorEvent()
+    {
+    }
+
+    AutocompleteErrorEvent(const String& reason)
+        : Event(eventNames().autocompleteerrorEvent, false, false)
+        , m_reason(reason)
+    {
+    }
+
+    AutocompleteErrorEvent(const AtomicString& eventType, const AutocompleteErrorEventInit& initializer)
+        : Event(eventType, initializer)
+        , m_reason(initializer.reason)
+    {
+    }
+
+    String m_reason;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(REQUEST_AUTOCOMPLETE)
+
+#endif // AutocompleteErrorEvent_h
diff --git a/Source/WebCore/dom/AutocompleteErrorEvent.idl b/Source/WebCore/dom/AutocompleteErrorEvent.idl
new file mode 100644 (file)
index 0000000..43003e9
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=REQUEST_AUTOCOMPLETE,
+    ConstructorTemplate=Event
+] interface AutocompleteErrorEvent : Event {
+    [InitializedByEventConstructor] readonly attribute DOMString reason;
+};
+
index 3471c07..c1c3b9e 100644 (file)
@@ -50,3 +50,4 @@ DeviceProximityEvent conditional=PROXIMITY_EVENTS
 OrientationEvent interfaceName=Event, conditional=ORIENTATION_EVENTS
 MediaKeyEvent conditional=ENCRYPTED_MEDIA
 TrackEvent conditional=VIDEO_TRACK
+AutocompleteErrorEvent conditional=REQUEST_AUTOCOMPLETE
index 8a83838..de79a70 100644 (file)
@@ -26,6 +26,7 @@
 #include "HTMLFormElement.h"
 
 #include "Attribute.h"
+#include "AutocompleteErrorEvent.h"
 #include "DOMFormData.h"
 #include "DOMWindow.h"
 #include "Document.h"
@@ -399,7 +400,7 @@ void HTMLFormElement::requestAutocomplete()
         return;
 
     if (!shouldAutocomplete() || !ScriptController::processingUserGesture()) {
-        finishRequestAutocomplete(AutocompleteResultError);
+        finishRequestAutocomplete(AutocompleteResultErrorDisabled);
         return;
     }
 
@@ -411,7 +412,18 @@ void HTMLFormElement::requestAutocomplete()
 
 void HTMLFormElement::finishRequestAutocomplete(AutocompleteResult result)
 {
-    RefPtr<Event> event(Event::create(result == AutocompleteResultSuccess ? eventNames().autocompleteEvent : eventNames().autocompleteerrorEvent, false, false));
+    RefPtr<Event> event;
+    if (result == AutocompleteResultSuccess)
+        event = Event::create(eventNames().autocompleteEvent, false, false);
+    else if (result == AutocompleteResultError) // FIXME: Remove when no longer used.
+        event = Event::create(eventNames().autocompleteerrorEvent, false, false);
+    else if (result == AutocompleteResultErrorDisabled)
+        event = AutocompleteErrorEvent::create("disabled");
+    else if (result == AutocompleteResultErrorCancel)
+        event = AutocompleteErrorEvent::create("cancel");
+    else if (result == AutocompleteResultErrorInvalid)
+        event = AutocompleteErrorEvent::create("invalid");
+
     event->setTarget(this);
     m_pendingAutocompleteEvents.append(event.release());
 
index d9c9ab5..2322069 100644 (file)
@@ -99,7 +99,13 @@ public:
     bool checkValidity();
 
 #if ENABLE(REQUEST_AUTOCOMPLETE)
-    enum AutocompleteResult { AutocompleteResultSuccess, AutocompleteResultError };
+    enum AutocompleteResult {
+        AutocompleteResultSuccess,
+        AutocompleteResultError, // FIXME: Remove when no longer used.
+        AutocompleteResultErrorDisabled,
+        AutocompleteResultErrorCancel,
+        AutocompleteResultErrorInvalid,
+    };
 
     void requestAutocomplete();
     void finishRequestAutocomplete(AutocompleteResult);
index c96c725..fc37b20 100644 (file)
     [Conditional=INPUT_SPEECH] attribute SpeechInputEventConstructor SpeechInputEvent;
     [Conditional=WEBGL] attribute WebGLContextEventConstructor WebGLContextEvent;
     [Conditional=PROXIMITY_EVENTS] attribute DeviceProximityEventConstructor DeviceProximityEvent;
+    [Conditional=REQUEST_AUTOCOMPLETE] attribute AutocompleteErrorEventConstructor AutocompleteErrorEvent;
 
     attribute EventExceptionConstructor EventException;
 
index 115937c..59e011c 100644 (file)
@@ -1,3 +1,13 @@
+2013-01-10  Dan Beam  <dbeam@chromium.org>
+
+        Implement AutocompleteErrorEvent#reason
+        https://bugs.webkit.org/show_bug.cgi?id=105568
+
+        Reviewed by Adam Barth.
+
+        * public/WebFormElement.h: Added matching enum values for public chromium WebKit API.
+        * src/AssertMatchingEnums.cpp: Updated compile assert that WebKit and WebCore enums match.
+
 2013-01-10  Adam Barth  <abarth@webkit.org>
 
         Add an ENABLE macro and a WebCore::Setting for the threaded parser
index 27c99d3..0ed5fb6 100644 (file)
@@ -69,7 +69,13 @@ namespace WebKit {
         WEBKIT_EXPORT void getNamedElements(const WebString&, WebVector<WebNode>&);
         WEBKIT_EXPORT void getFormControlElements(WebVector<WebFormControlElement>&) const;
 
-        enum AutocompleteResult { AutocompleteResultSuccess, AutocompleteResultError };
+        enum AutocompleteResult {
+            AutocompleteResultSuccess,
+            AutocompleteResultError, // FIXME: Remove when not used any more.
+            AutocompleteResultErrorDisabled,
+            AutocompleteResultErrorCancel,
+            AutocompleteResultErrorInvalid,
+        };
         WEBKIT_EXPORT void finishRequestAutocomplete(WebFormElement::AutocompleteResult);
 
 #if WEBKIT_IMPLEMENTATION
index abc2fd9..76b0b76 100644 (file)
@@ -628,4 +628,7 @@ COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUseCredentials, MediaPlayer
 #if ENABLE(REQUEST_AUTOCOMPLETE)
 COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultSuccess, HTMLFormElement::AutocompleteResultSuccess);
 COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultError, HTMLFormElement::AutocompleteResultError);
+COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorDisabled, HTMLFormElement::AutocompleteResultErrorDisabled);
+COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorCancel, HTMLFormElement::AutocompleteResultErrorCancel);
+COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorInvalid, HTMLFormElement::AutocompleteResultErrorInvalid);
 #endif