Skip to content

Commit

Permalink
Again updated Unicode character processing for composition.
Browse files Browse the repository at this point in the history
The previous change in 3.141.5.1 for using composed Unicode character
sequences on send and decomposed on retrieve was disturbingly naive,
and entirely incorrect. This revision mostly reverts that change,
with the difference of checking for "single-character" encoding
sequences when sending. The IE driver will no longer produce the same
input for some key combinations as other drivers (see some Hangul
sequences for concrete examples). The mitigating factor of this
difference in behavior, however, is that the driver should now
produce identical input and output between sending keys and reading
the text via either getting an element's text or its attributes.
Hopefully. There are likely to continue to be corner cases where use
of Unicode characters, does not entirely match up to expectations.
This is particularly so in languages where individual code points can
be combined to form other glyphs semantically or visually identical
to other individual code points.
  • Loading branch information
jimevans committed Jan 29, 2019
1 parent e8d326e commit 086ec3a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 19 deletions.
8 changes: 4 additions & 4 deletions cpp/iedriver/IEDriver.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,141,5,2
PRODUCTVERSION 3,141,5,2
FILEVERSION 3,141,5,3
PRODUCTVERSION 3,141,5,3
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -68,12 +68,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Software Freedom Conservancy"
VALUE "FileDescription", "Driver library for the IE driver"
VALUE "FileVersion", "3.141.5.2"
VALUE "FileVersion", "3.141.5.3"
VALUE "InternalName", "IEDriver.dll"
VALUE "LegalCopyright", "Copyright (C) 2019"
VALUE "OriginalFilename", "IEDriver.dll"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.141.5.2"
VALUE "ProductVersion", "3.141.5.3"
END
END
BLOCK "VarFileInfo"
Expand Down
18 changes: 10 additions & 8 deletions cpp/iedriver/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ int InputManager::KeyDown(BrowserHandle browser_wrapper,
std::string key_value = down_action["value"].asString();
std::wstring key = StringUtilities::ToWString(key_value);

if (!this->IsSingleKey(&key)) {
if (!this->IsSingleKey(key)) {
return EINVALIDARGUMENT;
}

Expand Down Expand Up @@ -585,7 +585,7 @@ int InputManager::KeyUp(BrowserHandle browser_wrapper,
std::string key_value = up_action["value"].asString();
std::wstring key = StringUtilities::ToWString(key_value);

if (!this->IsSingleKey(&key)) {
if (!this->IsSingleKey(key)) {
return EINVALIDARGUMENT;
}

Expand All @@ -596,15 +596,17 @@ int InputManager::KeyUp(BrowserHandle browser_wrapper,
return status_code;
}

bool InputManager::IsSingleKey(std::wstring* input) {
bool InputManager::IsSingleKey(const std::wstring& input) {
bool is_single_key = true;
StringUtilities::ComposeUnicodeString(input);
if (input->size() > 1) {
//StringUtilities::ComposeUnicodeString(input);
std::wstring composed_input = input;
StringUtilities::ComposeUnicodeString(&composed_input);
if (composed_input.size() > 1) {
WORD combining_bitmask = C3_NONSPACING | C3_DIACRITIC | C3_VOWELMARK;
std::vector<WORD> char_types(input->size());
std::vector<WORD> char_types(input.size());
BOOL get_type_success = ::GetStringTypeW(CT_CTYPE3,
input->c_str(),
static_cast<int>(input->size()),
input.c_str(),
static_cast<int>(input.size()),
&char_types[0]);
if (get_type_success) {
bool found_alpha = false;
Expand Down
2 changes: 1 addition & 1 deletion cpp/iedriver/InputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class InputManager {
InputState CloneCurrentInputState(void);
void UpdatePressedKeys(wchar_t character, bool press_key);
bool IsKeyPressed(wchar_t character);
bool IsSingleKey(std::wstring* input);
bool IsSingleKey(const std::wstring& input);

void SetupKeyDescriptions(void);
std::wstring GetKeyDescription(const wchar_t character);
Expand Down
1 change: 0 additions & 1 deletion cpp/iedriver/VariantUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ int VariantUtilities::ConvertVariantToJsonValue(IElementManager* element_manager
std::string string_value = "";
if (variant_value.bstrVal) {
std::wstring bstr_value = variant_value.bstrVal;
StringUtilities::DecomposeUnicodeString(&bstr_value);
string_value = StringUtilities::ToString(bstr_value);
}
*value = string_value;
Expand Down
21 changes: 20 additions & 1 deletion cpp/iedriverserver/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ available via the project downloads page. Changes in "revision" field indicate
private releases checked into the prebuilts directory of the source tree, but
not made generally available on the downloads page.

v3.141.5.3
==========
* Again updated Unicode character processing for composition. The
previous change in 3.141.5.1 for using composed Unicode character
sequences on send and decomposed on retrieve was disturbingly
naive, and entirely incorrect. This revision mostly reverts that
change, with the difference of checking for "single-character"
encoding sequences when sending. The IE driver will no longer
produce the same input for some key combinations as other
drivers (see some Hangul sequences for concrete examples). The
mitigating factor of this difference in behavior, however, is
that the driver should now produce identical input and output
between sending keys and reading the text via either getting an
element's text or its attributes. Hopefully. There are likely
to continue to be corner cases where use of Unicode characters,
does not entirely match up to expectations. This is particularly
so in languages where individual code points can be combined to
form other glyphs identical to other individual code points.

v3.141.5.2
==========
* Enabled create new window command to create tabs. This change
Expand Down Expand Up @@ -52,7 +71,7 @@ v3.141.5.1
the click point calculation was not taking the offset of the top-
left when looking for the in-view center of the element. This change
fixes that issue.
* Updatws Unicode character processing for combining characters. In a
* Updated Unicode character processing for combining characters. In a
previous revision, the IE driver was modified to normalize Unicode
strings that used combining characters to compose a single glyph when
sending keystrokes. This commit implements the reverse of that
Expand Down
8 changes: 4 additions & 4 deletions cpp/iedriverserver/IEDriverServer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,141,5,2
PRODUCTVERSION 3,141,5,2
FILEVERSION 3,141,5,3
PRODUCTVERSION 3,141,5,3
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -68,12 +68,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Software Freedom Conservancy"
VALUE "FileDescription", "Command line server for the IE driver"
VALUE "FileVersion", "3.141.5.2"
VALUE "FileVersion", "3.141.5.3"
VALUE "InternalName", "IEDriverServer.exe"
VALUE "LegalCopyright", "Copyright (C) 2019"
VALUE "OriginalFilename", "IEDriverServer.exe"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.141.5.2"
VALUE "ProductVersion", "3.141.5.3"
END
END
BLOCK "VarFileInfo"
Expand Down
Binary file modified cpp/prebuilt/Win32/Release/IEDriverServer.exe
Binary file not shown.
Binary file modified cpp/prebuilt/x64/Release/IEDriverServer.exe
Binary file not shown.

0 comments on commit 086ec3a

Please sign in to comment.