Bug 31234

Summary: Make tests http/tests/misc/isindex-with-no-form-base-href.html and isindex-with-no-form.html work using DOM keyboard events
Product: WebKit Reporter: Daniel Bates <dbates>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: ahmad.saleem792, andersca, ap, aroben, bdakin, darin, dbates, vicki
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Bug Depends on: 16735    
Bug Blocks:    
Attachments:
Description Flags
Example none

Description Daniel Bates 2009-11-07 19:36:02 PST
Following up from bug #30491, we should make the test cases:
http/tests/misc/isindex-with-no-form-base-href.html
http/tests/misc/isindex-with-no-form.html

work without using DRT's EventSender. Instead, we should rewrite these tests to use DOM keyboard events.
Comment 1 Daniel Bates 2009-11-14 21:52:12 PST
Created attachment 43241 [details]
Example

Example.

Tries to programmatically fire a keypress DOM KeyboardEvent at an HTMLInputElement with keyIdentifier = "Enter" to submit the form (that is, to simulate what equivalent action when the user gives the input focus and then presses the Return/Enter key on the keyboard)
Comment 2 Daniel Bates 2009-11-14 21:52:55 PST
Using a debugger to trace the execution of DOM KeyboardEvents, we need to fix bug #16735 in order to fix this bug.

Running the attachment Example <https://bugs.webkit.org/attachment.cgi?id=43241>, we see that the call flow is as follows (*):

WebCore::jsNodePrototypeFunctionDispatchEvent->EventTarget::dispatchEvent->Node::dispatchEvent->Node::dispatchGenericEvent->HTMLInputElement::defaultEventHandler

By line 1412 of HTMLInputElement.cpp <http://trac.webkit.org/browser/trunk/WebCore/html/HTMLInputElement.cpp?rev=50996#L1412>, we call KeyboardEvent::charCode(). Notice, this KeyboardEvent was generated programmatically by JavaScript (as opposed to a physical key press). Hence, this KeyboardEvent has no associated PlatformKeyboardEvent (i.e. KeyboardEvent::m_keyEvent == null). And by line 138 of KeyboardEvent.cpp <http://trac.webkit.org/browser/trunk/WebCore/dom/KeyboardEvent.cpp?rev=38094#L138> method KeyboardEvent::charCode returns 0 if !KeyboardEvent::m_keyEvent. So, for this example, KeyboardEvent::charCode always returns 0. Therefore, we cannot resolve this bug until we resolve bug #16735.

For completeness, before executing (*), the DOM keyboard event is first instantiated via the following call flow:

WebCore::jsDocumentPrototypeFunctionCreateEvent->Document::createEvent->KeyboardEvent::create->KeyboardEvent::KeyboardEvent()

Note, specifically the constructor KeyboardEvent::KeyboardEvent() is called. Hence, m_keyEvent := 0.

Then, the DOM keyboard event is initialized via the call flow: 

WebCore::jsKeyboardEventPrototypeFunctionInitKeyboardEvent->KeyboardEvent::initKeyboardEvent
Comment 3 Ahmad Saleem 2023-06-03 21:31:16 PDT
'isindex' is removed and now historical.

https://github.com/WebKit/WebKit/commit/c92f223d57abd60e7bc682985a103744f3760672

WPT test showing it as historical - http://wpt.live/html/semantics/forms/historical.html

and both of these tests are now removed (in above commit).

So marking this as 'RESOLVED WONTFIX'.