Title: [139372] trunk
Revision
139372
Author
[email protected]
Date
2013-01-10 14:40:15 -0800 (Thu, 10 Jan 2013)

Log Message

Implement AutocompleteErrorEvent#reason
https://bugs.webkit.org/show_bug.cgi?id=105568

Source/WebCore:

Patch by Dan Beam <[email protected]> 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 <[email protected]> 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 <[email protected]> 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139371 => 139372)


--- trunk/LayoutTests/ChangeLog	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/ChangeLog	2013-01-10 22:40:15 UTC (rev 139372)
@@ -1,3 +1,27 @@
+2013-01-10  Dan Beam  <[email protected]>
+
+        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  <[email protected]>
 
         Unreviewed rebaselines. Apple Windows port.

Added: trunk/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor-expected.txt (0 => 139372)


--- trunk/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor-expected.txt	2013-01-10 22:40:15 UTC (rev 139372)
@@ -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
+

Added: trunk/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor.html (0 => 139372)


--- trunk/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/autocomplete-error-event-constructor.html	2013-01-10 22:40:15 UTC (rev 139372)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</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=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/events/event-creation.html (139371 => 139372)


--- trunk/LayoutTests/fast/events/event-creation.html	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/fast/events/event-creation.html	2013-01-10 22:40:15 UTC (rev 139372)
@@ -223,7 +223,13 @@
     // 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.
 

Modified: trunk/LayoutTests/fast/forms/form-request-autocomplete.html (139371 => 139372)


--- trunk/LayoutTests/fast/forms/form-request-autocomplete.html	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/fast/forms/form-request-autocomplete.html	2013-01-10 22:40:15 UTC (rev 139372)
@@ -18,6 +18,7 @@
 
     checkDynamicAttributes();
     checkParsedAttributes();
+    checkNonUserGesture();
 }
 
 function checkForEnumerableProperties(form)
@@ -40,6 +41,9 @@
 
     var form = document.forms[0];
     checkForEnumerableProperties(form);
+
+    // Currently Chrome just immediately dispatches an error.
+    form._onautocompleteerror_ = errorWithReason('disabled');
     form.requestAutocomplete();
 }
 
@@ -51,7 +55,7 @@
     checkForEnumerableProperties(form);
 
     form.autocomplete = 'off';
-    form._onautocompleteerror_ = onError;
+    form._onautocompleteerror_ = errorWithReason('disabled');
     form.requestAutocomplete();
 }
 
@@ -61,7 +65,7 @@
 
     var form = document.createElement('form');
     checkForEnumerableProperties(form);
-    form._onautocompleteerror_ = onError;
+    form._onautocompleteerror_ = errorWithReason('disabled');
 
     setTimeout(function()
     {
@@ -69,6 +73,23 @@
     }, 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;

Modified: trunk/LayoutTests/fast/js/constructor-length.html (139371 => 139372)


--- trunk/LayoutTests/fast/js/constructor-length.html	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/fast/js/constructor-length.html	2013-01-10 22:40:15 UTC (rev 139372)
@@ -9,6 +9,7 @@
 
 shouldBe('ArrayBuffer.length', '1');
 shouldBe('AudioContext.length', '0');
+shouldBe('AutocompleteErrorEvent.length', '2');
 shouldBe('BeforeLoadEvent.length', '2');
 shouldBe('Blob.length', '2');
 shouldBe('CloseEvent.length', '2');

Modified: trunk/LayoutTests/fast/js/script-tests/global-constructors.js (139371 => 139372)


--- trunk/LayoutTests/fast/js/script-tests/global-constructors.js	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/fast/js/script-tests/global-constructors.js	2013-01-10 22:40:15 UTC (rev 139372)
@@ -39,7 +39,8 @@
         name == "Float32Array" ||
         name == "Float64Array" ||
         name == "FileError" ||
-        name == "FileReader")
+        name == "FileReader" ||
+        name == "AutocompleteErrorEvent")
         continue;
 
     if (name == "XMLDocument")

Modified: trunk/LayoutTests/platform/blackberry/fast/js/constructor-length-expected.txt (139371 => 139372)


--- trunk/LayoutTests/platform/blackberry/fast/js/constructor-length-expected.txt	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/platform/blackberry/fast/js/constructor-length-expected.txt	2013-01-10 22:40:15 UTC (rev 139372)
@@ -5,6 +5,7 @@
 
 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

Added: trunk/LayoutTests/platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt (0 => 139372)


--- trunk/LayoutTests/platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt	2013-01-10 22:40:15 UTC (rev 139372)
@@ -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
+

Modified: trunk/LayoutTests/platform/chromium/fast/forms/form-request-autocomplete-expected.txt (139371 => 139372)


--- trunk/LayoutTests/platform/chromium/fast/forms/form-request-autocomplete-expected.txt	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/platform/chromium/fast/forms/form-request-autocomplete-expected.txt	2013-01-10 22:40:15 UTC (rev 139372)
@@ -4,7 +4,14 @@
 
 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

Modified: trunk/LayoutTests/platform/chromium/fast/js/constructor-length-expected.txt (139371 => 139372)


--- trunk/LayoutTests/platform/chromium/fast/js/constructor-length-expected.txt	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/platform/chromium/fast/js/constructor-length-expected.txt	2013-01-10 22:40:15 UTC (rev 139372)
@@ -5,6 +5,7 @@
 
 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.

Modified: trunk/LayoutTests/platform/gtk/fast/js/constructor-length-expected.txt (139371 => 139372)


--- trunk/LayoutTests/platform/gtk/fast/js/constructor-length-expected.txt	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/platform/gtk/fast/js/constructor-length-expected.txt	2013-01-10 22:40:15 UTC (rev 139372)
@@ -5,6 +5,7 @@
 
 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

