Skip to content

Commit 8d73e5f

Browse files
committed
Making IE driver SetWindowRect command compliant with spec
1 parent 406b8da commit 8d73e5f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

cpp/iedriver/CommandHandlers/SetWindowRectCommandHandler.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,22 @@ void SetWindowRectCommandHandler::ExecuteInternal(
7171
browser_wrapper->Restore();
7272

7373
HWND window_handle = browser_wrapper->GetTopLevelWindowHandle();
74-
if (x >= 0 && y >= 0) {
75-
BOOL set_window_pos_result = ::SetWindowPos(window_handle, NULL, x, y, 0, 0, SWP_NOSIZE);
76-
if (!set_window_pos_result) {
77-
response->SetErrorResponse(ERROR_UNKNOWN_ERROR,
78-
"Unexpected error setting window size (SetWindowPos API failed)");
79-
return;
80-
}
74+
RECT current_window_rect;
75+
::GetWindowRect(window_handle, &current_window_rect);
76+
if (x < 0 || y < 0) {
77+
x = current_window_rect.left;
78+
y = current_window_rect.top;
79+
}
80+
if (height < 0 || width < 0) {
81+
height = current_window_rect.bottom - current_window_rect.top;
82+
width = current_window_rect.right - current_window_rect.left;
8183
}
8284

83-
if (width >= 0 && height >= 0) {
84-
BOOL set_window_size_result = ::SetWindowPos(window_handle, NULL, 0, 0, width, height, SWP_NOMOVE);
85-
if (!set_window_size_result) {
86-
response->SetErrorResponse(ERROR_UNKNOWN_ERROR,
87-
"Unexpected error setting window size (SetWindowPos API failed)");
88-
return;
89-
}
85+
BOOL set_window_pos_result = ::SetWindowPos(window_handle, NULL, x, y, width, height, 0);
86+
if (!set_window_pos_result) {
87+
response->SetErrorResponse(ERROR_UNKNOWN_ERROR,
88+
"Unexpected error setting window size (SetWindowPos API failed)");
89+
return;
9090
}
9191

9292
HWND browser_window_handle = browser_wrapper->GetTopLevelWindowHandle();
@@ -107,6 +107,9 @@ bool SetWindowRectCommandHandler::GetNumericParameter(
107107
std::string* error_message) {
108108
ParametersMap::const_iterator parameter_iterator = command_parameters.find(argument_name);
109109
if (parameter_iterator != command_parameters.end()) {
110+
if (parameter_iterator->second.isNull()) {
111+
return true;
112+
}
110113
if (!parameter_iterator->second.isNumeric()) {
111114
*error_message = argument_name + " must be a numeric parameter.";
112115
return false;

0 commit comments

Comments
 (0)