Commit 6e52713c authored by sukolsak@chromium.org's avatar sukolsak@chromium.org

Catch ERROR_INVALID_WINDOW_HANDLE in the quit chrome script.

In the mini_installer test framework, the script quit_chrome.py quits Chrome by sending a WM_CLOSE message to each window of Chrome. Once we send the message to a window, it's possible that the handles to other windows may become invalid (see buildbot error message http://goo.gl/16VmkX). Fix this by catching ERROR_INVALID_WINDOW_HANDLE.

NOTRY=True
BUG=264859
TEST=
1) Uninstall Chrome (if it's installed.) 
2) Build Chrome with Release mode and make sure that mini_installer.exe is created.
3) Go to src\chrome\test\mini_installer 
4) Edit quit_chrome.py. Add line "hwnd = 12345" before the line "win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)". Add line "print 'ok'" after the line "raise". Then save.
5) Run "python test_installer.py config\config.config --build-dir=<build-dir> --target=Release" where <build-dir> is the path to main build directory (the parent of the Release directory). It should print "ok" repeatedly.

Review URL: https://chromiumcodereview.appspot.com/23498025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222098 0039d316-1c4b-4281-b951-d872f2087c98
parent 513fa26d
...@@ -9,10 +9,12 @@ the process terminates. ...@@ -9,10 +9,12 @@ the process terminates.
""" """
import optparse import optparse
import pywintypes
import sys import sys
import time import time
import win32con import win32con
import win32gui import win32gui
import winerror
import chrome_helper import chrome_helper
...@@ -34,7 +36,12 @@ def CloseWindows(process_path): ...@@ -34,7 +36,12 @@ def CloseWindows(process_path):
return True return True
for hwnd in chrome_helper.GetWindowHandles(process_ids): for hwnd in chrome_helper.GetWindowHandles(process_ids):
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) try:
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
except pywintypes.error as error:
# It's normal that some window handles have become invalid.
if error.args[0] != winerror.ERROR_INVALID_WINDOW_HANDLE:
raise
time.sleep(0) time.sleep(0)
return False return False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment