Skip to content

Commit 9120f82

Browse files
committed
Changing 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.
1 parent 7d4b038 commit 9120f82

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

cpp/iedriver/VariantUtilities.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,17 @@ int VariantUtilities::ConvertVariantToJsonValue(IElementManager* element_manager
188188
} else if (VariantIsInteger(variant_value)) {
189189
*value = variant_value.lVal;
190190
} else if (VariantIsDouble(variant_value)) {
191-
*value = variant_value.dblVal;
191+
double int_part;
192+
if (std::modf(variant_value.dblVal, &int_part) == 0.0) {
193+
// This bears some explaining. Due to inconsistencies between versions
194+
// of the JSON serializer we use, if the value is floating-point, but
195+
// has no fractional part, convert it to a 64-bit integer so that it
196+
// will be serialized in a way consistent with language bindings'
197+
// expectations.
198+
*value = static_cast<long long>(int_part);
199+
} else {
200+
*value = variant_value.dblVal;
201+
}
192202
} else if (VariantIsBoolean(variant_value)) {
193203
*value = variant_value.boolVal == VARIANT_TRUE;
194204
} else if (VariantIsEmpty(variant_value)) {

cpp/iedriverserver/CHANGELOG

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ available via the project downloads page. Changes in "revision" field indicate
99
private releases checked into the prebuilts directory of the source tree, but
1010
not made generally available on the downloads page.
1111

12+
v3.11.1.2
13+
=========
14+
* Changed COM variant to JSON serialization in IE. There is an expectation
15+
that if a result from JavaScript is "integral," that it is serialized for
16+
return to the calling code as an integral number rather than a floating-
17+
point number. Previous versions of the JSON serializer used by the IE
18+
driver would (incorrectly) serialize a floating-point value with no
19+
decimal part as being an integer. After updating to a later version, the
20+
serializer now (correctly) serializes floating-point values as floating-
21+
point values, with a trailing ".0" to indicate a floating-point value.
22+
While this is the correct behavior by the serializer, it breaks the
23+
expectations of the language bindings. Therefore, we check to see if the
24+
variant value has a decimal part, and if it has none, convert it to an
25+
integer for serialization by the JSON library.
26+
* Updated JsonCpp library to latest source code. Fixes issue #5664.
27+
1228
v3.11.1.1
1329
=========
1430
* Separated out detection of focusable elements for sendKeys in IE. Allows

cpp/iedriverserver/IEDriverServer.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ END
5050
//
5151

5252
VS_VERSION_INFO VERSIONINFO
53-
FILEVERSION 3,11,1,1
54-
PRODUCTVERSION 3,11,1,1
53+
FILEVERSION 3,11,1,2
54+
PRODUCTVERSION 3,11,1,2
5555
FILEFLAGSMASK 0x3fL
5656
#ifdef _DEBUG
5757
FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
6868
BEGIN
6969
VALUE "CompanyName", "Software Freedom Conservancy"
7070
VALUE "FileDescription", "Command line server for the IE driver"
71-
VALUE "FileVersion", "3.11.1.1"
71+
VALUE "FileVersion", "3.11.1.2"
7272
VALUE "InternalName", "IEDriverServer.exe"
7373
VALUE "LegalCopyright", "Copyright (C) 2017"
7474
VALUE "OriginalFilename", "IEDriverServer.exe"
7575
VALUE "ProductName", "Selenium WebDriver"
76-
VALUE "ProductVersion", "3.11.1.1"
76+
VALUE "ProductVersion", "3.11.1.2"
7777
END
7878
END
7979
BLOCK "VarFileInfo"
40 KB
Binary file not shown.
32.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)