Skip to content

Chrome 137 #2912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@
"comment": "Querying by a11y attributes is not standard behavior"
},
{
"testIdPattern": "[bfcache.spec] BFCache can navigate to a BFCached page containing an OOPIF and a worker",
"testIdPattern": "[bfcache.spec] *",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "firefox"],
"expectations": ["SKIP"],
Expand Down Expand Up @@ -1622,32 +1622,11 @@
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[extensions.spec] extensions background_page target type should be available",
"testIdPattern": "[extensions.spec] extensions *",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "firefox"],
"expectations": ["SKIP"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[extensions.spec] extensions service_worker target type should be available",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "firefox"],
"expectations": ["SKIP"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[extensions.spec] extensions target.page() should return a background_page",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "firefox"],
"expectations": ["SKIP"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[extensions.spec] extensions target.page() should return a background_page",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "chrome"],
"expectations": ["FAIL", "PASS"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
"comment": "Chrome-specific test"
},
{
Comment on lines +1625 to 1631
Copy link
Preview

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a wildcard pattern for testIdPattern may unintentionally skip additional tests; consider narrowing the pattern or creating separate entries for each test case to prevent accidental skips.

Copilot uses AI. Check for mistakes.

"testIdPattern": "[fixtures.spec] Fixtures should close the browser when the node process closes",
Expand Down Expand Up @@ -3732,25 +3711,11 @@
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[extensions.spec] extensions background_page target type should be available",
"testIdPattern": "[extensions.spec] extensions *",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "chrome", "chrome-headless-shell"],
"expectations": ["SKIP"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[extensions.spec] extensions service_worker target type should be available",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "chrome", "chrome-headless-shell"],
"expectations": ["SKIP"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
},
{
"testIdPattern": "[extensions.spec] extensions target.page() should return a background_page",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "chrome", "chrome-headless-shell"],
"expectations": ["SKIP"],
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
"comment": "No extensions in chrome-headless-shell"
},
{
"testIdPattern": "[network.spec] network Network Events Page.Events.Request",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<script>
function unused(){}console.log('used!');</script>
function unused(){}console.log('used!');if(true===false)console.log('unused!');</script>

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions lib/PuppeteerSharp.Tests/Assets/simple-extension/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Mock script for background extension
window.MAGIC = 42;
// Mock script for service worker extension
globalThis.MAGIC = 42;
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "Simple extension",
"version": "0.1",
"background": {
"scripts": ["index.js"]
"service_worker": "index.js"
},
"content_scripts": [{
"matches": ["<all_urls>"],
"css": [],
"js": ["content-script.js"]
}],
"permissions": ["background", "activeTab"],
"manifest_version": 2
"manifest_version": 3
}
20 changes: 8 additions & 12 deletions lib/PuppeteerSharp.Tests/Browsers/Firefox/FirefoxDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ public class FirefoxDataTests
public void ShouldResolveUrlsForNightly()
{
Assert.That(
BrowserData.Firefox.ResolveDownloadUrl(Platform.Linux, "111.0a1", null),
BrowserData.Firefox.ResolveDownloadUrl(Platform.Linux, "nightly_111.0a1", null),
Is.EqualTo("https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.linux-x86_64.tar.bz2"));
Assert.That(
BrowserData.Firefox.ResolveDownloadUrl(Platform.MacOS, "111.0a1", null),
BrowserData.Firefox.ResolveDownloadUrl(Platform.MacOS, "nightly_111.0a1", null),
Is.EqualTo("https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.mac.dmg"));
Assert.That(
BrowserData.Firefox.ResolveDownloadUrl(Platform.MacOSArm64, "111.0a1", null),
BrowserData.Firefox.ResolveDownloadUrl(Platform.MacOSArm64, "nightly_111.0a1", null),
Is.EqualTo("https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.mac.dmg"));
Assert.That(
BrowserData.Firefox.ResolveDownloadUrl(Platform.Win32, "111.0a1", null),
BrowserData.Firefox.ResolveDownloadUrl(Platform.Win32, "nightly_111.0a1", null),
Is.EqualTo("https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.win32.zip"));
Assert.That(
BrowserData.Firefox.ResolveDownloadUrl(Platform.Win64, "111.0a1", null),
BrowserData.Firefox.ResolveDownloadUrl(Platform.Win64, "nightly_111.0a1", null),
Is.EqualTo("https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.win64.zip"));
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public void ShouldResolveExecutablePath()
Assert.That(
BrowserData.Firefox.RelativeExecutablePath(Platform.MacOS, "111.0a1"),
Is.EqualTo(Path.Combine(
"Firefox Nightly.app",
"Firefox.app",
"Contents",
"MacOS",
"firefox"
Expand All @@ -105,7 +105,7 @@ public void ShouldResolveExecutablePath()
Assert.That(
BrowserData.Firefox.RelativeExecutablePath(Platform.MacOSArm64, "111.0a1"),
Is.EqualTo(Path.Combine(
"Firefox Nightly.app",
"Firefox.app",
"Contents",
"MacOS",
"firefox"
Expand All @@ -122,11 +122,7 @@ public void ShouldResolveExecutablePath()

Assert.That(
BrowserData.Firefox.RelativeExecutablePath(Platform.Win32, "111.0a1"),
Is.EqualTo(Path.Combine("firefox", "firefox.exe")));

Assert.That(
Path.Combine("firefox", "firefox.exe"),
Is.EqualTo(BrowserData.Firefox.RelativeExecutablePath(Platform.Win64, "111.0a1")));
Is.EqualTo(Path.Combine("core", "firefox.exe")));
}
}
}
28 changes: 25 additions & 3 deletions lib/PuppeteerSharp.Tests/CoverageTests/JSCoverageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,31 @@ public async Task ShouldReportRightRanges()
var coverage = await Page.Coverage.StopJSCoverageAsync();
Assert.That(coverage, Has.Exactly(1).Items);
var entry = coverage[0];
Assert.That(entry.Ranges, Has.Exactly(1).Items);
var range = entry.Ranges[0];
Assert.That(entry.Text.Substring(range.Start, range.End - range.Start), Is.EqualTo("console.log('used!');"));
Assert.That(entry.Ranges, Has.Exactly(2).Items);
var range1 = entry.Ranges[0];
Assert.That(entry.Text.Substring(range1.Start, range1.End - range1.Start), Is.EqualTo("\n"));
var range2 = entry.Ranges[1];
Assert.That(entry.Text.Substring(range2.Start, range2.End - range2.Start), Is.EqualTo("console.log('used!');if(true===false)"));
}

[Test, Retry(2), PuppeteerTest("coverage.spec", "Coverage specs JSCoverage", "should report right ranges for \"per function\" scope")]
public async Task ShouldReportRightRangesForPerFunctionScope()
{
var coverageOptions = new CoverageStartOptions
{
UseBlockCoverage = false,
};

await Page.Coverage.StartJSCoverageAsync(coverageOptions);
await Page.GoToAsync(TestConstants.ServerUrl + "/jscoverage/ranges.html");
var coverage = await Page.Coverage.StopJSCoverageAsync();
Assert.That(coverage, Has.Exactly(1).Items);
var entry = coverage[0];
Assert.That(entry.Ranges, Has.Exactly(2).Items);
var range1 = entry.Ranges[0];
Assert.That(entry.Text.Substring(range1.Start, range1.End - range1.Start), Is.EqualTo("\n"));
var range2 = entry.Ranges[1];
Assert.That(entry.Text.Substring(range2.Start, range2.End - range2.Start), Is.EqualTo("console.log('used!');if(true===false)console.log('unused!');"));
}

[Test, Retry(2), PuppeteerTest("coverage.spec", "Coverage specs JSCoverage", "should report scripts that have no coverage")]
Expand Down
39 changes: 6 additions & 33 deletions lib/PuppeteerSharp.Tests/ExtensionsTests/ExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace PuppeteerSharp.Tests.ExtensionsTests
public class ExtensionsTests : PuppeteerBaseTest
{
private static readonly string _extensionPath = Path.Combine(AppContext.BaseDirectory, "Assets", "simple-extension");
private static readonly string _serviceWorkerExtensionPath = Path.Combine(AppContext.BaseDirectory, "Assets", "service-worker-extension");

private static LaunchOptions BrowserWithExtensionOptions() => new()
{
Expand All @@ -22,51 +21,25 @@ public class ExtensionsTests : PuppeteerBaseTest
}
};

private static LaunchOptions BrowserWithServiceWorkerExtensionOptions() => new()
{
Headless = false,
Args = new[]
{
$"--disable-extensions-except={_serviceWorkerExtensionPath.Quote()}",
$"--load-extension={_serviceWorkerExtensionPath.Quote()}"
}
};

[Test, Retry(2), PuppeteerTest("extensions.spec", "extensions", "background_page target type should be available")]
public async Task BackgroundPageTargetTypeShouldBeAvailable()
{
await using var browserWithExtension = await Puppeteer.LaunchAsync(
BrowserWithExtensionOptions(),
TestConstants.LoggerFactory);
await using (await browserWithExtension.NewPageAsync())
{
var backgroundPageTarget = await browserWithExtension.WaitForTargetAsync(t => t.Type == TargetType.BackgroundPage);
Assert.That(backgroundPageTarget, Is.Not.Null);
}
}

[Test, Retry(2), PuppeteerTest("extensions.spec", "extensions", "service_worker target type should be available")]
public async Task ServiceWorkerTargetTypeShouldBeAvailable()
{
await using var browserWithExtension = await Puppeteer.LaunchAsync(
BrowserWithServiceWorkerExtensionOptions(),
BrowserWithExtensionOptions(),
TestConstants.LoggerFactory);
var serviceWorkTarget = await browserWithExtension.WaitForTargetAsync(t => t.Type == TargetType.ServiceWorker);
await using var page = await browserWithExtension.NewPageAsync();
Assert.That(serviceWorkTarget, Is.Not.Null);

}

[Test, Retry(2), PuppeteerTest("extensions.spec", "extensions", "target.page() should return a background_page")]
public async Task TargetPageShouldReturnABackgroundPage()
[Test, Retry(2), PuppeteerTest("extensions.spec", "extensions", "can evaluate in the service worker")]
public async Task CanEvaluateInTheServiceWorker()
{
await using var browserWithExtension = await Puppeteer.LaunchAsync(
BrowserWithExtensionOptions(),
TestConstants.LoggerFactory);
var backgroundPageTarget = await browserWithExtension.WaitForTargetAsync(t => t.Type == TargetType.BackgroundPage);
await using var page = await backgroundPageTarget.PageAsync();
Assert.That(await page.EvaluateFunctionAsync<int>("() => 2 * 3"), Is.EqualTo(6));
Assert.That(await page.EvaluateFunctionAsync<int>("() => window.MAGIC"), Is.EqualTo(42));
var serviceWorkerTarget = await browserWithExtension.WaitForTargetAsync(t => t.Type == TargetType.ServiceWorker);
var worker = await serviceWorkerTarget.WorkerAsync();
Assert.That(await worker.EvaluateFunctionAsync<int>("() => globalThis.MAGIC"), Is.EqualTo(42));
}
}
}
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp/BrowserData/Chrome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class Chrome
/// <summary>
/// Default chrome build.
/// </summary>
public static string DefaultBuildId => "132.0.6834.83";
public static string DefaultBuildId => "137.0.7151.68";

internal static async Task<string> ResolveBuildIdAsync(ChromeReleaseChannel channel)
=> (await GetLastKnownGoodReleaseForChannel(channel).ConfigureAwait(false)).Version;
Expand Down
4 changes: 2 additions & 2 deletions lib/PuppeteerSharp/BrowserData/Firefox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class Firefox

private static readonly Dictionary<string, string> _cachedBuildIds = [];

internal static Task<string> GetDefaultBuildIdAsync() => ResolveBuildIdAsync(FirefoxChannel.Nightly);
internal static Task<string> GetDefaultBuildIdAsync() => Task.FromResult(DefaultBuildId);

internal static string ResolveDownloadUrl(Platform platform, string buildId, string baseUrl)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ private static (FirefoxChannel Channel, string BuildId) ParseBuildId(string buil
}
}

return (FirefoxChannel.Nightly, buildId);
return (FirefoxChannel.Stable, buildId);
}

private static string[] ResolveDownloadPath(Platform platform, string buildId)
Expand Down
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp/PageCoverage/Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal static CoverageEntryRange[] ConvertToDisjointRanges(List<CoverageRange>
}

// Filter out empty ranges.
return results.Where(range => range.End - range.Start > 1).ToArray();
return results.Where(range => range.End - range.Start > 0).ToArray();
}

internal void UpdateClient(CDPSession client)
Expand Down
7 changes: 7 additions & 0 deletions lib/PuppeteerSharp/PageCoverage/CoverageStartOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,12 @@ public class CoverageStartOptions
/// Whether the result includes raw V8 script coverage entries.
/// </summary>
public bool IncludeRawScriptCoverage { get; set; }

/// <summary>
/// Whether to collect coverage information at the block level.
/// If true, coverage will be collected at the block level (this is the default).
/// If false, coverage will be collected at the function level.
/// </summary>
public bool UseBlockCoverage { get; set; } = true;
}
}
4 changes: 3 additions & 1 deletion lib/PuppeteerSharp/PageCoverage/ICoverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public interface ICoverage
/// <summary>
/// Starts JS coverage.
/// </summary>
/// <param name="options">Set of configurable options for coverage.</param>
/// <param name="options">Set of configurable options for coverage defaults to
/// resetOnNavigation : true, reportAnonymousScripts : false,
/// includeRawScriptCoverage : false, useBlockCoverage : true.</param>
/// <returns>A task that resolves when coverage is started.</returns>
Task StartJSCoverageAsync(CoverageStartOptions options = null);

Expand Down
4 changes: 3 additions & 1 deletion lib/PuppeteerSharp/PageCoverage/JSCoverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class JSCoverage
private bool _resetOnNavigation;
private bool _reportAnonymousScripts;
private bool _includeRawScriptCoverage;
private bool _useBlockCoverage;

