Skip to content
Merged
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 @@ -679,7 +679,7 @@
{
"testIdPattern": "[page.spec] Page Page.newPage should open pages in a new window at the specified position",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"parameters": ["firefox"],
"expectations": ["FAIL"],
"comment": "Not supported by WebDriver BiDi"
},
Expand All @@ -693,7 +693,7 @@
{
"testIdPattern": "[page.spec] Page Page.newPage should open pages in a new window in maximized state",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"parameters": ["firefox"],
"expectations": ["FAIL"],
"comment": "Not supported by WebDriver BiDi"
},
Expand Down
19 changes: 15 additions & 4 deletions lib/PuppeteerSharp/Bidi/BidiBrowserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ public class BidiBrowserContext : BrowserContext
private readonly ConcurrentDictionary<BrowsingContext, BidiPage> _pages = [];
private readonly ConcurrentDictionary<BidiPage, BidiPageTargetInfo> _targets = new();
private readonly List<(string Origin, OverridePermission Permission)> _overrides = [];
private readonly ILogger<BidiBrowserContext> _logger;

private BidiBrowserContext(BidiBrowser browser, UserContext userContext, BidiBrowserContextOptions options)
{
UserContext = userContext;
Browser = browser;
DefaultViewport = options.DefaultViewport;
_logger = browser.LoggerFactory?.CreateLogger<BidiBrowserContext>();
}

internal ViewPortOptions DefaultViewport { get; set; }
Expand Down Expand Up @@ -144,16 +146,25 @@ public override async Task<IPage> NewPageAsync(CreatePageOptions options = null)
{
await page.SetViewportAsync(DefaultViewport).ConfigureAwait(false);
}
catch
catch (Exception ex)
{
// No support for setViewport in Firefox.
// Tolerate not supporting browsingContext.setViewport. Only log it.
_logger?.LogDebug(ex, "Failed to set viewport");
}
}

if (options?.Type == CreatePageType.Window && options?.WindowBounds != null)
{
var windowId = await page.WindowIdAsync().ConfigureAwait(false);
await Browser.SetWindowBoundsAsync(windowId, options.WindowBounds).ConfigureAwait(false);
try
{
var windowId = await page.WindowIdAsync().ConfigureAwait(false);
await Browser.SetWindowBoundsAsync(windowId, options.WindowBounds).ConfigureAwait(false);
}
catch (Exception ex)
{
// Tolerate not supporting browser.setClientWindowState. Only log it.
_logger?.LogDebug(ex, "Failed to set window bounds");
}
}

return page;
Expand Down
Loading