/// <summary> /// AppMonitorLoader Main Method for STi consumption, direct-application-launching version /// </summary> /// <param name="commandline">Arguments to AppMonitor loader, either a config file or original format</param> public static void RunApplication(string commandline) { ProcessStartInfo pInfo = ProcessArgs(commandline); DictionaryStore.StartServer(); ApplicationMonitor appMon = new ApplicationMonitor(); // if we're launching a ClickOnce application, clean the cache // Since this method precludes remote deployment and our enlistment should build properly signed manifests, there's no need to update / resign the manifests. if (pInfo.FileName.ToLowerInvariant().EndsWith(ApplicationDeploymentHelper.STANDALONE_APPLICATION_EXTENSION) || pInfo.FileName.ToLowerInvariant().EndsWith(ApplicationDeploymentHelper.BROWSER_APPLICATION_EXTENSION)) { ApplicationDeploymentHelper.CleanClickOnceCache(); } // shell exec the app appMon.StartProcess(pInfo); // Some Xbap tests exit early unless we add PresentationHost.exe as a monitored process. Has to happen after StartProcess. // Timing is not an issue, since this is simply adding a string to a List, so will execute orders of magnitude faster than actually starting any Xbap. if (pInfo.FileName.ToLowerInvariant().EndsWith(ApplicationDeploymentHelper.BROWSER_APPLICATION_EXTENSION)) { appMon.MonitorProcess("PresentationHost.exe"); } appMon.WaitForUIHandlerAbort(); CloseCurrentVariationIfOneExists(); appMon.Close(); }
public static AutomationElement GetErrorDetails(AutomationElement moreInfoButton) { // Getting to the error details text box: It's a child of the More Info button's parent. // (IEWindow has many text boxes, so the search must be limited.) AutomationElement elem = TreeWalker.RawViewWalker.GetParent(moreInfoButton); AutomationElement errorDetailsElem = null; // In IE8, the UIA element for the error page switched from Edit-> Text // Unfortunately there are lots of ControlType.Texts here, so find the 2nd one with a value pattern. if (ApplicationDeploymentHelper.GetIEVersion() >= 8) { AutomationElementCollection collection = elem.FindAll(TreeScope.Descendants, new AndCondition( new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text), new PropertyCondition(AutomationElement.IsValuePatternAvailableProperty, true))); if (collection.Count >= 2) { errorDetailsElem = collection[1]; } } else { errorDetailsElem = elem.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); } return(errorDetailsElem); }
private void LoadResources(string applicationName) { string[] viewItems = new string[serverList.Count + 1]; foreach (string resourceName in ApplicationDeploymentHelper.GetResources(applicationName, GlobalProperties.MgmtDBName, GlobalProperties.MgmtDBServer)) { viewItems[0] = resourceName; for (int i = 1; i < listViewResources.Columns.Count; i++) { viewItems[i] = "";// listView1.Columns[i].Text; } ListViewItem listViewItem = new ListViewItem(viewItems); listViewItem.UseItemStyleForSubItems = false; listViewResources.Items.Add(listViewItem); } }
/// <summary> /// Start Host /// </summary> /// <param name="startupUri"></param> public void StartHost(string startupUri) { if (monitor != null) { throw new InvalidOperationException("You must first Close the Host before calling StartHost again."); } DictionaryStore.StartServer(); //use a custom startup page if (!string.IsNullOrEmpty(startupUri)) { DictionaryStore.Current[UiaDistributedTestcaseHost.StartupUriId] = startupUri; } monitor = new ApplicationMonitor(); GetHwndUIHandler handler = new GetHwndUIHandler(); // register for iexplore and have your app set the title monitor.RegisterUIHandler(handler, "iexplore", "RegExp:(Ready)", UIHandlerNotification.TitleChanged); //Clear the Click Once cache so the app is always re-activated ApplicationDeploymentHelper.CleanClickOnceCache(); //run the app monitor.StartProcess(xbapFileName); //wait for the UIHandler to return abort or timeout in 90 seconds if (!monitor.WaitForUIHandlerAbort(90000) || handler.topLevelhWnd == IntPtr.Zero) { throw new TimeoutException("A timeout occured while waiting for the XamlBrowserHost to navigate to the startUpPage"); } // monitor.StopMonitoring(); //Get the remoteHost object // //if we timedout then let the caller know that the app is not hosting this object //if (remoteHost == null) // throw new InvalidOperationException("The launched application did not create a host object in the Harness remote site"); //set the host hwnd hWndHost = handler.topLevelhWnd; }
public override UIHandlerAction HandleWindow(IntPtr topLevelhWnd, IntPtr hwnd, System.Diagnostics.Process process, string title, UIHandlerNotification notification) { // Sleep for a bit. Takes a bit longer for window to be ready in Longhorn. Thread.Sleep(800); // Get a reference to the IE window... GlobalLog.LogDebug("Finding IE window"); AutomationElement ieWindow = AutomationElement.FromHandle(topLevelhWnd); if (ApplicationDeploymentHelper.GetIEVersion() >= 8) { GlobalLog.LogDebug("IE8+ present, using IWebBrowser2 Navigate() for reliability"); Thread.Sleep(3000); // Other approaches are fine until they meet LCIE. // IF this proves to be 100% reliable, this could be the only implementation. IENavigationHelper.NavigateInternetExplorer(uriToNavigate.ToString(), process.MainWindowHandle); } else { NavigateIEWindow(ieWindow, uriToNavigate); } return(UIHandlerAction.Unhandled); }
private void InitProcessMonitor(ProcessStartInfo startInfo) { //Reset the Abort signal and register it with the remoted harness abortSignal.Reset(); // Remember the arguments so tests can get to them easily // NOTE: startInfo may be null if we are monitoring without starting a process // If there are already values under ApplicationMonitorArguments, leave them and do nothing. if ((startInfo != null) && !string.IsNullOrEmpty(startInfo.Arguments) && string.IsNullOrEmpty(DictionaryStore.Current["ApplicationMonitorArguments"])) { DictionaryStore.Current["ApplicationMonitorArguments"] = startInfo.Arguments; } //Create the ProcessMonitor processMonitor = new ProcessMonitor(); processMonitor.ProcessExited += new ProcessExitedHandler(OnProcessExited); processMonitor.ProcessFound += new ProcessFoundHandler(OnProcessFound); processMonitor.VisibleWindowFound += new VisibleWindowHandler(OnVisibleWindowFound); processMonitor.VisibleWindowTitleChanged += new VisibleWindowHandler(OnVisibleWindowTitleChanged); //Monitor the Processes that the DeploymentHelper says are important in deployment processesToMonitor = ApplicationDeploymentHelper.GetProcessesToMonitor(startInfo); foreach (ProcessMonitorInfo processInfo in processesToMonitor) { processMonitor.AddProcess(processInfo.Name); } //Add Processes to be monitored that are described in the handler rules foreach (UIHandlerRule rule in handlerRules) { if (rule.ProcessName != null) { processMonitor.AddProcess(rule.ProcessName); } } }
/// <summary> /// Performs the Activation step /// </summary> /// <returns>returns true if the rest of the steps should be executed, otherwise, false</returns> protected override bool BeginStep() { //Create ApplicationMonitor appMonitor = new ApplicationMonitor(); // If defined, set a value in property bag. Used for communication test variations to target app if (PropertyBagValue != "") { // Update this code to allow > 1 prop bag values being set at once string[] values = PropertyBagValue.Trim().Split('='); if (values.Length == 2) { DictionaryStore.Current[values[0].Trim()] = values[1].Trim(); } else { throw new System.ArgumentException("Values must be a single 'foo=bar' format"); } } if (hostingPolicyResetter != null) { hostingPolicyResetter.Dispose(); } if (StrictHostingMode) { hostingPolicyResetter = HostingRuntimePolicyHelper.SetHostingRuntimePolicyValues( doNotLaunchV3AppInV4Runtime: true); } else { hostingPolicyResetter = HostingRuntimePolicyHelper.SetHostingRuntimePolicyValues( doNotLaunchV3AppInV4Runtime: false); } // upload files to FileHost is specified and scheme is not local if (Scheme != ActivationScheme.Local) { if (SupportFiles.Length > 0) { // Create host to copy files to... fileHost = new FileHost(UserDefinedDirectory, (Scheme == ActivationScheme.HttpInternetExternal)); // Upload each file foreach (SupportFile suppFile in SupportFiles) { // Whether to copy foo\bar\baz.xbap to the foo\bar created on the remote machine or just flattened fileHost.PreserveDirectoryStructure = suppFile.PreserveDirectoryStructure; if (suppFile.IncludeDependencies && !string.IsNullOrEmpty(suppFile.TargetDirectory)) { GlobalLog.LogEvidence("TargetDirectory with IncludeDependencies not yet implemented"); throw new NotImplementedException("TargetDirectory with IncludeDependencies not yet supported"); } if (suppFile.CustomTestScratchServerPath == null) { if (suppFile.IncludeDependencies) { fileHost.UploadFileWithDependencies(suppFile.Name); } else { fileHost.UploadFile(suppFile.Name, suppFile.TargetDirectory); } } else { fileHost.UploadFileNonDefaultServer(suppFile.Name, suppFile.CustomTestScratchServerPath); } } } // If no support files are listed, check the parent steps to see if one is a FileHostStep. // If this is the case, no need to upload the files as the FileHostStep has already. // Don't set throttle rate; this should be set in the markup for the parent's filehost. else { LoaderStep parent = this.ParentStep; while (parent != null) { if (parent.GetType() == typeof(Microsoft.Test.Loaders.Steps.FileHostStep)) { this.fileHost = ((FileHostStep)parent).fileHost; break; } // Failed to find it in the immediate parent: try til we hit null or the right one parent = parent.ParentStep; } } } // register UIHandlers foreach (UIHandler handler in UIHandlers) { if (handler.NamedRegistration != null) { appMonitor.RegisterUIHandler(handler, handler.NamedRegistration, handler.Notification); } else { appMonitor.RegisterUIHandler(handler, handler.ProcessName, handler.WindowTitle, handler.Notification); } } string param = ""; if (FileName.StartsWith("&") && FileName.EndsWith("&")) { param = DictionaryStore.Current[FileName.Substring(1, FileName.Length - 2)]; if (param == null) { throw new InvalidOperationException(FileName + " is not defined in the property bag; cannot be used to launch app"); } } else { // Allows for launching things in %program files%, which is localized. param = Environment.ExpandEnvironmentVariables(FileName); } if (Scheme != ActivationScheme.Local) { FileHostUriScheme hostScheme = FileHostUriScheme.Unc; if (Scheme != ActivationScheme.HttpInternetExternal) { hostScheme = (FileHostUriScheme)Enum.Parse(typeof(FileHostUriScheme), Scheme.ToString()); } param = fileHost.GetUri(FileName, hostScheme).ToString(); } // Clear the fusion cache by default. Can be disabled for custom ClickOnce scenarios if (ClearFusionCache) { ApplicationDeploymentHelper.CleanClickOnceCache(); } // Clear IE History but only if specified (defaults to false). Only matters for history-based navigation if (ClearIEHistory) { ApplicationDeploymentHelper.ClearIEHistory(); } // Launch the appropriate handler... switch (Method) { case ActivationMethod.Launch: { // This only works for local paths for security reasons. if (PresentationHostDebugMode) { param = Path.GetFullPath(param); // Workaround ... for some reason on XP64 there's no guarantee that it will actually find PresHost // Even though it verily is in the SysWOW64 directory. Solution... find the right one before we try string presHostPath = "presentationhost.exe"; if ((Environment.OSVersion.Version.Major == 5)) { presHostPath = (Directory.GetFiles(Environment.GetEnvironmentVariable("SystemRoot"), "PresentationHost.exe", SearchOption.AllDirectories))[0]; } appMonitor.StartProcess(presHostPath, " -debug \"" + param + "\""); } else { // Launch process with specified arguments. If shell: specified, then start that way. // If the arguments are for the URL, directly concatenate them. if ((Arguments.Length > 6) && (Arguments.ToLowerInvariant().StartsWith("shell:"))) { appMonitor.StartProcess(param, Environment.ExpandEnvironmentVariables(Arguments.Substring(6))); } else if ((Arguments.Length > 11) && (Arguments.ToLowerInvariant().StartsWith("currentdir:"))) { appMonitor.StartProcess(param, Path.Combine(Environment.CurrentDirectory, Arguments.Substring(11))); } else { appMonitor.StartProcess(param + Arguments); } } break; } case ActivationMethod.Navigate: { // If local we need to fully qualify the path if (Scheme == ActivationScheme.Local) { param = Path.GetFullPath(param); } // Fail to IE, since it has far more tests. string defaultBrowserExecutable = "iexplore.exe"; try { defaultBrowserExecutable = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Clients\StartMenuInternet", null, "iexplore.exe").ToString(); } catch (Exception) { try { defaultBrowserExecutable = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet", null, "iexplore.exe").ToString(); } catch (Exception) { // Do nothing, some machines have been seen in weird states where this is undefined. Log it anyways. GlobalLog.LogDebug("Unable to get StartMenuInternet key, FireFox or other non-standard browser tests may be affected. Contact Microsoft if this is the case"); } } // Handle the case where this value exists but isnt set to anything usable. IE is far more common so fall back to it. if (string.IsNullOrEmpty(defaultBrowserExecutable)) { defaultBrowserExecutable = "iexplore.exe"; } // start the default browser... currently just FF or IE. if (defaultBrowserExecutable.ToLowerInvariant().Contains("iexplore")) { // Create & register IE navigation handler // IE can be strange: About:NavigateIE sometimes gets a cancelled navigation // Workaround: Be less sensitive about the window title we trigger on. appMonitor.RegisterUIHandler(new NavigateIE(param + Arguments), "iexplore", "RegExp:(Internet Explorer)", UIHandlerNotification.All); appMonitor.StartProcess("iexplore.exe", "about:NavigateIE"); } else if (defaultBrowserExecutable.ToLowerInvariant().Contains("firefox")) { if (Scheme == ActivationScheme.Unc) { param = param.Replace("file:", "").Replace("/", @"\"); } } else { throw new InvalidOperationException("Don't know how to navigate an instance of \"" + defaultBrowserExecutable + "\" browser!!! Contact Microsoft with this message."); } break; } // GOTO used here for fallthrough since there's only 2 lines difference. case ActivationMethod.EHome: goto case ActivationMethod.EHomeFullScreen; case ActivationMethod.EHomeFullScreen: { // If local we need to fully qualify the path if (Scheme == ActivationScheme.Local) { param = Path.GetFullPath(param); } // Get a reference to the path for the ehome exe... string eHomePath = Environment.GetEnvironmentVariable("SystemRoot") + "\\ehome\\ehshell.exe"; // Fail hard if EHome isnt present on the system. // Need to mark testcases accurately in test DB to avoid this. if (!File.Exists(eHomePath)) { throw new InvalidOperationException("\"Ehome\" or \"EHomeFullScreen\" method selected but case was run on non-Media-Center-enabled SKU! \n Contact Microsoft for more info on this issue."); } // Construct args with path to content to launch (MUST be a Uri) string eHomeArgs = "/url:\"" + param + "\""; // Tack on the argument for full screen if requested if (Method == ActivationMethod.EHomeFullScreen) { eHomeArgs += " /directmedia:general"; } // Start MCE... appMonitor.StartProcess(eHomePath, eHomeArgs); break; } } // Store the activation path into the property bag. This way apps or child steps can directly figure out the deployment URI DictionaryStore.Current["ActivationStepUri"] = param; return(true); }
public bool Evaluate(string title, string processName, UIHandlerNotification notification, IntPtr hWnd) { if (title == null) { title = ""; } if (handler == null) { return(false); } if (hasBeenInvoked && !handler.AllowMultipleInvocations) { return(false); } if (this.title != null) { if (this.title.ToLowerInvariant().StartsWith("regexp:")) { string regexp = this.title.Substring(7); if (!Regex.IsMatch(title, regexp, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) { return(false); } } else if (StringComparer.InvariantCultureIgnoreCase.Compare(this.title, title) != 0) { return(false); } } if (this.processName != null && StringComparer.InvariantCultureIgnoreCase.Compare(this.processName, processName) != 0) { return(false); } if (this.notification != UIHandlerNotification.All && this.notification != notification) { return(false); } if (this.WindowClass != WindowClassEnum.Any && (this.WindowClass == WindowClassEnum.AvalonBrowserApplication) && !ApplicationDeploymentHelper.IsAvalonApplicationHwnd(hWnd)) { return(false); } return(true); }
// Use this method to set up non-intrusive environment settings, such as IE default settings, etc. // Since AppMonitor can't guarantee it can clean this up, ONLY set values that can be persisted. // WARNING: IF THIS METHOD THROWS AN EXCEPTION ALL APPMONITOR FUNCTIONALITY WILL BE AFFECTED!!! // private void SetupEnvironmentForTest() { try { // **** Set reg keys to disable Cross-domain frame navigation. Needed because there's a test that enables it temporarily. Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1", "1607", 3, RegistryValueKind.DWord); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", "1607", 3, RegistryValueKind.DWord); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... please fix X-Domain Frame Navigation setup code in ApplicationMonitor.SetupEnvironmentForTest() )\n" + ex.ToString()); } try { // **** Set reg keys to prevent HTTPS Mixed content dialog Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\0", "1609", 0, RegistryValueKind.DWord); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1", "1609", 0, RegistryValueKind.DWord); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2", "1609", 0, RegistryValueKind.DWord); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", "1609", 0, RegistryValueKind.DWord); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... please fix HTTPS Mixed content dialog in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } try { // **** Set reg key to prevent IE7 Phishing Filter dialog... if (ApplicationDeploymentHelper.GetIEVersion() >= 7) { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\PhishingFilter", "Enabled", 1, RegistryValueKind.DWord); } if (ApplicationDeploymentHelper.GetIEVersion() == 8) { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\PhishingFilter", "EnabledV8", 1, RegistryValueKind.DWord); } } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... please fix IE Phishing Filter key setup in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } try { // **** Set reg key to prevent dialog for IE7 on Vista creating new instance for cross-zone navigation if (ApplicationDeploymentHelper.GetIEVersion() == 7 && Environment.OSVersion.Version.Major == 6) { Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LowRegistry\DontShowMeThisDialogAgain", "PromptForBrokerRedirect", "NO", RegistryValueKind.String); } } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... If this error is seen on Vista, please fix IE zone-change setting in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } try { // **** Set reg key to prevent dialog for first-time IE7 GoldBar display // **** The bar still displays but this prevents a modal dialog from blocking animation. if (ApplicationDeploymentHelper.GetIEVersion() == 7) { Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\InformationBar", "FirstTime", 0, RegistryValueKind.DWord); } } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... Please fix IE \"First Goldbar\" code in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } try { // **** Set reg key to prevent dialog for first-time HTTPS navigation. // **** If this UI shows automation can be blocked. Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "WarnonZo----ssing", 0, RegistryValueKind.DWord); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... Please fix IE \"first-time HTTPS navigation\" code in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } if ((SystemInformation.Current.IsPersonalEdition) && (SystemInformation.Current.MajorVersion == 6)) { try { // **** Set reg key to prevent dialog for first-time HTTPS navigation. // **** If this UI shows automation can be blocked. Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "WarnonZo----ssing", 0, RegistryValueKind.DWord); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... Please fix IE \"Enable Intranet Zone for Home SKUs\" code in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } } try { // **** Set reg key to prevent dialog when IE thinks it's not the default browser. // **** Needed since if this is set programatically via registry, IE still detects change on some platforms. Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "ShowedCheckBrowser", "no", RegistryValueKind.String); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Check_Associations", "no", RegistryValueKind.String); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... Please fix IE \"Prevent Default Browser Check\" code in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } try { // No special treatment for Server: WPF Automation lab disables ESC now. //// Add Internet zone URLs to trusted sites on any Server SKU. //// This allows the tests to run as expected on IE Enhanced Security mode, which is the default behavior for LH Server + Server 2K3 //if (SystemInformation.Current.IsServer) //{ // ApplicationDeploymentHelper.AddUrlToZone(IEUrlZone.URLZONE_TRUSTED, FileHost.HttpInternetBaseUrl); // ApplicationDeploymentHelper.AddUrlToZone(IEUrlZone.URLZONE_TRUSTED, FileHost.HttpsInternetBaseUrl); // // Workaround for DD bugs # 129532 - LH Server: Xbap Error UI brings up IE Enhanced Security warning for local apps // // Not needed on Server 2K3 SKUs. // if (SystemInformation.Current.OSVersion.StartsWith("6")) // { // ApplicationDeploymentHelper.AddUrlToZone(IEUrlZone.URLZONE_TRUSTED, "about:security_PresentationHost.exe" ); // } // Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "DisplayTrustAlertDlg", 0, RegistryValueKind.DWord); // Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "RunOnceHasShown", 1, RegistryValueKind.DWord); // Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "IEHardenIENoWarn", 1, RegistryValueKind.DWord); //} //else //{ ApplicationDeploymentHelper.AddUrlToZone(IEUrlZone.URLZONE_INTERNET, FileHost.HttpInternetBaseUrl); ApplicationDeploymentHelper.AddUrlToZone(IEUrlZone.URLZONE_INTERNET, FileHost.HttpsInternetBaseUrl); //} ApplicationDeploymentHelper.AddUrlToZone(IEUrlZone.URLZONE_INTRANET, FileHost.HttpIntranetBaseUrl); ApplicationDeploymentHelper.AddUrlToZone(IEUrlZone.URLZONE_INTRANET, FileHost.HttpsIntranetBaseUrl); ApplicationDeploymentHelper.AddUrlToZone(IEUrlZone.URLZONE_INTRANET, FileHost.UncBaseUrl); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... Please fix IE \"IE URL->Zone mapping ... \" code in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } try { Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "IE8RunOnceCompleted", 1, RegistryValueKind.DWord); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Recovery", "AutoRecover", 2, RegistryValueKind.DWord); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... Please fix IE 8 first-run prep code in ApplicationMonitor.SetupEnvironmentForTest()\n" + ex.ToString()); } // Rarely, one of two specific PartialTrust tests will fail to complete. If this happens, a regkey gets left behind that // disables all access to WebBrowser or Media. Any further tests of those items on this machine will fail. // Try to delete those keys to save a massive headache. try { RegistryKey wpfFeaturesKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\.NETFramework\Windows Presentation Foundation\Features", true); if (wpfFeaturesKey != null) { wpfFeaturesKey.DeleteValue("WebBrowserDisallow", false); wpfFeaturesKey.DeleteValue("MediaAudioDisallow", false); wpfFeaturesKey.DeleteValue("MediaImageDisallow", false); wpfFeaturesKey.DeleteValue("MediaVideoDisallow", false); wpfFeaturesKey.DeleteValue("XBAPDisallow", false); wpfFeaturesKey.DeleteValue("ScriptInteropDisallow", false); wpfFeaturesKey.Close(); } // If there's a WOW6432Node defined, we need to check this as well. // Currently this only matters for Win7 because otherwise the previous call would have cleaned all these values. // Win7 removes hidden redirection but there still are "two" registries. wpfFeaturesKey = Registry.LocalMachine.OpenSubKey(@"Software\Wow6432Node\Microsoft\.NETFramework\Windows Presentation Foundation\Features", true); if (wpfFeaturesKey != null) { wpfFeaturesKey.DeleteValue("WebBrowserDisallow", false); wpfFeaturesKey.DeleteValue("MediaAudioDisallow", false); wpfFeaturesKey.DeleteValue("MediaImageDisallow", false); wpfFeaturesKey.DeleteValue("MediaVideoDisallow", false); wpfFeaturesKey.DeleteValue("XBAPDisallow", false); wpfFeaturesKey.DeleteValue("ScriptInteropDisallow", false); wpfFeaturesKey.Close(); } } catch (Exception) { // if we didn't find the regkey, ignore the exception } // Information bar first run dialog is usually ignorable but some focus tracking tests get confused by it, so prevent it from showing. try { Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\InformationBar", "FirstTime", 0, RegistryValueKind.DWord); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... Please fix IE Information Bar first run logic in ApplicationMonitor.SetupEnvironmentForTest():" + ex.ToString()); } //On IE9, XBAPs are disabled in the Internet Zone. Re-enable them so tests will start. //Note: We just enable no matter what Windows/IE version we're on, since we always want this on, //and it won't hurt to set it to 0 (enable) if it's already 0. try { Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", "2400", 0, RegistryValueKind.DWord); } catch (Exception ex) { GlobalLog.LogDebug(" -- Exception trying to set up environment ... Please fix Internet Zone XBAP enable logic in ApplicationMonitor.SetupEnvironmentForTest():" + ex.ToString()); } }