Skip to content

Commit

Permalink
Rollback to Chrome 124 (#2673)
Browse files Browse the repository at this point in the history
This reverts commit 1b22369.
  • Loading branch information
kblok authored Jul 3, 2024
1 parent 9b39a93 commit 5e9f4a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,34 @@ await Task.WhenAll(
public async Task ShouldWorkWithBothDomcontentloadedAndLoad()
{
var responseCompleted = new TaskCompletionSource<bool>();
Server.SetRoute("/one-style.css", _ => responseCompleted.Task);
Server.SetRoute("/one-style.css", _ =>
{
return responseCompleted.Task;
});

var waitForRequestTask = Server.WaitForRequest("/one-style.css");
var navigationTask = Page.GoToAsync(TestConstants.ServerUrl + "/one-style.html");
var domContentLoadedTask = Page.WaitForNavigationAsync(new NavigationOptions
{
WaitUntil = [WaitUntilNavigation.DOMContentLoaded]
WaitUntil = new[] { WaitUntilNavigation.DOMContentLoaded }
});

var bothFired = false;
var bothFiredTask = Page.WaitForNavigationAsync(new NavigationOptions
{
WaitUntil =
[
WaitUntil = new[]
{
WaitUntilNavigation.Load,
WaitUntilNavigation.DOMContentLoaded
]
}
}).ContinueWith(_ => bothFired = true);

await waitForRequestTask.WithTimeout(5_000);
await domContentLoadedTask.WithTimeout(5_000);
await waitForRequestTask.WithTimeout();
await domContentLoadedTask.WithTimeout();
Assert.False(bothFired);
responseCompleted.SetResult(true);
await bothFiredTask.WithTimeout(5_000);
await navigationTask.WithTimeout(5_000);
await bothFiredTask.WithTimeout();
await navigationTask.WithTimeout();
}

[Test, Retry(2), PuppeteerTest("navigation.spec", "navigation Page.waitForNavigation", "should work with clicking on anchor links")]
Expand Down
4 changes: 1 addition & 3 deletions lib/PuppeteerSharp/BrowserData/Chrome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public static class Chrome
/// <summary>
/// Default chrome build.
/// </summary>
public static string DefaultBuildId => "125.0.6422.76";

internal static int ChromeVersionRequiringPermissionsFix => 125;
public static string DefaultBuildId => "124.0.6367.201";

internal static async Task<string> ResolveBuildIdAsync(ChromeReleaseChannel channel)
=> (await GetLastKnownGoodReleaseForChannel(channel).ConfigureAwait(false)).Version;
Expand Down
34 changes: 2 additions & 32 deletions lib/PuppeteerSharp/BrowserFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private async Task<InstalledBrowser> DownloadAsync(SupportedBrowser browser, str
throw new PuppeteerException($"Failed to download {browser} for {Platform} from {url}", ex);
}

await UnpackArchiveAsync(archivePath, outputPath, fileName, browser, buildId).ConfigureAwait(false);
await UnpackArchiveAsync(archivePath, outputPath, fileName).ConfigureAwait(false);
new FileInfo(archivePath).Delete();

return new InstalledBrowser(cache, browser, buildId, Platform);
Expand Down Expand Up @@ -374,7 +374,7 @@ private Task<string> ResolveBuildIdAsync(BrowserTag tag)
}
}

private async Task UnpackArchiveAsync(string archivePath, string outputPath, string archiveName, SupportedBrowser browser, string buildId)
private async Task UnpackArchiveAsync(string archivePath, string outputPath, string archiveName)
{
if (archivePath.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -426,36 +426,6 @@ private async Task UnpackArchiveAsync(string archivePath, string outputPath, str
}
}
}

if (browser == SupportedBrowser.Chrome && (GetCurrentPlatform() == Platform.Win64 || GetCurrentPlatform() == Platform.Win32))
{
if (int.TryParse(buildId.Split('.').First(), out var majorVersion) &&
majorVersion >= Chrome.ChromeVersionRequiringPermissionsFix)
{
TrySetWindowsPermissions(outputPath);
}
}
}

private void TrySetWindowsPermissions(string outputPath)
{
try
{
var startInfo = new ProcessStartInfo
{
FileName = "icacls.exe",
Arguments = $"\"{outputPath}\" /grant *S-1-15-2-2:(OI)(CI)(RX)",
WindowStyle = ProcessWindowStyle.Hidden,
};
var process = Process.Start(startInfo);
process?.WaitForExit();
}
catch (Exception e)
{
Console.WriteLine("Unable to fix permissions: " + e.Message);
Console.WriteLine($"Visit https://pptr.dev/troubleshooting#chrome-reports-sandbox-errors-on-windows for more information");
throw;
}
}

private async Task DownloadFileUsingHttpClientTaskAsync(string address, string filename)
Expand Down

0 comments on commit 5e9f4a5

Please sign in to comment.