fix: ensure document.visibilityState aligns with the visibility of the TopLevelWindow (#19988)

* fix: ensure document.visibilityState aligns with the visibility of the
TopLevelWindow

* chore: disable the specs on linux on CI
This commit is contained in:
Samuel Attard 2019-09-05 10:56:06 -07:00 committed by GitHub
parent cd096289e9
commit 137622931b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 269 additions and 4 deletions

View file

@ -9,6 +9,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" // nogncheck
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h" // nogncheck
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "gin/converter.h"
@ -44,10 +45,21 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
if (options.Get(options::kBackgroundColor, &value))
web_preferences.Set(options::kBackgroundColor, value);
// Copy the transparent setting to webContents
v8::Local<v8::Value> transparent;
if (options.Get("transparent", &transparent))
web_preferences.Set("transparent", transparent);
// Copy the show setting to webContents, but only if we don't want to paint
// when initially hidden
bool paint_when_initially_hidden = true;
options.Get("paintWhenInitiallyHidden", &paint_when_initially_hidden);
if (!paint_when_initially_hidden) {
bool show = true;
options.Get(options::kShow, &show);
web_preferences.Set(options::kShow, show);
}
if (options.Get("webContents", &web_contents) && !web_contents.IsEmpty()) {
// Set webPreferences from options if using an existing webContents.
// These preferences will be used when the webContent launches new
@ -422,6 +434,16 @@ void BrowserWindow::Cleanup() {
Observe(nullptr);
}
void BrowserWindow::OnWindowShow() {
web_contents()->WasShown();
TopLevelWindow::OnWindowShow();
}
void BrowserWindow::OnWindowHide() {
web_contents()->WasHidden();
TopLevelWindow::OnWindowHide();
}
// static
mate::WrappableBase* BrowserWindow::New(mate::Arguments* args) {
if (!Browser::Get()->is_ready()) {