fix: capturePage not resolving with hidden windows (#27883)
This commit is contained in:
parent
f6949dd197
commit
d9997c303f
3 changed files with 29 additions and 1 deletions
|
@ -2758,6 +2758,18 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
|
|||
return handle;
|
||||
}
|
||||
|
||||
#if !defined(OS_MAC)
|
||||
// If the view's renderer is suspended this may fail on Windows/Linux -
|
||||
// bail if so. See CopyFromSurface in
|
||||
// content/public/browser/render_widget_host_view.h.
|
||||
auto* rfh = web_contents()->GetMainFrame();
|
||||
if (rfh &&
|
||||
rfh->GetVisibilityState() == blink::mojom::PageVisibilityState::kHidden) {
|
||||
promise.Resolve(gfx::Image());
|
||||
return handle;
|
||||
}
|
||||
#endif // defined(OS_MAC)
|
||||
|
||||
// Capture full page if user doesn't specify a |rect|.
|
||||
const gfx::Size view_size =
|
||||
rect.IsEmpty() ? view->GetViewBounds().size() : rect.size();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue