Skip to content

Commit

Permalink
Updating to manually initialize cookie manager on new window open for IE
Browse files Browse the repository at this point in the history
When a new window is requested by the browser, the driver creates
one, but does not set the window handle of the window to a proper
value. This is normally not an issue, but in the edge case where
the user wants to manipulate cookies in the new window, the cookie
manager does not have a window handle set to facilitate the transfer
of cookie information from the driver code to the browser. This
change rectifies that problem.
  • Loading branch information
jimevans committed Sep 10, 2018
1 parent 0e6abdc commit 318257c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
5 changes: 3 additions & 2 deletions cpp/iedriver/DocumentHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ DocumentHost::DocumentHost(HWND hwnd, HWND executor_handle) {
this->browser_id_ = StringUtilities::ToString(cast_guid_string);

::RpcStringFree(&guid_string);

this->window_handle_ = hwnd;
this->executor_handle_ = executor_handle;
this->script_executor_handle_ = NULL;
this->is_closing_ = false;
this->wait_required_ = false;
this->focused_frame_window_ = NULL;
this->cookie_manager_ = new CookieManager();
this->cookie_manager_->Initialize(this->window_handle_);
if (this->window_handle_ != NULL) {
this->cookie_manager_->Initialize(this->window_handle_);
}
}

DocumentHost::~DocumentHost(void) {
Expand Down
11 changes: 8 additions & 3 deletions cpp/iedriver/IECommandExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "BrowserFactory.h"
#include "CommandExecutor.h"
#include "CommandHandlerRepository.h"
#include "CookieManager.h"
#include "Element.h"
#include "ElementFinder.h"
#include "ElementRepository.h"
Expand Down Expand Up @@ -254,7 +255,7 @@ LRESULT IECommandExecutor::OnAfterNewWindow(UINT uMsg,
LOG(TRACE) << "Entering IECommandExecutor::OnAfterNewWindow";
if (wParam > 0) {
LOG(DEBUG) << "Creating thread and reposting message.";
this->CreateDelayPostMessageThread(wParam,
this->CreateDelayPostMessageThread(static_cast<DWORD>(wParam),
this->m_hWnd,
WD_AFTER_NEW_WINDOW);
} else {
Expand Down Expand Up @@ -283,11 +284,15 @@ LRESULT IECommandExecutor::OnBrowserNewWindow(UINT uMsg,
// interface has been marshaled back across the thread boundary to the
// NewWindow3 event handler will the navigation begin, which ensures that
// even the initial navigation will get captured by the proxy, if one is
// set.
// set. Likewise, the cookie manager needs to have its window handle
// properly set to a non-NULL value so that windows messages are routed
// to the correct window.
// N.B. DocumentHost::GetBrowserWindowHandle returns the tab window handle
// for IE 7 and above, and the top-level window for IE6. This is the window
// required for setting the proxy settings.
this->proxy_manager_->SetProxySettings(new_window_wrapper->GetBrowserWindowHandle());
HWND new_window_handle = new_window_wrapper->GetBrowserWindowHandle();
this->proxy_manager_->SetProxySettings(new_window_handle);
new_window_wrapper->cookie_manager()->Initialize(new_window_handle);
this->AddManagedBrowser(new_window_wrapper);
LOG(DEBUG) << "Attempting to marshal interface pointer to requesting thread.";
LPSTREAM* stream = reinterpret_cast<LPSTREAM*>(lParam);
Expand Down
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,14,0,4
PRODUCTVERSION 3,14,0,4
FILEVERSION 3,14,0,5
PRODUCTVERSION 3,14,0,5
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.14.0.4"
VALUE "FileVersion", "3.14.0.5"
VALUE "InternalName", "IEDriver.dll"
VALUE "LegalCopyright", "Copyright (C) 2018"
VALUE "OriginalFilename", "IEDriver.dll"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.14.0.4"
VALUE "ProductVersion", "3.14.0.5"
END
END
BLOCK "VarFileInfo"
Expand Down
10 changes: 10 additions & 0 deletions cpp/iedriverserver/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ 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.14.0.5
=========
* Updated to manually initialize cookie manager on new window open. When
a new window is requested by the browser, the driver creates one, but
does not set the window handle of the window to a proper value. This
is normally not an issue, but in the edge case where the user wants to
manipulate cookies in the new window, the cookie manager does not have
a window handle set to facilitate the transfer of cookie information
from the driver code to the browser. This change rectifies that problem.

v3.14.0.4
=========
* Updated to return 500 for timeouts instead of 408. Some HTTP clients
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,14,0,4
PRODUCTVERSION 3,14,0,4
FILEVERSION 3,14,0,5
PRODUCTVERSION 3,14,0,5
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.14.0.4"
VALUE "FileVersion", "3.14.0.5"
VALUE "InternalName", "IEDriverServer.exe"
VALUE "LegalCopyright", "Copyright (C) 2018"
VALUE "OriginalFilename", "IEDriverServer.exe"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.14.0.4"
VALUE "ProductVersion", "3.14.0.5"
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 318257c

Please sign in to comment.