-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #802 from icnocop/master
Waiting until Internet Explorer process being debugged has exited before continuing when using the web server
- Loading branch information
Showing
21 changed files
with
238 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,69 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using Chutzpah.Models; | ||
using Chutzpah.Utility; | ||
|
||
namespace Chutzpah.VS.Common | ||
{ | ||
public class VsDebuggerTestLauncher : ITestLauncher | ||
using System; | ||
using System.Diagnostics; | ||
using Chutzpah.Models; | ||
using Chutzpah.Utility; | ||
|
||
namespace Chutzpah.VS.Common | ||
{ | ||
public class VsDebuggerTestLauncher : ITestLauncher | ||
{ | ||
readonly IUrlBuilder urlBuilder; | ||
|
||
public Process DebuggingProcess { get; set; } | ||
|
||
public VsDebuggerTestLauncher(IUrlBuilder urlBuilder) | ||
{ | ||
this.urlBuilder = urlBuilder; | ||
} | ||
|
||
public void LaunchTest(TestContext testContext) | ||
} | ||
|
||
public void LaunchTest(TestContext testContext) | ||
{ | ||
var file = testContext.TestHarnessPath; | ||
file = urlBuilder.GenerateFileUrl(testContext, file, fullyQualified: true); | ||
|
||
// Start IE. | ||
ProcessStartInfo startInfo = new ProcessStartInfo() | ||
{ | ||
UseShellExecute = true, | ||
FileName = BrowserPathHelper.GetBrowserPath("ie"), | ||
Arguments = string.Format("-noframemerging -suspended -debug {0}", file) | ||
// -noframemerging | ||
// This is what VS does when launching the script debugger. | ||
// Unsure whether strictly necessary. | ||
// -suspended | ||
// This is what VS does when launching the script debugger. | ||
// Seems to cause IE to suspend all threads which is what we want. | ||
// -debug | ||
// This is what VS does when launching the script debugger. | ||
// Not sure exactly what it does. | ||
}; | ||
Process ieMainProcess = Process.Start(startInfo); | ||
|
||
// Get child 'tab' process spawned by IE. | ||
// We need to wait a few ms for IE to open the process. | ||
Process ieTabProcess = null; | ||
for (int i = 0;; ++i) { | ||
System.Threading.Thread.Sleep(10); | ||
ieTabProcess = ProcessExtensions.FindFirstChildProcessOf(ieMainProcess.Id); | ||
if (ieTabProcess != null) { | ||
break; } | ||
if (i > 400) { // 400 * 10 = 4s timeout | ||
throw new InvalidOperationException("Timeout waiting for Internet Explorer child process to start."); } | ||
} | ||
|
||
// Debug the script in that tab process. | ||
DteHelpers.DebugAttachToProcess(ieTabProcess.Id, "script"); | ||
|
||
// Resume the threads in the IE process which where started off suspended. | ||
ieTabProcess.Resume(); | ||
} | ||
} | ||
} | ||
ProcessStartInfo startInfo = new ProcessStartInfo() | ||
{ | ||
UseShellExecute = true, | ||
FileName = BrowserPathHelper.GetBrowserPath("ie"), | ||
Arguments = string.Format("-noframemerging -suspended -debug {0}", file) | ||
// -noframemerging | ||
// This is what VS does when launching the script debugger. | ||
// Unsure whether strictly necessary. | ||
// -suspended | ||
// This is what VS does when launching the script debugger. | ||
// Seems to cause IE to suspend all threads which is what we want. | ||
// -debug | ||
// This is what VS does when launching the script debugger. | ||
// Not sure exactly what it does. | ||
}; | ||
Process ieMainProcess = Process.Start(startInfo); | ||
|
||
int ieBrowserTabOpenTimeout = ((testContext.TestFileSettings.IEBrowserTabOpenTimeout ?? Constants.DefaultIEBrowserTabOpenTimeout) * 100); | ||
|
||
// Get child 'tab' process spawned by IE. | ||
for (int i = 0;; ++i) | ||
{ | ||
// We need to wait a few ms for IE to open the process. | ||
System.Threading.Thread.Sleep(10); | ||
|
||
this.DebuggingProcess = ProcessExtensions.FindFirstChildProcessOf(ieMainProcess.Id); | ||
if (this.DebuggingProcess != null) | ||
{ | ||
break; | ||
} | ||
|
||
if (i > ieBrowserTabOpenTimeout) | ||
{ | ||
throw new InvalidOperationException("Timeout waiting for Internet Explorer child process to start."); | ||
} | ||
} | ||
|
||
// Debug the script in that tab process. | ||
DteHelpers.DebugAttachToProcess(this.DebuggingProcess.Id, "script"); | ||
|
||
// Resume the threads in the IE process which where started off suspended. | ||
this.DebuggingProcess.Resume(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.