mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
41 Commits
clavin/rem
...
v4.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f88a06df84 | ||
|
|
96a4fce100 | ||
|
|
85b0f254be | ||
|
|
9ac4611075 | ||
|
|
6c18908333 | ||
|
|
f2ca4c11c8 | ||
|
|
7ab6073cdb | ||
|
|
b57d12583f | ||
|
|
3cd67db581 | ||
|
|
630bc64f2f | ||
|
|
a2b4458046 | ||
|
|
fd205a1577 | ||
|
|
1ff102e54a | ||
|
|
d525083d75 | ||
|
|
f1a8483349 | ||
|
|
5fbf1f9a54 | ||
|
|
838f108821 | ||
|
|
df70487f80 | ||
|
|
0c09199f77 | ||
|
|
6281e4ef0b | ||
|
|
abbf9c3ca3 | ||
|
|
b4f4ce1b84 | ||
|
|
5f83e07748 | ||
|
|
203b41fe2e | ||
|
|
c16b34539a | ||
|
|
446275c85a | ||
|
|
1adce9413a | ||
|
|
3ee697b258 | ||
|
|
6e30d855ba | ||
|
|
948fc6f612 | ||
|
|
8c2d16f031 | ||
|
|
11486b99a4 | ||
|
|
ebb2c53c3d | ||
|
|
8094f1a3f0 | ||
|
|
b7f20f1878 | ||
|
|
e9e0219ae8 | ||
|
|
24b809f2bc | ||
|
|
cfbb22b380 | ||
|
|
f9ae1aa999 | ||
|
|
f1ec2237e7 | ||
|
|
35df516e28 |
@@ -311,20 +311,30 @@ step-mksnapshot-store: &step-mksnapshot-store
|
||||
path: src/out/Default/mksnapshot.zip
|
||||
destination: mksnapshot.zip
|
||||
|
||||
step-generate-breakpad-symbols: &step-generate-breakpad-symbols
|
||||
step-build-dump-syms: &step-build-dump-syms
|
||||
run:
|
||||
name: Generate breakpad symbols
|
||||
environment:
|
||||
# TODO(alexeykuzmin): Explicitly pass an out folder path to the scripts.
|
||||
ELECTRON_OUT_DIR: Default
|
||||
name: Build dump_syms binary
|
||||
command: |
|
||||
cd src
|
||||
|
||||
# Build needed dump_syms executable
|
||||
ninja -C out/Default third_party/breakpad:dump_syms
|
||||
|
||||
electron/script/dump-symbols.py -d "$PWD/out/Default/electron.breakpad.syms"
|
||||
electron/script/zip-symbols.py
|
||||
step-generate-breakpad-symbols: &step-generate-breakpad-symbols
|
||||
run:
|
||||
name: Generate breakpad symbols
|
||||
command: |
|
||||
cd src
|
||||
export BUILD_PATH="$PWD/out/Default"
|
||||
export DEST_PATH="$BUILD_PATH/electron.breakpad.syms"
|
||||
electron/script/dump-symbols.py -b $BUILD_PATH -d $DEST_PATH -v
|
||||
|
||||
step-zip-symbols: &step-zip-symbols
|
||||
run:
|
||||
name: Zip symbols
|
||||
command: |
|
||||
cd src
|
||||
export BUILD_PATH="$PWD/out/Default"
|
||||
electron/script/zip-symbols.py -b $BUILD_PATH
|
||||
|
||||
step-maybe-native-mksnapshot-gn-gen: &step-maybe-native-mksnapshot-gn-gen
|
||||
run:
|
||||
@@ -458,7 +468,9 @@ steps-electron-build-for-tests: &steps-electron-build-for-tests
|
||||
|
||||
# Breakpad symbols.
|
||||
# TODO(alexeykuzmin): We should do it only in nightly builds.
|
||||
- *step-build-dump-syms
|
||||
- *step-generate-breakpad-symbols
|
||||
- *step-zip-symbols
|
||||
|
||||
# Trigger tests on arm hardware if needed
|
||||
- *step-maybe-trigger-arm-test
|
||||
@@ -479,7 +491,9 @@ steps-electron-build-for-publish: &steps-electron-build-for-publish
|
||||
- *step-maybe-electron-dist-strip
|
||||
- *step-electron-dist-build
|
||||
- *step-electron-dist-store
|
||||
- *step-build-dump-syms
|
||||
- *step-generate-breakpad-symbols
|
||||
- *step-zip-symbols
|
||||
|
||||
# mksnapshot
|
||||
- *step-mksnapshot-build
|
||||
|
||||
10
BUILD.gn
10
BUILD.gn
@@ -750,6 +750,16 @@ if (is_mac) {
|
||||
"/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll",
|
||||
"/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll",
|
||||
]
|
||||
|
||||
# This is to support renaming of electron.exe. node-gyp has hard-coded
|
||||
# executable names which it will recognise as node. This module definition
|
||||
# file claims that the electron executable is in fact named "node.exe",
|
||||
# which is one of the executable names that node-gyp recognizes.
|
||||
# See https://github.com/nodejs/node-gyp/commit/52ceec3a6d15de3a8f385f43dbe5ecf5456ad07a
|
||||
ldflags += [ "/DEF:" + rebase_path("build/electron.def", root_build_dir) ]
|
||||
inputs = [
|
||||
"build/electron.def",
|
||||
]
|
||||
}
|
||||
if (is_linux) {
|
||||
ldflags = [ "-pie" ]
|
||||
|
||||
6
DEPS
6
DEPS
@@ -12,7 +12,7 @@ vars = {
|
||||
'chromium_version':
|
||||
'69.0.3497.106',
|
||||
'node_version':
|
||||
'5654c276d0497ff9a0bb0d7550b9073b2e2e7d3f',
|
||||
'f14ddf9d7e07739dc1dc0cbe2f7a5ba8b44906d1',
|
||||
|
||||
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
|
||||
'pyyaml_version': '3.12',
|
||||
@@ -24,6 +24,9 @@ vars = {
|
||||
'requests_git': 'https://github.com/kennethreitz',
|
||||
'yaml_git': 'https://github.com/yaml',
|
||||
|
||||
# To be able to build clean Chromium from sources.
|
||||
'apply_patches': True,
|
||||
|
||||
# Python interface to Amazon Web Services. Is used for releases only.
|
||||
'checkout_boto': False,
|
||||
|
||||
@@ -68,6 +71,7 @@ deps = {
|
||||
hooks = [
|
||||
{
|
||||
'name': 'patch_chromium',
|
||||
'condition': 'apply_patches',
|
||||
'pattern': 'src/electron',
|
||||
'action': [
|
||||
'python',
|
||||
|
||||
@@ -1173,7 +1173,7 @@ v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
|
||||
|
||||
auto* const info_mgr = GPUInfoManager::GetInstance();
|
||||
if (info_type == "complete") {
|
||||
#if defined(OS_WIN)
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
info_mgr->FetchCompleteInfo(promise);
|
||||
#else
|
||||
info_mgr->FetchBasicInfo(promise);
|
||||
|
||||
@@ -814,8 +814,10 @@ void WebContents::DidChangeThemeColor(SkColor theme_color) {
|
||||
|
||||
void WebContents::DocumentLoadedInFrame(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
if (!render_frame_host->GetParent())
|
||||
if (!render_frame_host->GetParent()) {
|
||||
is_dom_ready_ = true;
|
||||
Emit("dom-ready");
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
||||
@@ -842,6 +844,7 @@ void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host,
|
||||
}
|
||||
|
||||
void WebContents::DidStartLoading() {
|
||||
is_dom_ready_ = false;
|
||||
Emit("did-start-loading");
|
||||
}
|
||||
|
||||
@@ -1422,6 +1425,10 @@ bool WebContents::IsCurrentlyAudible() {
|
||||
return web_contents()->IsCurrentlyAudible();
|
||||
}
|
||||
|
||||
bool WebContents::IsDOMReady() const {
|
||||
return is_dom_ready_;
|
||||
}
|
||||
|
||||
void WebContents::Print(mate::Arguments* args) {
|
||||
PrintSettings settings = {false, false, base::string16()};
|
||||
if (args->Length() >= 1 && !args->GetNext(&settings)) {
|
||||
@@ -2019,6 +2026,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("setAudioMuted", &WebContents::SetAudioMuted)
|
||||
.SetMethod("isAudioMuted", &WebContents::IsAudioMuted)
|
||||
.SetMethod("isCurrentlyAudible", &WebContents::IsCurrentlyAudible)
|
||||
.SetMethod("isDomReady", &WebContents::IsDOMReady)
|
||||
.SetMethod("undo", &WebContents::Undo)
|
||||
.SetMethod("redo", &WebContents::Redo)
|
||||
.SetMethod("cut", &WebContents::Cut)
|
||||
|
||||
@@ -52,7 +52,6 @@ class FrameSubscriber;
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
class OffScreenWebContentsView;
|
||||
class OffScreenRenderWidgetHostView;
|
||||
#endif
|
||||
|
||||
namespace api {
|
||||
@@ -142,6 +141,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
void SetAudioMuted(bool muted);
|
||||
bool IsAudioMuted();
|
||||
bool IsCurrentlyAudible();
|
||||
bool IsDOMReady() const;
|
||||
void Print(mate::Arguments* args);
|
||||
std::vector<printing::PrinterBasicInfo> GetPrinterList();
|
||||
void SetEmbedder(const WebContents* embedder);
|
||||
@@ -425,7 +425,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
|
||||
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
|
||||
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView()
|
||||
const override;
|
||||
#endif
|
||||
|
||||
// Called when we receive a CursorChange message from chromium.
|
||||
@@ -491,6 +492,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||
// Whether to enable devtools.
|
||||
bool enable_devtools_ = true;
|
||||
|
||||
// Whether page's document is ready.
|
||||
bool is_dom_ready_ = false;
|
||||
|
||||
// Observers of this WebContents.
|
||||
base::ObserverList<ExtendedWebContentsObserver> observers_;
|
||||
|
||||
|
||||
@@ -17,15 +17,23 @@ namespace atom {
|
||||
namespace api {
|
||||
|
||||
OffScreenWebContentsView* WebContents::GetOffScreenWebContentsView() const {
|
||||
const auto* impl =
|
||||
static_cast<const content::WebContentsImpl*>(web_contents());
|
||||
return static_cast<OffScreenWebContentsView*>(impl->GetView());
|
||||
if (IsOffScreen()) {
|
||||
const auto* impl =
|
||||
static_cast<const content::WebContentsImpl*>(web_contents());
|
||||
return static_cast<OffScreenWebContentsView*>(impl->GetView());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
OffScreenRenderWidgetHostView* WebContents::GetOffScreenRenderWidgetHostView()
|
||||
const {
|
||||
return static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (IsOffScreen()) {
|
||||
return static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -26,11 +26,12 @@ GPUInfoManager::~GPUInfoManager() {
|
||||
|
||||
// Based on
|
||||
// https://chromium.googlesource.com/chromium/src.git/+/69.0.3497.106/content/browser/gpu/gpu_data_manager_impl_private.cc#838
|
||||
bool GPUInfoManager::NeedsCompleteGpuInfoCollection() {
|
||||
#if defined(OS_WIN)
|
||||
const auto& gpu_info = gpu_data_manager_->GetGPUInfo();
|
||||
return (gpu_info.dx_diagnostics.values.empty() &&
|
||||
gpu_info.dx_diagnostics.children.empty());
|
||||
bool GPUInfoManager::NeedsCompleteGpuInfoCollection() const {
|
||||
#if defined(OS_MACOSX)
|
||||
return gpu_data_manager_->GetGPUInfo().gl_vendor.empty();
|
||||
#elif defined(OS_WIN)
|
||||
return (gpu_data_manager_->GetGPUInfo().dx_diagnostics.values.empty() &&
|
||||
gpu_data_manager_->GetGPUInfo().dx_diagnostics.children.empty());
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
|
||||
|
||||
GPUInfoManager();
|
||||
~GPUInfoManager() override;
|
||||
bool NeedsCompleteGpuInfoCollection();
|
||||
bool NeedsCompleteGpuInfoCollection() const;
|
||||
void FetchCompleteInfo(scoped_refptr<util::Promise> promise);
|
||||
void FetchBasicInfo(scoped_refptr<util::Promise> promise);
|
||||
void OnGpuInfoUpdate() override;
|
||||
|
||||
@@ -253,6 +253,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||
}
|
||||
|
||||
bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
||||
js_env_->OnMessageLoopCreated();
|
||||
exit_code_ = result_code;
|
||||
return brightray::BrowserMainParts::MainMessageLoopRun(result_code);
|
||||
}
|
||||
|
||||
@@ -217,14 +217,74 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
return settings;
|
||||
}
|
||||
|
||||
// copied from GetLoginItemForApp in base/mac/mac_util.mm
|
||||
LSSharedFileListItemRef GetLoginItemForApp() {
|
||||
base::ScopedCFTypeRef<LSSharedFileListRef> login_items(
|
||||
LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL));
|
||||
if (!login_items.get()) {
|
||||
LOG(ERROR) << "Couldn't get a Login Items list.";
|
||||
return NULL;
|
||||
}
|
||||
base::scoped_nsobject<NSArray> login_items_array(
|
||||
base::mac::CFToNSCast(LSSharedFileListCopySnapshot(login_items, NULL)));
|
||||
NSURL* url = [NSURL fileURLWithPath:[base::mac::MainBundle() bundlePath]];
|
||||
for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
|
||||
LSSharedFileListItemRef item =
|
||||
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
|
||||
CFURLRef item_url_ref = NULL;
|
||||
if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr &&
|
||||
item_url_ref) {
|
||||
base::ScopedCFTypeRef<CFURLRef> item_url(item_url_ref);
|
||||
if (CFEqual(item_url, url)) {
|
||||
CFRetain(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void RemoveFromLoginItems() {
|
||||
base::ScopedCFTypeRef<LSSharedFileListRef> list(
|
||||
LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL));
|
||||
if (!list) {
|
||||
LOG(ERROR) << "Unable to access shared file list";
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetLoginItemForApp() != NULL) {
|
||||
base::scoped_nsobject<NSArray> login_items_array(
|
||||
base::mac::CFToNSCast(LSSharedFileListCopySnapshot(list, NULL)));
|
||||
|
||||
if (!login_items_array) {
|
||||
LOG(ERROR) << "No items in list of auto-loaded apps";
|
||||
return;
|
||||
}
|
||||
|
||||
for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
|
||||
LSSharedFileListItemRef item =
|
||||
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
|
||||
CFURLRef url_ref = NULL;
|
||||
if (LSSharedFileListItemResolve(item, 0, &url_ref, NULL) == noErr &&
|
||||
item) {
|
||||
base::ScopedCFTypeRef<CFURLRef> url(url_ref);
|
||||
if ([[base::mac::CFToNSCast(url.get()) path]
|
||||
hasPrefix:[[NSBundle mainBundle] bundlePath]])
|
||||
LSSharedFileListItemRemove(list, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||
#if defined(MAS_BUILD)
|
||||
platform_util::SetLoginItemEnabled(settings.open_at_login);
|
||||
#else
|
||||
if (settings.open_at_login)
|
||||
base::mac::AddToLoginItems(settings.open_as_hidden);
|
||||
else
|
||||
base::mac::RemoveFromLoginItems();
|
||||
else {
|
||||
RemoveFromLoginItems();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "components/prefs/scoped_user_pref_update.h"
|
||||
#include "components/security_state/content/content_utils.h"
|
||||
#include "components/security_state/core/security_state.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
@@ -39,6 +40,10 @@
|
||||
#include "content/public/browser/security_style_explanations.h"
|
||||
#include "storage/browser/fileapi/isolated_context.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
||||
#endif
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
@@ -201,6 +206,11 @@ void CommonWebContentsDelegate::SetOwnerWindow(
|
||||
web_contents->RemoveUserData(
|
||||
NativeWindowRelay::kNativeWindowRelayUserDataKey);
|
||||
}
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
auto* osr_rwhv = GetOffScreenRenderWidgetHostView();
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->SetNativeWindow(owner_window);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::ResetManagedWebContents(bool async) {
|
||||
@@ -236,6 +246,13 @@ content::WebContents* CommonWebContentsDelegate::GetDevToolsWebContents()
|
||||
return web_contents_->GetDevToolsWebContents();
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
OffScreenRenderWidgetHostView*
|
||||
CommonWebContentsDelegate::GetOffScreenRenderWidgetHostView() const {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
content::WebContents* CommonWebContentsDelegate::OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "brightray/browser/inspectable_web_contents_view_delegate.h"
|
||||
#include "chrome/browser/devtools/devtools_file_system_indexer.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
|
||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
||||
#include "atom/browser/ui/autofill_popup.h"
|
||||
@@ -31,6 +32,10 @@ class AtomBrowserContext;
|
||||
class NativeWindow;
|
||||
class WebDialogHelper;
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
class OffScreenRenderWidgetHostView;
|
||||
#endif
|
||||
|
||||
class CommonWebContentsDelegate
|
||||
: public content::WebContentsDelegate,
|
||||
public brightray::InspectableWebContentsDelegate,
|
||||
@@ -65,6 +70,11 @@ class CommonWebContentsDelegate
|
||||
bool is_html_fullscreen() const { return html_fullscreen_; }
|
||||
|
||||
protected:
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
virtual OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView()
|
||||
const;
|
||||
#endif
|
||||
|
||||
// content::WebContentsDelegate:
|
||||
content::WebContents* OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/microtasks_runner.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/task_scheduler/initialization_util.h"
|
||||
@@ -62,7 +63,15 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
|
||||
return isolate;
|
||||
}
|
||||
|
||||
void JavascriptEnvironment::OnMessageLoopCreated() {
|
||||
DCHECK(!microtasks_runner_);
|
||||
microtasks_runner_.reset(new MicrotasksRunner(isolate()));
|
||||
base::MessageLoopCurrent::Get()->AddTaskObserver(microtasks_runner_.get());
|
||||
}
|
||||
|
||||
void JavascriptEnvironment::OnMessageLoopDestroying() {
|
||||
DCHECK(microtasks_runner_);
|
||||
base::MessageLoopCurrent::Get()->RemoveTaskObserver(microtasks_runner_.get());
|
||||
platform_->UnregisterIsolate(isolate_);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_
|
||||
#define ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "gin/public/isolate_holder.h"
|
||||
#include "uv.h" // NOLINT(build/include)
|
||||
@@ -16,12 +18,14 @@ class MultiIsolatePlatform;
|
||||
|
||||
namespace atom {
|
||||
|
||||
class MicrotasksRunner;
|
||||
// Manage the V8 isolate and context automatically.
|
||||
class JavascriptEnvironment {
|
||||
public:
|
||||
explicit JavascriptEnvironment(uv_loop_t* event_loop);
|
||||
~JavascriptEnvironment();
|
||||
|
||||
void OnMessageLoopCreated();
|
||||
void OnMessageLoopDestroying();
|
||||
|
||||
node::MultiIsolatePlatform* platform() const { return platform_; }
|
||||
@@ -43,6 +47,8 @@ class JavascriptEnvironment {
|
||||
v8::Global<v8::Context> context_;
|
||||
v8::Context::Scope context_scope_;
|
||||
|
||||
std::unique_ptr<MicrotasksRunner> microtasks_runner_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(JavascriptEnvironment);
|
||||
};
|
||||
|
||||
|
||||
20
atom/browser/microtasks_runner.cc
Normal file
20
atom/browser/microtasks_runner.cc
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/microtasks_runner.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
MicrotasksRunner::MicrotasksRunner(v8::Isolate* isolate) : isolate_(isolate) {}
|
||||
|
||||
void MicrotasksRunner::WillProcessTask(const base::PendingTask& pending_task) {}
|
||||
|
||||
void MicrotasksRunner::DidProcessTask(const base::PendingTask& pending_task) {
|
||||
v8::Isolate::Scope scope(isolate_);
|
||||
v8::MicrotasksScope::PerformCheckpoint(isolate_);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
36
atom/browser/microtasks_runner.h
Normal file
36
atom/browser/microtasks_runner.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_MICROTASKS_RUNNER_H_
|
||||
#define ATOM_BROWSER_MICROTASKS_RUNNER_H_
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
|
||||
namespace v8 {
|
||||
class Isolate;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
// Microtasks like promise resolution, are run at the end of the current
|
||||
// task. This class implements a task observer that runs tells v8 to run them.
|
||||
// Microtasks runner implementation is based on the EndOfTaskRunner in blink.
|
||||
// Node follows the kExplicit MicrotasksPolicy, and we do the same in browser
|
||||
// process. Hence, we need to have this task observer to flush the queued
|
||||
// microtasks.
|
||||
class MicrotasksRunner : public base::MessageLoop::TaskObserver {
|
||||
public:
|
||||
explicit MicrotasksRunner(v8::Isolate* isolate);
|
||||
|
||||
// base::MessageLoop::TaskObserver
|
||||
void WillProcessTask(const base::PendingTask& pending_task) override;
|
||||
void DidProcessTask(const base::PendingTask& pending_task) override;
|
||||
|
||||
private:
|
||||
v8::Isolate* isolate_;
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_MICROTASKS_RUNNER_H_
|
||||
@@ -153,13 +153,17 @@ void URLRequestStreamJob::OnData(std::vector<char>&& buffer) { // NOLINT
|
||||
if (pending_buf_) {
|
||||
int len = BufferCopy(&write_buffer_, pending_buf_.get(), pending_buf_size_);
|
||||
write_buffer_.erase(write_buffer_.begin(), write_buffer_.begin() + len);
|
||||
pending_buf_ = nullptr;
|
||||
pending_buf_size_ = 0;
|
||||
ReadRawDataComplete(len);
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestStreamJob::OnEnd() {
|
||||
ended_ = true;
|
||||
ReadRawDataComplete(0);
|
||||
if (pending_buf_) {
|
||||
ReadRawDataComplete(0);
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestStreamJob::OnError(int error) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "components/viz/common/frame_sinks/delay_based_time_source.h"
|
||||
#include "components/viz/common/gl_helper.h"
|
||||
#include "components/viz/common/quads/render_pass.h"
|
||||
#include "content/browser/renderer_host/cursor_manager.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/common/view_messages.h"
|
||||
@@ -264,9 +265,10 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
||||
callback_(callback),
|
||||
frame_rate_(frame_rate),
|
||||
scale_factor_(kDefaultScaleFactor),
|
||||
size_(native_window->GetSize()),
|
||||
size_(native_window ? native_window->GetSize() : gfx::Size()),
|
||||
painting_(painting),
|
||||
is_showing_(!render_widget_host_->is_hidden()),
|
||||
cursor_manager_(new content::CursorManager(this)),
|
||||
mouse_wheel_phase_handler_(this),
|
||||
weak_ptr_factory_(this) {
|
||||
DCHECK(render_widget_host_);
|
||||
@@ -280,6 +282,8 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
||||
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
|
||||
#endif
|
||||
|
||||
current_device_scale_factor_ = 1;
|
||||
|
||||
local_surface_id_ = local_surface_id_allocator_.GenerateId();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
@@ -308,7 +312,8 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
||||
#endif
|
||||
GetCompositor()->SetDelegate(this);
|
||||
|
||||
native_window_->AddObserver(this);
|
||||
if (native_window_)
|
||||
native_window_->AddObserver(this);
|
||||
|
||||
ResizeRootLayer(false);
|
||||
render_widget_host_->SetView(this);
|
||||
@@ -351,13 +356,15 @@ OffScreenRenderWidgetHostView::CreateBrowserAccessibilityManager(
|
||||
|
||||
void OffScreenRenderWidgetHostView::OnWindowResize() {
|
||||
// In offscreen mode call RenderWidgetHostView's SetSize explicitly
|
||||
auto size = native_window_->GetSize();
|
||||
auto size = native_window_ ? native_window_->GetSize() : gfx::Size();
|
||||
SetSize(size);
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::OnWindowClosed() {
|
||||
native_window_->RemoveObserver(this);
|
||||
native_window_ = nullptr;
|
||||
if (native_window_) {
|
||||
native_window_->RemoveObserver(this);
|
||||
native_window_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() {
|
||||
@@ -445,12 +452,12 @@ void OffScreenRenderWidgetHostView::Show() {
|
||||
browser_compositor_->SetRenderWidgetHostIsHidden(false);
|
||||
#else
|
||||
delegated_frame_host_->SetCompositor(compositor_.get());
|
||||
delegated_frame_host_->WasShown(
|
||||
GetLocalSurfaceId(), GetRootLayer()->bounds().size(), ui::LatencyInfo());
|
||||
delegated_frame_host_->WasShown(GetLocalSurfaceId(),
|
||||
GetRootLayer()->bounds().size(), false);
|
||||
#endif
|
||||
|
||||
if (render_widget_host_)
|
||||
render_widget_host_->WasShown(ui::LatencyInfo());
|
||||
render_widget_host_->WasShown(false);
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::Hide() {
|
||||
@@ -628,6 +635,10 @@ void OffScreenRenderWidgetHostView::InitAsFullscreen(
|
||||
|
||||
void OffScreenRenderWidgetHostView::UpdateCursor(const content::WebCursor&) {}
|
||||
|
||||
content::CursorManager* OffScreenRenderWidgetHostView::GetCursorManager() {
|
||||
return cursor_manager_.get();
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::SetIsLoading(bool loading) {}
|
||||
|
||||
void OffScreenRenderWidgetHostView::TextInputStateChanged(
|
||||
@@ -727,10 +738,6 @@ gfx::Size OffScreenRenderWidgetHostView::GetCompositorViewportPixelSize()
|
||||
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), scale_factor_);
|
||||
}
|
||||
|
||||
gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const {
|
||||
return GetDelegatedFrameHost()->GetRequestedRendererSize();
|
||||
}
|
||||
|
||||
content::RenderWidgetHostViewBase*
|
||||
OffScreenRenderWidgetHostView::CreateViewForWidget(
|
||||
content::RenderWidgetHost* render_widget_host,
|
||||
@@ -783,13 +790,14 @@ void OffScreenRenderWidgetHostView::DidReceiveFirstFrameAfterNavigation() {
|
||||
render_widget_host_->DidReceiveFirstFrameAfterNavigation();
|
||||
}
|
||||
|
||||
viz::LocalSurfaceId OffScreenRenderWidgetHostView::GetLocalSurfaceId() const {
|
||||
const viz::LocalSurfaceId& OffScreenRenderWidgetHostView::GetLocalSurfaceId()
|
||||
const {
|
||||
return local_surface_id_;
|
||||
}
|
||||
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
viz::FrameSinkId OffScreenRenderWidgetHostView::GetFrameSinkId() {
|
||||
const viz::FrameSinkId& OffScreenRenderWidgetHostView::GetFrameSinkId() const {
|
||||
return GetDelegatedFrameHost()->frame_sink_id();
|
||||
}
|
||||
|
||||
@@ -1029,7 +1037,7 @@ void OffScreenRenderWidgetHostView::SynchronizeVisualProperties() {
|
||||
ResizeRootLayer(false);
|
||||
if (render_widget_host_)
|
||||
render_widget_host_->SynchronizeVisualProperties();
|
||||
GetDelegatedFrameHost()->SynchronizeVisualProperties(
|
||||
GetDelegatedFrameHost()->EmbedSurface(
|
||||
local_surface_id_, size_, cc::DeadlinePolicy::UseDefaultDeadline());
|
||||
}
|
||||
|
||||
@@ -1240,6 +1248,18 @@ void OffScreenRenderWidgetHostView::InvalidateBounds(const gfx::Rect& bounds) {
|
||||
}
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::SetNativeWindow(NativeWindow* window) {
|
||||
if (native_window_)
|
||||
native_window_->RemoveObserver(this);
|
||||
|
||||
native_window_ = window;
|
||||
|
||||
if (native_window_)
|
||||
native_window_->AddObserver(this);
|
||||
|
||||
OnWindowResize();
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::ResizeRootLayer(bool force) {
|
||||
SetupFrameRate(false);
|
||||
|
||||
@@ -1269,7 +1289,7 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer(bool force) {
|
||||
bool resized = UpdateNSViewAndDisplay();
|
||||
#else
|
||||
bool resized = true;
|
||||
GetDelegatedFrameHost()->SynchronizeVisualProperties(
|
||||
GetDelegatedFrameHost()->EmbedSurface(
|
||||
local_surface_id_, size, cc::DeadlinePolicy::UseDefaultDeadline());
|
||||
#endif
|
||||
|
||||
|
||||
@@ -57,6 +57,10 @@ class NSWindow;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace content {
|
||||
class CursorManager;
|
||||
} // namespace content
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomCopyFrameGenerator;
|
||||
@@ -141,6 +145,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
|
||||
void RenderProcessGone(base::TerminationStatus, int) override;
|
||||
void Destroy(void) override;
|
||||
void SetTooltipText(const base::string16&) override;
|
||||
content::CursorManager* GetCursorManager() override;
|
||||
void SelectionBoundsChanged(
|
||||
const ViewHostMsg_SelectionBounds_Params&) override;
|
||||
void CopyFromSurface(
|
||||
@@ -156,7 +161,11 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
|
||||
void ImeCompositionRangeChanged(const gfx::Range&,
|
||||
const std::vector<gfx::Rect>&) override;
|
||||
gfx::Size GetCompositorViewportPixelSize() const override;
|
||||
gfx::Size GetRequestedRendererSize() const override;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties(
|
||||
const cc::RenderFrameMetadata& metadata) override;
|
||||
#endif
|
||||
|
||||
content::RenderWidgetHostViewBase* CreateViewForWidget(
|
||||
content::RenderWidgetHost*,
|
||||
@@ -175,8 +184,8 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
|
||||
void DidReceiveFirstFrameAfterNavigation() override;
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
viz::LocalSurfaceId GetLocalSurfaceId() const override;
|
||||
viz::FrameSinkId GetFrameSinkId() override;
|
||||
const viz::LocalSurfaceId& GetLocalSurfaceId() const override;
|
||||
const viz::FrameSinkId& GetFrameSinkId() const override;
|
||||
|
||||
void DidNavigate() override;
|
||||
|
||||
@@ -259,6 +268,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
|
||||
content::RenderWidgetHostImpl* render_widget_host() const {
|
||||
return render_widget_host_;
|
||||
}
|
||||
void SetNativeWindow(NativeWindow* window);
|
||||
NativeWindow* window() const { return native_window_; }
|
||||
gfx::Size size() const { return size_; }
|
||||
float scale_factor() const { return scale_factor_; }
|
||||
@@ -272,6 +282,12 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
|
||||
}
|
||||
|
||||
private:
|
||||
#if defined(OS_MACOSX)
|
||||
display::Display GetDisplay();
|
||||
void OnDidUpdateVisualPropertiesComplete(
|
||||
const cc::RenderFrameMetadata& metadata);
|
||||
#endif
|
||||
|
||||
void SetupFrameRate(bool force);
|
||||
void ResizeRootLayer(bool force);
|
||||
|
||||
@@ -324,6 +340,8 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
|
||||
std::unique_ptr<ui::Compositor> compositor_;
|
||||
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
|
||||
|
||||
std::unique_ptr<content::CursorManager> cursor_manager_;
|
||||
|
||||
std::unique_ptr<AtomCopyFrameGenerator> copy_frame_generator_;
|
||||
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
|
||||
|
||||
|
||||
@@ -11,21 +11,13 @@
|
||||
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
|
||||
#include "ui/display/screen.h"
|
||||
|
||||
namespace {
|
||||
|
||||
display::Display GetDisplay() {
|
||||
return display::Screen::GetScreen()->GetDisplayNearestView(nullptr);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace atom {
|
||||
|
||||
class MacHelper : public content::BrowserCompositorMacClient,
|
||||
public ui::AcceleratedWidgetMacNSView {
|
||||
public:
|
||||
explicit MacHelper(OffScreenRenderWidgetHostView* view) : view_(view) {
|
||||
[this->AcceleratedWidgetGetNSView() setWantsLayer:YES];
|
||||
[view_->GetNativeView() setWantsLayer:YES];
|
||||
}
|
||||
|
||||
virtual ~MacHelper() {}
|
||||
@@ -48,11 +40,6 @@ class MacHelper : public content::BrowserCompositorMacClient,
|
||||
view_->render_widget_host()->DidProcessFrame(frame_token);
|
||||
}
|
||||
|
||||
// ui::AcceleratedWidgetMacNSView:
|
||||
NSView* AcceleratedWidgetGetNSView() const override {
|
||||
return [view_->window()->GetNativeWindow() contentView];
|
||||
}
|
||||
|
||||
void AcceleratedWidgetCALayerParamsUpdated() override {}
|
||||
|
||||
void DidReceiveFirstFrameAfterNavigation() override {
|
||||
@@ -61,7 +48,22 @@ class MacHelper : public content::BrowserCompositorMacClient,
|
||||
|
||||
void DestroyCompositorForShutdown() override {}
|
||||
|
||||
bool SynchronizeVisualProperties() override {
|
||||
bool SynchronizeVisualProperties(
|
||||
const base::Optional<viz::LocalSurfaceId>&
|
||||
child_allocated_local_surface_id) override {
|
||||
auto* browser_compositor = view_->browser_compositor();
|
||||
if (child_allocated_local_surface_id) {
|
||||
browser_compositor->UpdateRendererLocalSurfaceIdFromChild(
|
||||
*child_allocated_local_surface_id);
|
||||
} else {
|
||||
browser_compositor->AllocateNewRendererLocalSurfaceId();
|
||||
}
|
||||
|
||||
if (auto* host = browser_compositor->GetDelegatedFrameHost()) {
|
||||
host->EmbedSurface(browser_compositor->GetRendererLocalSurfaceId(),
|
||||
browser_compositor->GetRendererSize(),
|
||||
cc::DeadlinePolicy::UseDefaultDeadline());
|
||||
}
|
||||
return view_->render_widget_host()->SynchronizeVisualProperties();
|
||||
}
|
||||
|
||||
@@ -90,8 +92,8 @@ void OffScreenRenderWidgetHostView::CreatePlatformWidget(
|
||||
bool is_guest_view_hack) {
|
||||
mac_helper_ = new MacHelper(this);
|
||||
browser_compositor_.reset(new content::BrowserCompositorMac(
|
||||
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true,
|
||||
GetDisplay(), AllocateFrameSinkId(is_guest_view_hack)));
|
||||
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), GetDisplay(),
|
||||
AllocateFrameSinkId(is_guest_view_hack)));
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
|
||||
@@ -99,7 +101,48 @@ void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
|
||||
delete mac_helper_;
|
||||
}
|
||||
|
||||
viz::LocalSurfaceId OffScreenRenderWidgetHostView::GetLocalSurfaceId() const {
|
||||
viz::ScopedSurfaceIdAllocator
|
||||
OffScreenRenderWidgetHostView::DidUpdateVisualProperties(
|
||||
const cc::RenderFrameMetadata& metadata) {
|
||||
base::OnceCallback<void()> allocation_task = base::BindOnce(
|
||||
base::IgnoreResult(
|
||||
&OffScreenRenderWidgetHostView::OnDidUpdateVisualPropertiesComplete),
|
||||
weak_ptr_factory_.GetWeakPtr(), metadata);
|
||||
return browser_compositor_->GetScopedRendererSurfaceIdAllocator(
|
||||
std::move(allocation_task));
|
||||
}
|
||||
|
||||
display::Display OffScreenRenderWidgetHostView::GetDisplay() {
|
||||
content::ScreenInfo screen_info;
|
||||
GetScreenInfo(&screen_info);
|
||||
|
||||
// Start with a reasonable display representation.
|
||||
display::Display display =
|
||||
display::Screen::GetScreen()->GetDisplayNearestView(nullptr);
|
||||
|
||||
// Populate attributes based on |screen_info|.
|
||||
display.set_bounds(screen_info.rect);
|
||||
display.set_work_area(screen_info.available_rect);
|
||||
display.set_device_scale_factor(screen_info.device_scale_factor);
|
||||
display.set_color_space(screen_info.color_space);
|
||||
display.set_color_depth(screen_info.depth);
|
||||
display.set_depth_per_component(screen_info.depth_per_component);
|
||||
display.set_is_monochrome(screen_info.is_monochrome);
|
||||
display.SetRotationAsDegree(screen_info.orientation_angle);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::OnDidUpdateVisualPropertiesComplete(
|
||||
const cc::RenderFrameMetadata& metadata) {
|
||||
DCHECK_EQ(current_device_scale_factor_, metadata.device_scale_factor);
|
||||
browser_compositor_->SynchronizeVisualProperties(
|
||||
metadata.device_scale_factor, metadata.viewport_size_in_pixels,
|
||||
metadata.local_surface_id.value_or(viz::LocalSurfaceId()));
|
||||
}
|
||||
|
||||
const viz::LocalSurfaceId& OffScreenRenderWidgetHostView::GetLocalSurfaceId()
|
||||
const {
|
||||
return browser_compositor_->GetRendererLocalSurfaceId();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
|
||||
auto* relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay)
|
||||
return gfx::NativeView();
|
||||
return relay->window->GetNativeView();
|
||||
return relay->GetNativeWindow()->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
|
||||
@@ -52,7 +52,7 @@ gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
|
||||
auto* relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay)
|
||||
return gfx::NativeView();
|
||||
return relay->window->GetNativeView();
|
||||
return relay->GetNativeWindow()->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
|
||||
@@ -62,7 +62,7 @@ gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
|
||||
auto* relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay)
|
||||
return gfx::NativeWindow();
|
||||
return relay->window->GetNativeWindow();
|
||||
return relay->GetNativeWindow()->GetNativeWindow();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -102,17 +102,14 @@ OffScreenWebContentsView::CreateViewForWidget(
|
||||
render_widget_host->GetView());
|
||||
}
|
||||
|
||||
auto* relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
return new OffScreenRenderWidgetHostView(
|
||||
transparent_, painting_, GetFrameRate(), callback_, render_widget_host,
|
||||
nullptr, relay->window.get());
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
content::RenderWidgetHostViewBase*
|
||||
OffScreenWebContentsView::CreateViewForPopupWidget(
|
||||
content::RenderWidgetHost* render_widget_host) {
|
||||
auto* relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
|
||||
content::WebContentsImpl* web_contents_impl =
|
||||
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||
|
||||
@@ -123,9 +120,9 @@ OffScreenWebContentsView::CreateViewForPopupWidget(
|
||||
->GetRenderWidgetHostView()
|
||||
: web_contents_impl->GetRenderWidgetHostView());
|
||||
|
||||
return new OffScreenRenderWidgetHostView(
|
||||
transparent_, true, view->GetFrameRate(), callback_, render_widget_host,
|
||||
view, relay->window.get());
|
||||
return new OffScreenRenderWidgetHostView(transparent_, true,
|
||||
view->GetFrameRate(), callback_,
|
||||
render_widget_host, view, nullptr);
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {}
|
||||
@@ -140,8 +137,11 @@ void OffScreenWebContentsView::RenderViewCreated(
|
||||
#endif
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::RenderViewSwappedIn(
|
||||
content::RenderViewHost* host) {}
|
||||
void OffScreenWebContentsView::RenderViewReady() {}
|
||||
|
||||
void OffScreenWebContentsView::RenderViewHostChanged(
|
||||
content::RenderViewHost* old_host,
|
||||
content::RenderViewHost* new_host) {}
|
||||
|
||||
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {}
|
||||
|
||||
|
||||
@@ -50,7 +50,9 @@ class OffScreenWebContentsView : public content::WebContentsView,
|
||||
content::RenderWidgetHost* render_widget_host) override;
|
||||
void SetPageTitle(const base::string16& title) override;
|
||||
void RenderViewCreated(content::RenderViewHost* host) override;
|
||||
void RenderViewSwappedIn(content::RenderViewHost* host) override;
|
||||
void RenderViewReady() override;
|
||||
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
||||
content::RenderViewHost* new_host) override;
|
||||
void SetOverscrollControllerEnabled(bool enabled) override;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
||||
@@ -50,8 +50,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,0,0,20181010
|
||||
PRODUCTVERSION 4,0,0,20181010
|
||||
FILEVERSION 4,0,0,4
|
||||
PRODUCTVERSION 4,0,0,4
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
||||
@@ -397,6 +397,8 @@ void WebContentsPreferences::OverrideWebkitPrefs(
|
||||
std::string encoding;
|
||||
if (GetAsString(&preference_, "defaultEncoding", &encoding))
|
||||
prefs->default_encoding = encoding;
|
||||
|
||||
prefs->node_integration = IsEnabled(options::kNodeIntegration);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define ATOM_MINOR_VERSION 0
|
||||
#define ATOM_PATCH_VERSION 0
|
||||
// clang-format off
|
||||
#define ATOM_PRE_RELEASE_VERSION -nightly.20181010
|
||||
#define ATOM_PRE_RELEASE_VERSION -beta.4
|
||||
// clang-format on
|
||||
|
||||
#ifndef ATOM_STRINGIFY
|
||||
|
||||
@@ -21,8 +21,7 @@ v8::Maybe<bool> Promise::RejectWithErrorMessage(const std::string& string) {
|
||||
v8::Local<v8::String> error_message =
|
||||
v8::String::NewFromUtf8(isolate(), string.c_str());
|
||||
v8::Local<v8::Value> error = v8::Exception::Error(error_message);
|
||||
return GetInner()->Reject(isolate()->GetCurrentContext(),
|
||||
mate::ConvertToV8(isolate(), error));
|
||||
return Reject(error);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Promise::GetHandle() const {
|
||||
|
||||
@@ -32,6 +32,8 @@ class Promise : public base::RefCounted<Promise> {
|
||||
v8::Undefined(isolate()));
|
||||
}
|
||||
|
||||
// Promise resolution is a microtask
|
||||
// We use the MicrotasksRunner to trigger the running of pending microtasks
|
||||
template <typename T>
|
||||
v8::Maybe<bool> Resolve(const T& value) {
|
||||
return GetInner()->Resolve(isolate()->GetCurrentContext(),
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "atom/renderer/atom_render_frame_observer.h"
|
||||
#include "atom/renderer/web_worker_observer.h"
|
||||
#include "base/command_line.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/blink/public/web/web_document.h"
|
||||
@@ -86,6 +87,15 @@ void AtomRendererClient::DidCreateScriptContext(
|
||||
if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame))
|
||||
return;
|
||||
|
||||
// Don't allow node integration if this is a child window and it does not have
|
||||
// node integration enabled. Otherwise we would have memory leak in the child
|
||||
// window since we don't clean up node environments.
|
||||
//
|
||||
// TODO(zcbenz): We shouldn't allow node integration even for the top frame.
|
||||
if (!render_frame->GetWebkitPreferences().node_integration &&
|
||||
render_frame->GetWebFrame()->Opener())
|
||||
return;
|
||||
|
||||
injected_frames_.insert(render_frame);
|
||||
|
||||
// Prepare the node bindings.
|
||||
|
||||
@@ -177,22 +177,26 @@ void RendererClientBase::RenderFrameCreated(
|
||||
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
||||
GURL(kPdfViewerUIOrigin), "file", "", true);
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
content::RenderView* render_view = render_frame->GetRenderView();
|
||||
if (render_frame->IsMainFrame() && render_view) {
|
||||
blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget();
|
||||
if (web_frame_widget) {
|
||||
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
|
||||
if (cmd->HasSwitch(switches::kGuestInstanceID)) { // webview.
|
||||
web_frame_widget->SetBaseBackgroundColor(SK_ColorTRANSPARENT);
|
||||
} else { // normal window.
|
||||
std::string name = cmd->GetSwitchValueASCII(switches::kBackgroundColor);
|
||||
SkColor color =
|
||||
name.empty() ? SK_ColorTRANSPARENT : ParseHexColor(name);
|
||||
web_frame_widget->SetBaseBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
||||
new AtomRenderViewObserver(render_view);
|
||||
blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget();
|
||||
if (!web_frame_widget)
|
||||
return;
|
||||
|
||||
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
|
||||
if (cmd->HasSwitch(switches::kGuestInstanceID)) { // webview.
|
||||
web_frame_widget->SetBaseBackgroundColor(SK_ColorTRANSPARENT);
|
||||
} else { // normal window.
|
||||
std::string name = cmd->GetSwitchValueASCII(switches::kBackgroundColor);
|
||||
SkColor color = name.empty() ? SK_ColorTRANSPARENT : ParseHexColor(name);
|
||||
web_frame_widget->SetBaseBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererClientBase::DidClearWindowObject(
|
||||
|
||||
@@ -4,6 +4,7 @@ root_extra_deps = [ "//electron" ]
|
||||
|
||||
v8_promise_internal_field_count = 1
|
||||
v8_typed_array_max_size_in_heap = 0
|
||||
v8_embedder_string = "-electron.0"
|
||||
|
||||
enable_cdm_host_verification = false
|
||||
enable_extensions = false
|
||||
|
||||
6
build/electron.def
Normal file
6
build/electron.def
Normal file
@@ -0,0 +1,6 @@
|
||||
; This is to support renaming of electron.exe. node-gyp has hard-coded
|
||||
; executable names which it will recognise as node. This module definition
|
||||
; file claims that the electron executable is in fact named "node.exe",
|
||||
; which is one of the executable names that node-gyp recognizes.
|
||||
; See https://github.com/nodejs/node-gyp/commit/52ceec3a6d15de3a8f385f43dbe5ecf5456ad07a
|
||||
NAME node.exe
|
||||
@@ -8,7 +8,7 @@ declare_args() {
|
||||
# Allow running Electron as a node binary.
|
||||
enable_run_as_node = true
|
||||
|
||||
enable_osr = false
|
||||
enable_osr = true
|
||||
|
||||
enable_view_api = false
|
||||
|
||||
|
||||
@@ -995,7 +995,7 @@ Returns `Object`:
|
||||
the app as a login item. Defaults to `false`.
|
||||
* `openAsHidden` Boolean (optional) _macOS_ - `true` to open the app as hidden. Defaults to
|
||||
`false`. The user can edit this setting from the System Preferences so
|
||||
`app.getLoginItemStatus().wasOpenedAsHidden` should be checked when the app
|
||||
`app.getLoginItemSettings().wasOpenedAsHidden` should be checked when the app
|
||||
is opened to know the current value. This setting is not available on [MAS builds][mas-builds].
|
||||
* `path` String (optional) _Windows_ - The executable to launch at login.
|
||||
Defaults to `process.execPath`.
|
||||
|
||||
@@ -18,6 +18,9 @@ The following `webPreferences` option default values are deprecated in favor of
|
||||
| `nodeIntegration` | `true` | `false` |
|
||||
| `webviewTag` | `nodeIntegration` if set else `true` | `false` |
|
||||
|
||||
## `nativeWindowOpen`
|
||||
|
||||
Child windows opened with the `nativeWindowOpen` option will always have Node.js integration disabled.
|
||||
|
||||
# Planned Breaking API Changes (4.0)
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
> Create and control views.
|
||||
|
||||
**Note:** The BrowserView API is currently experimental and may change or be
|
||||
removed in future Electron releases.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
A `BrowserView` can be used to embed additional web content into a
|
||||
|
||||
@@ -270,6 +270,8 @@ filenames = {
|
||||
"atom/browser/mac/in_app_purchase_observer.mm",
|
||||
"atom/browser/mac/in_app_purchase_product.h",
|
||||
"atom/browser/mac/in_app_purchase_product.mm",
|
||||
"atom/browser/microtasks_runner.cc",
|
||||
"atom/browser/microtasks_runner.h",
|
||||
"atom/browser/native_browser_view.cc",
|
||||
"atom/browser/native_browser_view.h",
|
||||
"atom/browser/native_browser_view_mac.h",
|
||||
|
||||
@@ -49,6 +49,23 @@ BrowserWindow.prototype._init = function () {
|
||||
return
|
||||
}
|
||||
|
||||
if (webContents.getLastWebPreferences().nodeIntegration === true) {
|
||||
const message =
|
||||
'Enabling Node.js integration in child windows opened with the ' +
|
||||
'"nativeWindowOpen" option will cause memory leaks, please turn off ' +
|
||||
'the "nodeIntegration" option.\\n' +
|
||||
'From 5.x child windows opened with the "nativeWindowOpen" option ' +
|
||||
'will always have Node.js integration disabled.\\n' +
|
||||
'See https://github.com/electron/electron/pull/15076 for more.'
|
||||
// console is only available after DOM is created.
|
||||
const printWarning = () => this.webContents.executeJavaScript(`console.warn('${message}')`)
|
||||
if (this.webContents.isDomReady()) {
|
||||
printWarning()
|
||||
} else {
|
||||
this.webContents.once('dom-ready', printWarning)
|
||||
}
|
||||
}
|
||||
|
||||
const { url, frameName } = urlFrameName
|
||||
v8Util.deleteHiddenValue(webContents, 'url-framename')
|
||||
const options = {
|
||||
|
||||
@@ -376,7 +376,7 @@ handleRemoteCommand('ELECTRON_BROWSER_GUEST_WEB_CONTENTS', function (event, cont
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function (event, requestId, guestInstanceId, method, args, hasCallback) {
|
||||
new Promise(resolve => {
|
||||
const guestViewManager = require('./guest-view-manager')
|
||||
const guestViewManager = require('@electron/internal/browser/guest-view-manager')
|
||||
const guest = guestViewManager.getGuest(guestInstanceId)
|
||||
if (guest.hostWebContents !== event.sender) {
|
||||
throw new Error('Access denied')
|
||||
@@ -428,6 +428,7 @@ const getTempDirectory = function () {
|
||||
const crashReporterInit = function (options) {
|
||||
const productName = options.productName || electron.app.getName()
|
||||
const crashesDirectory = path.join(getTempDirectory(), `${productName} Crashes`)
|
||||
let crashServicePid
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
const env = {
|
||||
@@ -440,15 +441,18 @@ const crashReporterInit = function (options) {
|
||||
'--v=1'
|
||||
]
|
||||
|
||||
spawn(process.helperExecPath, args, {
|
||||
const crashServiceProcess = spawn(process.helperExecPath, args, {
|
||||
env,
|
||||
detached: true
|
||||
})
|
||||
|
||||
crashServicePid = crashServiceProcess.pid
|
||||
}
|
||||
|
||||
return {
|
||||
productName,
|
||||
crashesDirectory,
|
||||
crashServicePid,
|
||||
appVersion: electron.app.getVersion()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,20 +292,6 @@
|
||||
process.nextTick(() => fs.lstat(pathArgument, callback))
|
||||
}
|
||||
|
||||
const { statSyncNoException } = fs
|
||||
fs.statSyncNoException = pathArgument => {
|
||||
const { isAsar, asarPath, filePath } = splitPath(pathArgument)
|
||||
if (!isAsar) return statSyncNoException(pathArgument)
|
||||
|
||||
const archive = getOrCreateArchive(asarPath)
|
||||
if (!archive) return false
|
||||
|
||||
const stats = archive.stat(filePath)
|
||||
if (!stats) return false
|
||||
|
||||
return asarStatsToFsStats(stats)
|
||||
}
|
||||
|
||||
const { realpathSync } = fs
|
||||
fs.realpathSync = function (pathArgument) {
|
||||
const { isAsar, asarPath, filePath } = splitPath(pathArgument)
|
||||
|
||||
@@ -58,6 +58,7 @@ class CrashReporter {
|
||||
|
||||
this.productName = ret.productName
|
||||
this.crashesDirectory = ret.crashesDirectory
|
||||
this.crashServicePid = ret.crashServicePid
|
||||
|
||||
if (extra == null) extra = {}
|
||||
if (extra._productName == null) extra._productName = ret.productName
|
||||
|
||||
@@ -5,8 +5,7 @@ window.onload = function () {
|
||||
window.InspectorFrontendHost.showContextMenuAtPoint = createMenu
|
||||
|
||||
// Use dialog API to override file chooser dialog.
|
||||
// Note: It will be moved to UI after Chrome 57.
|
||||
window.Bindings.createFileSelectorElement = createFileSelectorElement
|
||||
window.UI.createFileSelectorElement = createFileSelectorElement
|
||||
}
|
||||
|
||||
window.confirm = function (message, title) {
|
||||
|
||||
@@ -47,6 +47,7 @@ class WebViewImpl {
|
||||
createInternalElement () {
|
||||
const iframeElement = document.createElement('iframe')
|
||||
iframeElement.style.flex = '1 1 auto'
|
||||
iframeElement.style.width = '100%'
|
||||
iframeElement.style.border = '0'
|
||||
v8Util.setHiddenValue(iframeElement, 'internal', this)
|
||||
return iframeElement
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "4.0.0-nightly.20181010",
|
||||
"version": "4.0.0-beta.4",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "4.0.0-nightly.20181010",
|
||||
"version": "4.0.0-beta.4",
|
||||
"repository": "https://github.com/electron/electron",
|
||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||
"devDependencies": {
|
||||
@@ -45,7 +45,7 @@
|
||||
"check-tls": "python ./script/tls.py",
|
||||
"clang-format": "find atom/ brightray/ chromium_src/ -iname *.h -o -iname *.cc -o -iname *.mm | xargs clang-format -i",
|
||||
"lint": "node ./script/lint.js && npm run lint:clang-format && npm run lint:docs",
|
||||
"lint:js": ".node /script/lint.js --js",
|
||||
"lint:js": "node ./script/lint.js --js",
|
||||
"lint:clang-format": "python script/run-clang-format.py -r -c atom/ chromium_src/ brightray/ || (echo \"\\nCode not formatted correctly.\" && exit 1)",
|
||||
"lint:cpp": "node ./script/lint.js --cc",
|
||||
"lint:py": "node ./script/lint.js --py",
|
||||
|
||||
@@ -491,3 +491,12 @@ patches:
|
||||
dylib currently fails to resolve Squirrel.framework on OSX, we need to fix
|
||||
this but it is not a blocker for releasing Electron. This patch removes
|
||||
the hard fail on dylib resolve failure from dump_syms
|
||||
-
|
||||
author: zcbenz <zcbenz@gmail.com>
|
||||
file: web_preferences.patch
|
||||
description: |
|
||||
Add a node_integration field to WebPreferences so we can determine whether
|
||||
a frame has node integration in renderer process.
|
||||
|
||||
This is required by the nativeWindowOpen option, which put multiple main
|
||||
frames in one renderer process.
|
||||
|
||||
26
patches/common/chromium/web_preferences.patch
Normal file
26
patches/common/chromium/web_preferences.patch
Normal file
@@ -0,0 +1,26 @@
|
||||
diff --git a/content/public/common/common_param_traits_macros.h b/content/public/common/common_param_traits_macros.h
|
||||
index 57f03dc..7c4409e 100644
|
||||
--- a/content/public/common/common_param_traits_macros.h
|
||||
+++ b/content/public/common/common_param_traits_macros.h
|
||||
@@ -198,6 +198,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences)
|
||||
IPC_STRUCT_TRAITS_MEMBER(animation_policy)
|
||||
IPC_STRUCT_TRAITS_MEMBER(user_gesture_required_for_presentation)
|
||||
IPC_STRUCT_TRAITS_MEMBER(text_track_margin_percentage)
|
||||
+ IPC_STRUCT_TRAITS_MEMBER(node_integration)
|
||||
IPC_STRUCT_TRAITS_MEMBER(save_previous_document_resources)
|
||||
IPC_STRUCT_TRAITS_MEMBER(text_autosizing_enabled)
|
||||
IPC_STRUCT_TRAITS_MEMBER(double_tap_to_zoom_enabled)
|
||||
diff --git a/content/public/common/web_preferences.h b/content/public/common/web_preferences.h
|
||||
index 78cbf5f..b33ac28 100644
|
||||
--- a/content/public/common/web_preferences.h
|
||||
+++ b/content/public/common/web_preferences.h
|
||||
@@ -222,6 +222,9 @@ struct CONTENT_EXPORT WebPreferences {
|
||||
// Cues will not be placed in this margin area.
|
||||
float text_track_margin_percentage;
|
||||
|
||||
+ // Electron: Whether the frame has node integration.
|
||||
+ bool node_integration = false;
|
||||
+
|
||||
bool immersive_mode_enabled;
|
||||
|
||||
bool text_autosizing_enabled;
|
||||
@@ -78,8 +78,7 @@ def generate_posix_symbols(binary, source_root, build_dir, destination):
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description='Create breakpad symbols')
|
||||
parser.add_argument('-b', '--build-dir',
|
||||
help='Path to an Electron build folder. \
|
||||
Relative to the --source-root.',
|
||||
help='Path to an Electron build folder.',
|
||||
default=RELEASE_PATH,
|
||||
required=False)
|
||||
parser.add_argument('-d', '--destination',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
@@ -17,29 +18,38 @@ def main():
|
||||
if get_target_arch() == 'mips64el':
|
||||
return
|
||||
|
||||
args = parse_args()
|
||||
dist_name = 'symbols.zip'
|
||||
zip_file = os.path.join(OUT_DIR, dist_name)
|
||||
zip_file = os.path.join(args.build_dir, dist_name)
|
||||
licenses = ['LICENSE', 'LICENSES.chromium.html', 'version']
|
||||
|
||||
with scoped_cwd(OUT_DIR):
|
||||
with scoped_cwd(args.build_dir):
|
||||
dirs = ['{0}.breakpad.syms'.format(PROJECT_NAME)]
|
||||
print('Making symbol zip: ' + zip_file)
|
||||
make_zip(zip_file, licenses, dirs)
|
||||
|
||||
if PLATFORM == 'darwin':
|
||||
dsym_name = 'dsym.zip'
|
||||
with scoped_cwd(OUT_DIR):
|
||||
with scoped_cwd(args.build_dir):
|
||||
dsyms = glob.glob('*.dSYM')
|
||||
dsym_zip_file = os.path.join(OUT_DIR, dsym_name)
|
||||
dsym_zip_file = os.path.join(args.build_dir, dsym_name)
|
||||
print('Making dsym zip: ' + dsym_zip_file)
|
||||
make_zip(dsym_zip_file, licenses, dsyms)
|
||||
elif PLATFORM == 'win32':
|
||||
pdb_name = 'pdb.zip'
|
||||
with scoped_cwd(OUT_DIR):
|
||||
with scoped_cwd(args.build_dir):
|
||||
pdbs = glob.glob('*.pdb')
|
||||
pdb_zip_file = os.path.join(OUT_DIR, pdb_name)
|
||||
pdb_zip_file = os.path.join(args.build_dir, pdb_name)
|
||||
print('Making pdb zip: ' + pdb_zip_file)
|
||||
make_zip(pdb_zip_file, pdbs + licenses, [])
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description='Zip symbols')
|
||||
parser.add_argument('-b', '--build-dir',
|
||||
help='Path to an Electron build folder.',
|
||||
default=OUT_DIR,
|
||||
required=False)
|
||||
return parser.parse_args()
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
sys.exit(main())
|
||||
|
||||
@@ -432,16 +432,23 @@ describe('app module', () => {
|
||||
app.setLoginItemSettings({ openAtLogin: false, path: updateExe, args: processStartArgs })
|
||||
})
|
||||
|
||||
it('returns the login item status of the app', done => {
|
||||
it('sets and returns the app as a login item', done => {
|
||||
app.setLoginItemSettings({ openAtLogin: true })
|
||||
expect(app.getLoginItemSettings()).to.deep.equal({
|
||||
openAtLogin: true,
|
||||
openAsHidden: false,
|
||||
wasOpenedAtLogin: false,
|
||||
wasOpenedAsHidden: false,
|
||||
restoreState: false
|
||||
})
|
||||
// Wait because login item settings are not applied immediately in MAS build
|
||||
const delay = process.mas ? 150 : 0
|
||||
setTimeout(() => {
|
||||
expect(app.getLoginItemSettings()).to.deep.equal({
|
||||
openAtLogin: true,
|
||||
openAsHidden: false,
|
||||
wasOpenedAtLogin: false,
|
||||
wasOpenedAsHidden: false,
|
||||
restoreState: false
|
||||
})
|
||||
done()
|
||||
}, delay)
|
||||
})
|
||||
|
||||
it('adds a login item that loads in hidden mode', () => {
|
||||
app.setLoginItemSettings({ openAtLogin: true, openAsHidden: true })
|
||||
expect(app.getLoginItemSettings()).to.deep.equal({
|
||||
openAtLogin: true,
|
||||
@@ -450,20 +457,21 @@ describe('app module', () => {
|
||||
wasOpenedAsHidden: false,
|
||||
restoreState: false
|
||||
})
|
||||
})
|
||||
|
||||
app.setLoginItemSettings({})
|
||||
// Wait because login item settings are not applied immediately in MAS build
|
||||
const delay = process.mas ? 100 : 0
|
||||
setTimeout(() => {
|
||||
expect(app.getLoginItemSettings()).to.deep.equal({
|
||||
openAtLogin: false,
|
||||
openAsHidden: false,
|
||||
wasOpenedAtLogin: false,
|
||||
wasOpenedAsHidden: false,
|
||||
restoreState: false
|
||||
})
|
||||
done()
|
||||
}, delay)
|
||||
it('correctly sets and unsets the LoginItem as hidden', function () {
|
||||
if (process.platform !== 'darwin' || process.mas) this.skip()
|
||||
|
||||
expect(app.getLoginItemSettings().openAtLogin).to.be.false()
|
||||
expect(app.getLoginItemSettings().openAsHidden).to.be.false()
|
||||
|
||||
app.setLoginItemSettings({ openAtLogin: true, openAsHidden: true })
|
||||
expect(app.getLoginItemSettings().openAtLogin).to.be.true()
|
||||
expect(app.getLoginItemSettings().openAsHidden).to.be.true()
|
||||
|
||||
app.setLoginItemSettings({ openAtLogin: true, openAsHidden: false })
|
||||
expect(app.getLoginItemSettings().openAtLogin).to.be.true()
|
||||
expect(app.getLoginItemSettings().openAsHidden).to.be.false()
|
||||
})
|
||||
|
||||
it('allows you to pass a custom executable and arguments', function () {
|
||||
@@ -844,10 +852,9 @@ describe('app module', () => {
|
||||
await verifyBasicGPUInfo(gpuInfo)
|
||||
})
|
||||
|
||||
// FIXME: this broke with the M69 upgrade.
|
||||
xit('succeeds with complete GPUInfo', async () => {
|
||||
it('succeeds with complete GPUInfo', async () => {
|
||||
const completeInfo = await getGPUInfo('complete')
|
||||
if (process.platform === 'linux' || process.platform === 'darwin') {
|
||||
if (process.platform === 'linux') {
|
||||
// For linux and macOS complete info is same as basic info
|
||||
await verifyBasicGPUInfo(completeInfo)
|
||||
const basicInfo = await getGPUInfo('basic')
|
||||
@@ -864,11 +871,8 @@ describe('app module', () => {
|
||||
|
||||
it('fails for invalid info_type', () => {
|
||||
const invalidType = 'invalid'
|
||||
const errorMessage =
|
||||
`app.getGPUInfo() didn't fail for the "${invalidType}" info type`
|
||||
return app.getGPUInfo(invalidType).then(
|
||||
() => Promise.reject(new Error(errorMessage)),
|
||||
() => Promise.resolve())
|
||||
const expectedErrorMessage = "Invalid info type. Use 'basic' or 'complete'"
|
||||
return expect(app.getGPUInfo(invalidType)).to.eventually.be.rejectedWith(expectedErrorMessage)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -125,9 +125,7 @@ describe('webContents module', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// FIXME: this is broken on mac in the M69 upgrade, fix & re-enable before
|
||||
// release
|
||||
xdescribe('isCurrentlyAudible() API', () => {
|
||||
describe('isCurrentlyAudible() API', () => {
|
||||
it('returns whether audio is playing', async () => {
|
||||
const webContents = remote.getCurrentWebContents()
|
||||
const context = new window.AudioContext()
|
||||
|
||||
2
spec/fixtures/api/crash-restart.html
vendored
2
spec/fixtures/api/crash-restart.html
vendored
@@ -19,7 +19,7 @@ crashReporter.start({
|
||||
})
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
ipcRenderer.sendSync('crash-service-pid', crashReporter._crashServiceProcess.pid)
|
||||
ipcRenderer.sendSync('crash-service-pid', crashReporter.crashServicePid)
|
||||
}
|
||||
|
||||
setImmediate(() => {
|
||||
|
||||
2
spec/fixtures/api/crash.html
vendored
2
spec/fixtures/api/crash.html
vendored
@@ -20,7 +20,7 @@
|
||||
})
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
ipcRenderer.sendSync('crash-service-pid', crashReporter._crashServiceProcess.pid)
|
||||
ipcRenderer.sendSync('crash-service-pid', crashReporter.crashServicePid)
|
||||
}
|
||||
|
||||
if (!uploadToServer) {
|
||||
|
||||
6
spec/fixtures/module/runas-renamed.js
vendored
Normal file
6
spec/fixtures/module/runas-renamed.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
try {
|
||||
require('runas')
|
||||
} catch (e) {
|
||||
process.exit(1)
|
||||
}
|
||||
process.exit(0)
|
||||
@@ -1,6 +1,7 @@
|
||||
const assert = require('assert')
|
||||
const Module = require('module')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const { remote } = require('electron')
|
||||
const { BrowserWindow } = remote
|
||||
const { closeWindow } = require('./window-helpers')
|
||||
@@ -24,6 +25,22 @@ describe('modules support', () => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
it('can be required if electron.exe is renamed', () => {
|
||||
const { execPath } = remote.process
|
||||
const testExecPath = path.join(path.dirname(execPath), 'test.exe')
|
||||
fs.copyFileSync(execPath, testExecPath)
|
||||
try {
|
||||
const runasFixture = path.join(fixtures, 'module', 'runas-renamed.js')
|
||||
assert.ok(fs.existsSync(runasFixture))
|
||||
const child = require('child_process').spawnSync(testExecPath, [runasFixture])
|
||||
assert.strictEqual(child.status, 0)
|
||||
} finally {
|
||||
fs.unlinkSync(testExecPath)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// TODO(alexeykuzmin): Disabled during the Chromium 62 (Node.js 9) upgrade.
|
||||
|
||||
24
vsts.yml
24
vsts.yml
@@ -8,11 +8,16 @@ jobs:
|
||||
CI: true
|
||||
steps:
|
||||
|
||||
- bash: |
|
||||
git clean -fdx
|
||||
displayName: Clean unneeded git directories
|
||||
timeoutInMinutes: 2
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: 'Copy Files to: src/electron'
|
||||
inputs:
|
||||
TargetFolder: src/electron
|
||||
timeoutInMinutes: 1
|
||||
timeoutInMinutes: 2
|
||||
|
||||
- bash: |
|
||||
export PATH="$PATH:/Users/electron/depot_tools"
|
||||
@@ -208,10 +213,8 @@ jobs:
|
||||
# Run this job only if we are supposed to run the tests,
|
||||
# and we have an Electron built either in the previous job or in a different job, defined by a user.
|
||||
condition: and(eq(variables['RUN_TESTS'], '1'), or(succeeded(), ne(variables['Custom.UseArtifacts.BuildId'], '')))
|
||||
# TODO(alexeykuzmin): Run on Microsoft-hosted agents
|
||||
# once https://github.com/electron/electron/issues/15041 is fixed.
|
||||
# pool:
|
||||
# vmImage: 'macOS-10.13'
|
||||
pool:
|
||||
vmImage: 'macOS-10.13'
|
||||
timeoutInMinutes: 20
|
||||
variables:
|
||||
CI: true
|
||||
@@ -269,12 +272,11 @@ jobs:
|
||||
destinationFolder: src/out/Default/gen
|
||||
timeoutInMinutes: 1
|
||||
|
||||
# TODO(alexeykuzmin): Install Node when tests are run on Microsoft-hosted agents.
|
||||
# - task: NodeTool@0
|
||||
# displayName: Install Node.js 10.x
|
||||
# inputs:
|
||||
# versionSpec: '10.x'
|
||||
# timeoutInMinutes: 2 # Should take less than a minute.
|
||||
- task: NodeTool@0
|
||||
displayName: Install Node.js 10.x
|
||||
inputs:
|
||||
versionSpec: '10.x'
|
||||
timeoutInMinutes: 2 # Should take less than a minute.
|
||||
|
||||
- bash: |
|
||||
cd src/electron
|
||||
|
||||
Reference in New Issue
Block a user