Skip to content

Commit 6c807c7

Browse files
committed
Preventing crash in IE driver when attaching to IWebBrowser2 object fails.
1 parent 18a2092 commit 6c807c7

File tree

7 files changed

+5081
-5095
lines changed

7 files changed

+5081
-5095
lines changed

Diff for: cpp/iedriver/BrowserFactory.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,20 @@ bool BrowserFactory::AttachToBrowserUsingShellWindows(
446446
reinterpret_cast<LPARAM>(process_window_info));
447447
if (process_window_info->hwndBrowser != NULL) {
448448
hr = shell_window_variant.pdispVal->QueryInterface<IWebBrowser2>(&browser);
449-
process_window_info->pBrowser = browser.Detach();
449+
if (FAILED(hr)) {
450+
LOGHR(WARN, hr) << "Found browser window using ShellWindows "
451+
<< "API, but QueryInterface for IWebBrowser2 "
452+
<< "failed, so could not attach to the browser.";
453+
} else {
454+
process_window_info->pBrowser = browser.Detach();
455+
}
450456
break;
451457
}
452458
}
453459
}
454460
}
455-
if (process_window_info->hwndBrowser == NULL) {
461+
if (process_window_info->hwndBrowser == NULL ||
462+
process_window_info->pBrowser == NULL) {
456463
::Sleep(250);
457464
}
458465
}
@@ -463,6 +470,11 @@ bool BrowserFactory::AttachToBrowserUsingShellWindows(
463470
this->browser_attach_timeout_);
464471
return false;
465472
}
473+
474+
if (process_window_info->pBrowser == NULL) {
475+
*error_message = ATTACH_FAILURE_ERROR_MESSAGE;
476+
return false;
477+
}
466478
return true;
467479
}
468480

Diff for: cpp/iedriver/BrowserFactory.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#define PROTECTED_MODE_SETTING_ERROR_MESSAGE "Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones."
4343
#define ZOOM_SETTING_ERROR_MESSAGE "Browser zoom level was set to %d%%. It should be set to 100%%"
4444
#define ATTACH_TIMEOUT_ERROR_MESSAGE "Could not find an Internet Explorer window belonging to the process with ID %d within %d milliseconds."
45+
#define ATTACH_FAILURE_ERROR_MESSAGE "Found browser window using ShellWindows API, but could not attach to the browser IWebBrowser2 object."
4546
#define CREATEPROCESS_REGISTRY_ERROR_MESSAGE "Unable to use CreateProcess() API. To use CreateProcess() with Internet Explorer 8 or higher, the value of registry setting in HEKY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main\\TabProcGrowth must be '0'."
4647

4748
#define ZONE_MY_COMPUTER L"0"

Diff for: cpp/iedriver/Generated/atoms.h

+5,060-5,093
Large diffs are not rendered by default.

Diff for: cpp/iedriverserver/CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ 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+
v2.45.0.1
13+
=========
14+
* Updates to JavaScript automation atoms.
15+
* Changed to prevent crash when driver fails to connect to IWebBrowser2
16+
object.
17+
1218
v2.45.0.0
1319
=========
1420
* Release to synchronize with release of Selenium project.

Diff for: cpp/iedriverserver/IEDriverServer.rc

0 Bytes
Binary file not shown.

Diff for: cpp/prebuilt/Win32/Release/IEDriverServer.exe

-21.5 KB
Binary file not shown.

Diff for: cpp/prebuilt/x64/Release/IEDriverServer.exe

-22 KB
Binary file not shown.

0 commit comments

Comments
 (0)