Modified: trunk/LayoutTests/platform/mac/fast/js/constructor-length-expected.txt (139371 => 139372)


--- trunk/LayoutTests/platform/mac/fast/js/constructor-length-expected.txt	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/platform/mac/fast/js/constructor-length-expected.txt	2013-01-10 22:40:15 UTC (rev 139372)
@@ -5,6 +5,7 @@
 
 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

Modified: trunk/LayoutTests/platform/qt/fast/js/constructor-length-expected.txt (139371 => 139372)


--- trunk/LayoutTests/platform/qt/fast/js/constructor-length-expected.txt	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/LayoutTests/platform/qt/fast/js/constructor-length-expected.txt	2013-01-10 22:40:15 UTC (rev 139372)
@@ -5,6 +5,7 @@
 
 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

Modified: trunk/Source/WebCore/ChangeLog (139371 => 139372)


--- trunk/Source/WebCore/ChangeLog	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebCore/ChangeLog	2013-01-10 22:40:15 UTC (rev 139372)
@@ -1,3 +1,31 @@
+2013-01-10  Dan Beam  <[email protected]>
+
+        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  <[email protected]>
 
         HTMLMediaElement::resume() should schedule a load rather than load immediately

Modified: trunk/Source/WebCore/WebCore.gypi (139371 => 139372)


--- trunk/Source/WebCore/WebCore.gypi	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebCore/WebCore.gypi	2013-01-10 22:40:15 UTC (rev 139372)
@@ -190,6 +190,7 @@
             'css/WebKitCSSTransformValue.idl',
             'css/WebKitCSSViewportRule.idl',
             'dom/Attr.idl',
+            'dom/AutocompleteErrorEvent.idl',
             'dom/BeforeLoadEvent.idl',
             'dom/CDATASection.idl',
             'dom/CharacterData.idl',
@@ -2707,6 +2708,7 @@
             'dom/AncestorChainWalker.cpp',
             'dom/AncestorChainWalker.h',
             'dom/Attr.cpp',
+            'dom/AutocompleteErrorEvent.h',
             'dom/BeforeLoadEvent.h',
             'dom/BeforeTextInsertedEvent.cpp',
             'dom/BeforeTextInsertedEvent.h',
@@ -6078,6 +6080,8 @@
             '<(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',

Added: trunk/Source/WebCore/dom/AutocompleteErrorEvent.h (0 => 139372)


--- trunk/Source/WebCore/dom/AutocompleteErrorEvent.h	                        (rev 0)
+++ trunk/Source/WebCore/dom/AutocompleteErrorEvent.h	2013-01-10 22:40:15 UTC (rev 139372)
@@ -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

Added: trunk/Source/WebCore/dom/AutocompleteErrorEvent.idl (0 => 139372)


--- trunk/Source/WebCore/dom/AutocompleteErrorEvent.idl	                        (rev 0)
+++ trunk/Source/WebCore/dom/AutocompleteErrorEvent.idl	2013-01-10 22:40:15 UTC (rev 139372)
@@ -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;
+};
+

Modified: trunk/Source/WebCore/dom/EventNames.in (139371 => 139372)


--- trunk/Source/WebCore/dom/EventNames.in	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebCore/dom/EventNames.in	2013-01-10 22:40:15 UTC (rev 139372)
@@ -50,3 +50,4 @@
 OrientationEvent interfaceName=Event, conditional=ORIENTATION_EVENTS
 MediaKeyEvent conditional=ENCRYPTED_MEDIA
 TrackEvent conditional=VIDEO_TRACK
+AutocompleteErrorEvent conditional=REQUEST_AUTOCOMPLETE

Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (139371 => 139372)


--- trunk/Source/WebCore/html/HTMLFormElement.cpp	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp	2013-01-10 22:40:15 UTC (rev 139372)
@@ -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 @@
         return;
 
     if (!shouldAutocomplete() || !ScriptController::processingUserGesture()) {
-        finishRequestAutocomplete(AutocompleteResultError);
+        finishRequestAutocomplete(AutocompleteResultErrorDisabled);
         return;
     }
 
@@ -411,7 +412,18 @@
 
 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());
 

Modified: trunk/Source/WebCore/html/HTMLFormElement.h (139371 => 139372)


--- trunk/Source/WebCore/html/HTMLFormElement.h	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebCore/html/HTMLFormElement.h	2013-01-10 22:40:15 UTC (rev 139372)
@@ -99,7 +99,13 @@
     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);

Modified: trunk/Source/WebCore/page/DOMWindow.idl (139371 => 139372)


--- trunk/Source/WebCore/page/DOMWindow.idl	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2013-01-10 22:40:15 UTC (rev 139372)
@@ -563,6 +563,7 @@
     [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;
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (139371 => 139372)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-01-10 22:40:15 UTC (rev 139372)
@@ -1,3 +1,13 @@
+2013-01-10  Dan Beam  <[email protected]>
+
+        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  <[email protected]>
 
         Add an ENABLE macro and a WebCore::Setting for the threaded parser

Modified: trunk/Source/WebKit/chromium/public/WebFormElement.h (139371 => 139372)


--- trunk/Source/WebKit/chromium/public/WebFormElement.h	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebKit/chromium/public/WebFormElement.h	2013-01-10 22:40:15 UTC (rev 139372)
@@ -69,7 +69,13 @@
         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

Modified: trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp (139371 => 139372)


--- trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp	2013-01-10 22:31:48 UTC (rev 139371)
+++ trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp	2013-01-10 22:40:15 UTC (rev 139372)
@@ -628,4 +628,7 @@
 #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
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to