Changeset 139372 in webkit


Ignore:
Timestamp:
Jan 10, 2013 2:40:15 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Implement AutocompleteErrorEvent#reason
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.
Location:
trunk
Files:
5 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139370 r139372  
     12013-01-10  Dan Beam  <dbeam@chromium.org>
     2
     3        Implement AutocompleteErrorEvent#reason
     4        https://bugs.webkit.org/show_bug.cgi?id=105568
     5
     6        Added tests to verify event creation and global event constructor existence of AutocompleteErrorEvent
     7        and updated the existing tests to make sure errors received are of the right type and have the right reason.
     8
     9        Reviewed by Adam Barth.
     10
     11        * fast/events/constructors/autocomplete-error-event-constructor-expected.txt: Added.
     12        * fast/events/constructors/autocomplete-error-event-constructor.html: Added.
     13        * fast/events/event-creation.html: Added new AutocompleteErrorEvent() test case.
     14        * fast/forms/form-request-autocomplete.html: Updated 'autocompleteerror' listeners to check event.reason.
     15        * fast/js/constructor-length.html: Added AutocompleteErrorEvent to list.
     16        * fast/js/script-tests/global-constructors.js: Added AutocompleteErrorEvent to list.
     17        * platform/blackberry/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
     18        * platform/chromium/fast/events/constructors/autocomplete-error-event-constructor-expected.txt: Added.
     19        * platform/chromium/fast/forms/form-request-autocomplete-expected.txt: Updated passing expectations.
     20        * platform/chromium/fast/js/constructor-length-expected.txt: Added expected 0 length result.
     21        * platform/gtk/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
     22        * platform/mac/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
     23        * platform/qt/fast/js/constructor-length-expected.txt: Added expected ReferenceError.
     24
    1252013-01-10  Roger Fong  <roger_fong@apple.com>
    226
  • trunk/LayoutTests/fast/events/event-creation.html

    r121234 r139372  
    223223    // shouldBeTrue("document.createEvent('OrientationEvent') instanceof window.Event");
    224224    // shouldBeTrue("document.createEvent('OrientationEvent').constructor === window.Event");
     225
     226    // #if ENABLE(REQUEST_AUTOCOMPLETE)
     227    // AutocompleteErrorEvent
     228    // shouldBeTrue("document.createEvent('AutocompleteErrorEvent') instanceof window.AutocompleteErrorEvent");
     229    // shouldBeTrue("document.createEvent('AutocompleteErrorEvent') instanceof window.Event");
     230    // shouldBeTrue("document.createEvent('AutocompleteErrorEvent').constructor === window.AutocompleteErrorEvent");
    225231
    226232
  • trunk/LayoutTests/fast/forms/form-request-autocomplete.html

    r136800 r139372  
    1919    checkDynamicAttributes();
    2020    checkParsedAttributes();
     21    checkNonUserGesture();
    2122}
    2223
     
    4142    var form = document.forms[0];
    4243    checkForEnumerableProperties(form);
     44
     45    // Currently Chrome just immediately dispatches an error.
     46    form.onautocompleteerror = errorWithReason('disabled');
    4347    form.requestAutocomplete();
    4448}
     
    5256
    5357    form.autocomplete = 'off';
    54     form.onautocompleteerror = onError;
     58    form.onautocompleteerror = errorWithReason('disabled');
    5559    form.requestAutocomplete();
    5660}
     
    6266    var form = document.createElement('form');
    6367    checkForEnumerableProperties(form);
    64     form.onautocompleteerror = onError;
     68    form.onautocompleteerror = errorWithReason('disabled');
    6569
    6670    setTimeout(function()
     
    6872        form.requestAutocomplete();
    6973    }, 0);
     74}
     75
     76function errorWithReason(reason)
     77{
     78    return function(event) {
     79        if (event instanceof AutocompleteErrorEvent)
     80            testPassed('event is an AutocompleteErrorEvent');
     81        else
     82            testFailed('expected an AutocompleteErrorEvent');
     83
     84        if (event.reason == reason)
     85            testPassed('got expected reason: ' + reason);
     86        else
     87            testFailed('wrong reason, expected: ' + reason + ', got: ' + event.reason);
     88
     89        onError();
     90    };
    7091}
    7192
  • trunk/LayoutTests/fast/js/constructor-length.html

    r138354 r139372  
    1010shouldBe('ArrayBuffer.length', '1');
    1111shouldBe('AudioContext.length', '0');
     12shouldBe('AutocompleteErrorEvent.length', '2');
    1213shouldBe('BeforeLoadEvent.length', '2');
    1314shouldBe('Blob.length', '2');
  • trunk/LayoutTests/fast/js/script-tests/global-constructors.js

    r130343 r139372  
    4040        name == "Float64Array" ||
    4141        name == "FileError" ||
    42         name == "FileReader")
     42        name == "FileReader" ||
     43        name == "AutocompleteErrorEvent")
    4344        continue;
    4445
  • trunk/LayoutTests/platform/blackberry/fast/js/constructor-length-expected.txt

    r138354 r139372  
    66PASS ArrayBuffer.length is 1
    77FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
     8FAIL AutocompleteErrorEvent.length should be 2. Threw exception ReferenceError: Can't find variable: AutocompleteErrorEvent
    89PASS BeforeLoadEvent.length is 2
    910PASS Blob.length is 2
  • trunk/LayoutTests/platform/chromium/fast/forms/form-request-autocomplete-expected.txt

    r133720 r139372  
    55PASS no enumerable properties on HTMLFormElement
    66PASS no enumerable properties on HTMLFormElement
    7 PASS got expected number of error events (2)
     7PASS no enumerable properties on HTMLFormElement
     8PASS event is an AutocompleteErrorEvent
     9PASS got expected reason: disabled
     10PASS event is an AutocompleteErrorEvent
     11PASS got expected reason: disabled
     12PASS event is an AutocompleteErrorEvent
     13PASS got expected reason: disabled
     14PASS got expected number of error events (3)
    815PASS successfullyParsed is true
    916
  • trunk/LayoutTests/platform/chromium/fast/js/constructor-length-expected.txt

    r138354 r139372  
    66FAIL ArrayBuffer.length should be 1. Was 0.
    77FAIL AudioContext.length should be 0. Threw exception ReferenceError: AudioContext is not defined
     8FAIL AutocompleteErrorEvent.length should be 2. Was 0.
    89FAIL BeforeLoadEvent.length should be 2. Was 0.
    910FAIL Blob.length should be 2. Was 0.
  • trunk/LayoutTests/platform/gtk/fast/js/constructor-length-expected.txt

    r138354 r139372  
    66PASS ArrayBuffer.length is 1
    77FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
     8FAIL AutocompleteErrorEvent.length should be 2. Threw exception ReferenceError: Can't find variable: AutocompleteErrorEvent
    89PASS BeforeLoadEvent.length is 2
    910PASS Blob.length is 2
  • trunk/LayoutTests/platform/mac/fast/js/constructor-length-expected.txt

    r138354 r139372  
    66PASS ArrayBuffer.length is 1
    77FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
     8FAIL AutocompleteErrorEvent.length should be 2. Threw exception ReferenceError: Can't find variable: AutocompleteErrorEvent
    89PASS BeforeLoadEvent.length is 2
    910PASS Blob.length is 2
  • trunk/LayoutTests/platform/qt/fast/js/constructor-length-expected.txt

    r138354 r139372  
    66PASS ArrayBuffer.length is 1
    77FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
     8FAIL AutocompleteErrorEvent.length should be 2. Threw exception ReferenceError: Can't find variable: AutocompleteErrorEvent
    89PASS BeforeLoadEvent.length is 2
    910PASS Blob.length is 2
  • trunk/Source/WebCore/ChangeLog

    r139371 r139372  
     12013-01-10  Dan Beam  <dbeam@chromium.org>
     2
     3        Implement AutocompleteErrorEvent#reason
     4        https://bugs.webkit.org/show_bug.cgi?id=105568
     5
     6        Reviewed by Adam Barth.
     7
     8        Test: fast/events/constructors/autocomplete-error-event-constructor.html
     9
     10        * WebCore.gypi: Added AutocompleteErrorEvent.idl and AutocompleteErrorEvent.h for chromium port's build.
     11        * dom/AutocompleteErrorEvent.h: Added.
     12        (WebCore): Added new type of error named AutocompleteErrorEvent.
     13        (AutocompleteErrorEventInit): Added init params for AutocompleteErrorEvents (so initEvent() can be used).
     14        (AutocompleteErrorEvent): Added a new error event that inherits from Event but also has a reason for failure.
     15        (WebCore::AutocompleteErrorEvent::create): Factory function to create AutocompleteErrorEvents.
     16        (WebCore::AutocompleteErrorEvent::reason): The reason why a requestAutocomplete() invocation failed. Can be
     17                                                   "disabled", "cancel", or "invalid".
     18        (WebCore::AutocompleteErrorEvent::interfaceName): The name of the event's interface (for event.toString()).
     19        (WebCore::AutocompleteErrorEvent::AutocompleteErrorEvent): Various ways of constructing the error event.
     20        * dom/AutocompleteErrorEvent.idl: Added.
     21        * dom/EventNames.in: Added AutocompleteError to this list, based on REQUEST_AUTOCOMPLETE conditional.
     22        * html/HTMLFormElement.cpp: Updated form elements to dispatch AutocompleteErrorEvents on errors and to give
     23                                    more details (event.reason) when the request fails.
     24        (WebCore::HTMLFormElement::requestAutocomplete): Changed to newly added failure type "disabled".
     25        (WebCore::HTMLFormElement::finishRequestAutocomplete): Changed
     26        * html/HTMLFormElement.h: Added new results (ErrorDisabled, ErrorCancel, ErrorInvalid).
     27        * page/DOMWindow.idl: Added global event constructor for new AutocompleteErrorEvent() style event creation.
     28
    1292013-01-10  Yong Li  <yoli@rim.com>
    230
  • trunk/Source/WebCore/WebCore.gypi

    r139325 r139372  
    191191            'css/WebKitCSSViewportRule.idl',
    192192            'dom/Attr.idl',
     193            'dom/AutocompleteErrorEvent.idl',
    193194            'dom/BeforeLoadEvent.idl',
    194195            'dom/CDATASection.idl',
     
    27082709            'dom/AncestorChainWalker.h',
    27092710            'dom/Attr.cpp',
     2711            'dom/AutocompleteErrorEvent.h',
    27102712            'dom/BeforeLoadEvent.h',
    27112713            'dom/BeforeTextInsertedEvent.cpp',
     
    60796081            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAudioBufferSourceNode.cpp',
    60806082            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAudioBufferSourceNode.h',
     6083            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAutocompleteErrorEvent.cpp',
     6084            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSAutocompleteErrorEvent.h',
    60816085            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSChannelMergerNode.cpp',
    60826086            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSChannelMergerNode.h',
  • trunk/Source/WebCore/dom/EventNames.in

    r131372 r139372  
    5151MediaKeyEvent conditional=ENCRYPTED_MEDIA
    5252TrackEvent conditional=VIDEO_TRACK
     53AutocompleteErrorEvent conditional=REQUEST_AUTOCOMPLETE
  • trunk/Source/WebCore/html/HTMLFormElement.cpp

    r137406 r139372  
    2727
    2828#include "Attribute.h"
     29#include "AutocompleteErrorEvent.h"
    2930#include "DOMFormData.h"
    3031#include "DOMWindow.h"
     
    400401
    401402    if (!shouldAutocomplete() || !ScriptController::processingUserGesture()) {
    402         finishRequestAutocomplete(AutocompleteResultError);
     403        finishRequestAutocomplete(AutocompleteResultErrorDisabled);
    403404        return;
    404405    }
     
    412413void HTMLFormElement::finishRequestAutocomplete(AutocompleteResult result)
    413414{
    414     RefPtr<Event> event(Event::create(result == AutocompleteResultSuccess ? eventNames().autocompleteEvent : eventNames().autocompleteerrorEvent, false, false));
     415    RefPtr<Event> event;
     416    if (result == AutocompleteResultSuccess)
     417        event = Event::create(eventNames().autocompleteEvent, false, false);
     418    else if (result == AutocompleteResultError) // FIXME: Remove when no longer used.
     419        event = Event::create(eventNames().autocompleteerrorEvent, false, false);
     420    else if (result == AutocompleteResultErrorDisabled)
     421        event = AutocompleteErrorEvent::create("disabled");
     422    else if (result == AutocompleteResultErrorCancel)
     423        event = AutocompleteErrorEvent::create("cancel");
     424    else if (result == AutocompleteResultErrorInvalid)
     425        event = AutocompleteErrorEvent::create("invalid");
     426
    415427    event->setTarget(this);
    416428    m_pendingAutocompleteEvents.append(event.release());
  • trunk/Source/WebCore/html/HTMLFormElement.h

    r135093 r139372  
    100100
    101101#if ENABLE(REQUEST_AUTOCOMPLETE)
    102     enum AutocompleteResult { AutocompleteResultSuccess, AutocompleteResultError };
     102    enum AutocompleteResult {
     103        AutocompleteResultSuccess,
     104        AutocompleteResultError, // FIXME: Remove when no longer used.
     105        AutocompleteResultErrorDisabled,
     106        AutocompleteResultErrorCancel,
     107        AutocompleteResultErrorInvalid,
     108    };
    103109
    104110    void requestAutocomplete();
  • trunk/Source/WebCore/page/DOMWindow.idl

    r138843 r139372  
    564564    [Conditional=WEBGL] attribute WebGLContextEventConstructor WebGLContextEvent;
    565565    [Conditional=PROXIMITY_EVENTS] attribute DeviceProximityEventConstructor DeviceProximityEvent;
     566    [Conditional=REQUEST_AUTOCOMPLETE] attribute AutocompleteErrorEventConstructor AutocompleteErrorEvent;
    566567
    567568    attribute EventExceptionConstructor EventException;
  • trunk/Source/WebKit/chromium/ChangeLog

    r139367 r139372  
     12013-01-10  Dan Beam  <dbeam@chromium.org>
     2
     3        Implement AutocompleteErrorEvent#reason
     4        https://bugs.webkit.org/show_bug.cgi?id=105568
     5
     6        Reviewed by Adam Barth.
     7
     8        * public/WebFormElement.h: Added matching enum values for public chromium WebKit API.
     9        * src/AssertMatchingEnums.cpp: Updated compile assert that WebKit and WebCore enums match.
     10
    1112013-01-10  Adam Barth  <abarth@webkit.org>
    212
  • trunk/Source/WebKit/chromium/public/WebFormElement.h

    r139323 r139372  
    7070        WEBKIT_EXPORT void getFormControlElements(WebVector<WebFormControlElement>&) const;
    7171
    72         enum AutocompleteResult { AutocompleteResultSuccess, AutocompleteResultError };
     72        enum AutocompleteResult {
     73            AutocompleteResultSuccess,
     74            AutocompleteResultError, // FIXME: Remove when not used any more.
     75            AutocompleteResultErrorDisabled,
     76            AutocompleteResultErrorCancel,
     77            AutocompleteResultErrorInvalid,
     78        };
    7379        WEBKIT_EXPORT void finishRequestAutocomplete(WebFormElement::AutocompleteResult);
    7480
  • trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp

    r138738 r139372  
    629629COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultSuccess, HTMLFormElement::AutocompleteResultSuccess);
    630630COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultError, HTMLFormElement::AutocompleteResultError);
    631 #endif
     631COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorDisabled, HTMLFormElement::AutocompleteResultErrorDisabled);
     632COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorCancel, HTMLFormElement::AutocompleteResultErrorCancel);
     633COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorInvalid, HTMLFormElement::AutocompleteResultErrorInvalid);
     634#endif
Note: See TracChangeset for help on using the changeset viewer.