Bug 864940 - Only hand off focus rights to explorer if the test console has focus. r=bbondy
authorJim Mathies <jmathies@mozilla.com>
Thu, 09 May 2013 13:37:41 -0500
changeset 138195 f8c1e234d93963af00e65f79bd44048026029ccb
parent 138194 10cb7bc4cc588dc7e2a9956a29ec50732402663e
child 138196 ed91d4356cf07f0a1edd75d59d78237b0457fbaa
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs864940
milestone23.0a1
Bug 864940 - Only hand off focus rights to explorer if the test console has focus. r=bbondy
browser/metro/shell/testing/metrotestharness.cpp
--- a/browser/metro/shell/testing/metrotestharness.cpp
+++ b/browser/metro/shell/testing/metrotestharness.cpp
@@ -214,22 +214,25 @@ static bool Launch()
   WCHAR appModelID[256];
   // Activation is based on the browser's registered app model id
   if (!GetDefaultBrowserAppModelID(appModelID, (sizeof(appModelID)/sizeof(WCHAR)))) {
     Fail(L"GetDefaultBrowserAppModelID failed.");
     return false;
   }
   Log(L"App model id='%s'", appModelID);
 
-  // Hand off focus rights to the out-of-process activation server. Without
-  // this the metro interface won't launch.
-  hr = CoAllowSetForegroundWindow(activateMgr, NULL);
-  if (FAILED(hr)) {
-    Fail(L"CoAllowSetForegroundWindow result %X", hr);
-    return false;
+  // Hand off focus rights if the terminal has focus to the out-of-process
+  // activation server (explorer.exe). Without this the metro interface
+  // won't launch.
+  if (GetForegroundWindow() == GetConsoleWindow()) {
+    hr = CoAllowSetForegroundWindow(activateMgr, NULL);
+    if (FAILED(hr)) {
+      Fail(L"CoAllowSetForegroundWindow result %X", hr);
+      return false;
+    }
   }
 
   Log(L"Harness process id: %d", GetCurrentProcessId());
 
   // Because we can't pass command line args, we store params in a
   // tests.ini file in dist/bin which the browser picks up on launch.
   CStringA testFilePath;
   if (sFirefoxPath.GetLength()) {