Skip to content
Merged
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
12 changes: 12 additions & 0 deletions lib/PuppeteerSharp/Cdp/CdpBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,18 @@ public override async Task<IPage> LaunchPWAAsync(LaunchPWAOptions options)
throw new PuppeteerException($"Failed to create a page for the launched PWA (manifestId = {options.ManifestId})");
}

// target.InitializedTask only guarantees the Target domain reported a URL. page.Url is populated by
// a separate, independently-timed pathway: target.PageAsync() above triggers a Page.getFrameTree
// call whose response can still carry an empty URL for the main frame even after InitializedTask
// resolved. If that happens, wait for the main frame to report its navigated URL via the
// FrameNavigated event before handing the page back, so callers never observe page.Url empty.
if (string.IsNullOrEmpty(page.Url))
{
await page.WaitForFrameAsync(
frame => frame == page.MainFrame && !string.IsNullOrEmpty(frame.Url),
new WaitForOptions { Timeout = options.Timeout }).ConfigureAwait(false);
}

return page;
}

Expand Down
Loading