Skip to content

Commit

Permalink
Allow IE to handle supplementary Unicode characters in sendKeys
Browse files Browse the repository at this point in the history
The IE driver lost the ability to check for surrogate pairs after
implementing spec compliance in 3.5. The driver will still convert
the keys being sent using sendKeys from UTF-8 to UTF-16 (Windows
development default for wide strings), but it will now properly
check for supplementary characters by checking for surrogate pairs.
  • Loading branch information
jimevans committed Jan 8, 2019
1 parent a068442 commit 0c442a7
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
14 changes: 14 additions & 0 deletions cpp/iedriver/CommandHandlers/SendKeysCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ Json::Value SendKeysCommandHandler::CreateActionSequencePayload(const IECommandE
for (size_t i = 0; i < keys->size(); ++i) {
std::wstring character = L"";
character.push_back(keys->at(i));
if (IS_HIGH_SURROGATE(keys->at(i))) {
// We've converted the key string to a wstring, which contain
// wchar_t elements. On Windows, wchar_t is 16 bits, meaning
// the string has been encoded to UTF-16, which implies each
// Unicode code point will be either one wchar_t (where the
// value <= 0xFFFF), or two wchar_ts (where the code point is
// represented by a surrogate pair). In the latter case, we
// test for the first part of a surrogate pair, and if it is
// one, we grab the next wchar_t, and use the two together to
// represent a single Unicode "character."
++i;
character.push_back(keys->at(i));
}

std::string single_key = StringUtilities::ToString(character);

if (keys->at(i) == WD_KEY_SHIFT) {
Expand Down
10 changes: 5 additions & 5 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,0,5
PRODUCTVERSION 3,141,0,5
FILEVERSION 3,141,0,6
PRODUCTVERSION 3,141,0,6
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.0.5"
VALUE "FileVersion", "3.141.0.6"
VALUE "InternalName", "IEDriver.dll"
VALUE "LegalCopyright", "Copyright (C) 2018"
VALUE "LegalCopyright", "Copyright (C) 2019"
VALUE "OriginalFilename", "IEDriver.dll"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.141.0.5"
VALUE "ProductVersion", "3.141.0.6"
END
END
BLOCK "VarFileInfo"
Expand Down
14 changes: 14 additions & 0 deletions cpp/iedriverserver/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ 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.0.6
==========
* Modified to allow the driver to handle supplementary Unicode characters
in sendKeys. The IE driver lost the ability to check for surrogate
pairs after implementing spec compliance in 3.5. The driver will still
convert the keys being sent using sendKeys from UTF-8 to UTF-16 (Windows
development default for wide strings), but it will now properly
check for supplementary characters by checking for surrogate pairs.
* Moved normalization of Unicode strings to InputManager. Rather than
normalizing every conversion from UTF-8, it is more correct to only
perform the normalization when using the Unicode strings for keyboard
input. Accordingly, the normalization code is being moved from
StringUtilities to the InputManager class.

v3.141.0.5
==========
* Updated element obscured algorithm to handle shadow DOM polyfills. Shadow
Expand Down
10 changes: 5 additions & 5 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,0,5
PRODUCTVERSION 3,141,0,5
FILEVERSION 3,141,0,6
PRODUCTVERSION 3,141,0,6
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.0.5"
VALUE "FileVersion", "3.141.0.6"
VALUE "InternalName", "IEDriverServer.exe"
VALUE "LegalCopyright", "Copyright (C) 2018"
VALUE "LegalCopyright", "Copyright (C) 2019"
VALUE "OriginalFilename", "IEDriverServer.exe"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.141.0.5"
VALUE "ProductVersion", "3.141.0.6"
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.
1 change: 0 additions & 1 deletion dotnet/test/common/I18Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public void ShouldBeAbleToEnterHebrewTextFromRightToLeft()
}

[Test]
[IgnoreBrowser(Browser.IE, "Driver does not properly handle surrogate pairs for SendKeys")]
[IgnoreBrowser(Browser.Chrome, "ChromeDriver only supports characters in the BMP")]
public void ShouldBeAbleToEnterSupplementaryCharacters()
{
Expand Down

0 comments on commit 0c442a7

Please sign in to comment.