WebKit Bugzilla
Attachment 343357 Details for
Bug 186937
: [Mac] Web Automation: include correct key code with synthesized NSEvents used for keystrokes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186937-20180622125022.patch (text/plain), 5.22 KB, created by
BJ Burg
on 2018-06-22 12:50:22 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
BJ Burg
Created:
2018-06-22 12:50:22 PDT
Size:
5.22 KB
patch
obsolete
>Subversion Revision: 233066 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 956768ff76fb75a900e8bab42b371fc26c4462d3..9492ccb68c4a7a7dc59fbac94a1551be6e1f1abd 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,21 @@ >+2018-06-22 Brian Burg <bburg@apple.com> >+ >+ [Mac] Web Automation: include correct key code with synthesized NSEvents used for keystrokes >+ https://bugs.webkit.org/show_bug.cgi?id=186937 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In some cases, a missing keyCode for an ASCII letter/number can cause synthesized >+ NSEvents to not be converted into a key equivalent action like copy: or paste:. >+ >+ * UIProcess/Automation/mac/WebAutomationSessionMac.mm: >+ Drive by, always initialize keyCode. >+ >+ (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction): >+ (WebKit::keyCodeForCharKey): Compute the keyCode as defined by HLTB headers. >+ This only needs to be computed for characters with physical keys, excluding the >+ number pad and some traditional virtual keys that do not usually have glyphs. >+ > 2018-06-22 Brian Burg <bburg@apple.com> > > [Cocoa] REGRESSION(W3C): actions for key equivalents are not respected >diff --git a/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm b/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm >index 2f2245c4d973917bc7502cdb5a0935068919814f..0e6523a6d75d4a1e41b9bcf06e6bc7e3f4930fd0 100644 >--- a/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm >+++ b/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm >@@ -225,6 +225,145 @@ static bool virtualKeyHasStickyModifier(VirtualKey key) > } > } > >+static int keyCodeForCharKey(CharKey key) >+{ >+ switch (key) { >+ case 'q': >+ case 'Q': >+ return kVK_ANSI_Q; >+ case 'w': >+ case 'W': >+ return kVK_ANSI_W; >+ case 'e': >+ case 'E': >+ return kVK_ANSI_E; >+ case 'r': >+ case 'R': >+ return kVK_ANSI_R; >+ case 't': >+ case 'T': >+ return kVK_ANSI_T; >+ case 'y': >+ case 'Y': >+ return kVK_ANSI_Y; >+ case 'u': >+ case 'U': >+ return kVK_ANSI_U; >+ case 'i': >+ case 'I': >+ return kVK_ANSI_I; >+ case 'o': >+ case 'O': >+ return kVK_ANSI_O; >+ case 'p': >+ case 'P': >+ return kVK_ANSI_P; >+ case 'a': >+ case 'A': >+ return kVK_ANSI_A; >+ case 's': >+ case 'S': >+ return kVK_ANSI_S; >+ case 'd': >+ case 'D': >+ return kVK_ANSI_D; >+ case 'f': >+ case 'F': >+ return kVK_ANSI_F; >+ case 'g': >+ case 'G': >+ return kVK_ANSI_G; >+ case 'h': >+ case 'H': >+ return kVK_ANSI_H; >+ case 'j': >+ case 'J': >+ return kVK_ANSI_J; >+ case 'k': >+ case 'K': >+ return kVK_ANSI_K; >+ case 'l': >+ case 'L': >+ return kVK_ANSI_L; >+ case 'z': >+ case 'Z': >+ return kVK_ANSI_Z; >+ case 'x': >+ case 'X': >+ return kVK_ANSI_X; >+ case 'c': >+ case 'C': >+ return kVK_ANSI_C; >+ case 'v': >+ case 'V': >+ return kVK_ANSI_V; >+ case 'b': >+ case 'B': >+ return kVK_ANSI_B; >+ case 'n': >+ case 'N': >+ return kVK_ANSI_N; >+ case 'm': >+ case 'M': >+ return kVK_ANSI_M; >+ case '1': >+ return kVK_ANSI_1; >+ case '2': >+ return kVK_ANSI_2; >+ case '3': >+ return kVK_ANSI_3; >+ case '4': >+ return kVK_ANSI_4; >+ case '5': >+ return kVK_ANSI_5; >+ case '6': >+ return kVK_ANSI_6; >+ case '7': >+ return kVK_ANSI_7; >+ case '8': >+ return kVK_ANSI_8; >+ case '9': >+ return kVK_ANSI_9; >+ case '0': >+ return kVK_ANSI_0; >+ case '=': >+ case '+': >+ return kVK_ANSI_Equal; >+ case '-': >+ case '_': >+ return kVK_ANSI_Minus; >+ case '[': >+ case '{': >+ return kVK_ANSI_LeftBracket; >+ case ']': >+ case '}': >+ return kVK_ANSI_RightBracket; >+ case '\'': >+ case '"': >+ return kVK_ANSI_Quote; >+ case ';': >+ case ':': >+ return kVK_ANSI_Semicolon; >+ case '\\': >+ case '|': >+ return kVK_ANSI_Backslash; >+ case ',': >+ case '<': >+ return kVK_ANSI_Comma; >+ case '.': >+ case '>': >+ return kVK_ANSI_Period; >+ case '/': >+ case '?': >+ return kVK_ANSI_Slash; >+ case '`': >+ case '~': >+ return kVK_ANSI_Grave; >+ } >+ >+ return 0; >+} >+ > static int keyCodeForVirtualKey(VirtualKey key) > { > // The likely keyCode for the virtual key as defined in <HIToolbox/Events.h>. >@@ -432,7 +571,7 @@ void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& pag > > bool isStickyModifier = false; > NSEventModifierFlags changedModifiers = 0; >- int keyCode; >+ int keyCode = 0; > std::optional<unichar> charCode; > std::optional<unichar> charCodeIgnoringModifiers; > >@@ -445,6 +584,7 @@ void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& pag > charCodeIgnoringModifiers = charCodeIgnoringModifiersForVirtualKey(virtualKey); > }, > [&] (CharKey charKey) { >+ keyCode = keyCodeForCharKey(charKey); > charCode = (unichar)charKey; > charCodeIgnoringModifiers = (unichar)charKey; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186937
:
343357
|
343472
|
343473