Skip to content

Commit

Permalink
Changing COM variant to JSON serialization in IE
Browse files Browse the repository at this point in the history
There is an expectation that if a result from JavaScript is "integral,"
that it is serialized for return to the calling code as an integral
number rather than a floating-point number. Previous versions of the
JSON serializer used by the IE driver would (incorrectly) serialize a
floating-point value with no decimal part as being an integer. After
updating to a later version, the serializer now (correctly) serializes
floating-point values as floating-point values, with a trailing ".0" to
indicate a floating - point value. While this is the correct behavior
by the serializer, it breaks the expectations of the language bindings.
Therefore, we check to see if the variant value has a decimal part, and
if it has none, convert it to an integer for serialization by the JSON
library.
  • Loading branch information
jimevans committed Mar 22, 2018
1 parent 7d4b038 commit 9120f82
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
12 changes: 11 additions & 1 deletion cpp/iedriver/VariantUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,17 @@ int VariantUtilities::ConvertVariantToJsonValue(IElementManager* element_manager
} else if (VariantIsInteger(variant_value)) {
*value = variant_value.lVal;
} else if (VariantIsDouble(variant_value)) {
*value = variant_value.dblVal;
double int_part;
if (std::modf(variant_value.dblVal, &int_part) == 0.0) {
// This bears some explaining. Due to inconsistencies between versions
// of the JSON serializer we use, if the value is floating-point, but
// has no fractional part, convert it to a 64-bit integer so that it
// will be serialized in a way consistent with language bindings'
// expectations.
*value = static_cast<long long>(int_part);
} else {
*value = variant_value.dblVal;
}
} else if (VariantIsBoolean(variant_value)) {
*value = variant_value.boolVal == VARIANT_TRUE;
} else if (VariantIsEmpty(variant_value)) {
Expand Down
16 changes: 16 additions & 0 deletions cpp/iedriverserver/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ 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.11.1.2
=========
* Changed COM variant to JSON serialization in IE. There is an expectation
that if a result from JavaScript is "integral," that it is serialized for
return to the calling code as an integral number rather than a floating-
point number. Previous versions of the JSON serializer used by the IE
driver would (incorrectly) serialize a floating-point value with no
decimal part as being an integer. After updating to a later version, the
serializer now (correctly) serializes floating-point values as floating-
point values, with a trailing ".0" to indicate a floating-point value.
While this is the correct behavior by the serializer, it breaks the
expectations of the language bindings. Therefore, we check to see if the
variant value has a decimal part, and if it has none, convert it to an
integer for serialization by the JSON library.
* Updated JsonCpp library to latest source code. Fixes issue #5664.

v3.11.1.1
=========
* Separated out detection of focusable elements for sendKeys in IE. Allows
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,11,1,1
PRODUCTVERSION 3,11,1,1
FILEVERSION 3,11,1,2
PRODUCTVERSION 3,11,1,2
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.11.1.1"
VALUE "FileVersion", "3.11.1.2"
VALUE "InternalName", "IEDriverServer.exe"
VALUE "LegalCopyright", "Copyright (C) 2017"
VALUE "OriginalFilename", "IEDriverServer.exe"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.11.1.1"
VALUE "ProductVersion", "3.11.1.2"
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 9120f82

Please sign in to comment.