public JSCoverage(CDPSession client)
{
Expand All @@ -42,6 +43,7 @@ internal Task StartAsync(CoverageStartOptions options)
_resetOnNavigation = options.ResetOnNavigation;
_reportAnonymousScripts = options.ReportAnonymousScripts;
_includeRawScriptCoverage = options.IncludeRawScriptCoverage;
_useBlockCoverage = options.UseBlockCoverage;
_enabled = true;
_scriptURLs.Clear();
_scriptSources.Clear();
Expand All @@ -53,7 +55,7 @@ internal Task StartAsync(CoverageStartOptions options)
_client.SendAsync("Profiler.startPreciseCoverage", new ProfilerStartPreciseCoverageRequest
{
CallCount = _includeRawScriptCoverage,
Detailed = true,
Detailed = _useBlockCoverage,
}),
_client.SendAsync("Debugger.enable"),
_client.SendAsync("Debugger.setSkipAllPauses", new DebuggerSetSkipAllPausesRequest { Skip = true }));
Expand Down
8 changes: 4 additions & 4 deletions lib/PuppeteerSharp/PuppeteerSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<Description>Headless Browser .NET API</Description>
<PackageId>PuppeteerSharp</PackageId>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageVersion>20.1.3</PackageVersion>
<ReleaseVersion>20.1.3</ReleaseVersion>
<AssemblyVersion>20.1.3</AssemblyVersion>
<FileVersion>20.1.3</FileVersion>
<PackageVersion>20.2.0</PackageVersion>
<ReleaseVersion>20.2.0</ReleaseVersion>
<AssemblyVersion>20.2.0</AssemblyVersion>
<FileVersion>20.2.0</FileVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
<DebugType>embedded</DebugType>
Expand Down
Loading