Merge branch 'master' into breaking-changes
This commit is contained in:
commit
c7d1f95240
41 changed files with 267 additions and 298 deletions
2
DEPS
2
DEPS
|
@ -2,7 +2,7 @@ vars = {
|
||||||
'chromium_version':
|
'chromium_version':
|
||||||
'63.0.3239.150',
|
'63.0.3239.150',
|
||||||
'libchromiumcontent_revision':
|
'libchromiumcontent_revision':
|
||||||
'0e8b7216fe616405ea14ff5bece3ca087ead613c',
|
'1c542968990da951df27c8a0371a4ab5494a5a6c',
|
||||||
'node_version':
|
'node_version':
|
||||||
'v9.7.0-33-g538a5023af',
|
'v9.7.0-33-g538a5023af',
|
||||||
'native_mate_revision':
|
'native_mate_revision':
|
||||||
|
|
|
@ -145,9 +145,6 @@ void Screen::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("dipToScreenPoint", &display::win::ScreenWin::DIPToScreenPoint)
|
.SetMethod("dipToScreenPoint", &display::win::ScreenWin::DIPToScreenPoint)
|
||||||
.SetMethod("screenToDipRect", &ScreenToDIPRect)
|
.SetMethod("screenToDipRect", &ScreenToDIPRect)
|
||||||
.SetMethod("dipToScreenRect", &DIPToScreenRect)
|
.SetMethod("dipToScreenRect", &DIPToScreenRect)
|
||||||
#endif
|
|
||||||
#if defined(OS_MACOSX)
|
|
||||||
.SetMethod("getMenuBarHeight", &Screen::getMenuBarHeight)
|
|
||||||
#endif
|
#endif
|
||||||
.SetMethod("getDisplayMatching", &Screen::GetDisplayMatching);
|
.SetMethod("getDisplayMatching", &Screen::GetDisplayMatching);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,6 @@ class Screen : public mate::EventEmitter<Screen>,
|
||||||
display::Display GetDisplayNearestPoint(const gfx::Point& point);
|
display::Display GetDisplayNearestPoint(const gfx::Point& point);
|
||||||
display::Display GetDisplayMatching(const gfx::Rect& match_rect);
|
display::Display GetDisplayMatching(const gfx::Rect& match_rect);
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
|
||||||
int getMenuBarHeight();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// display::DisplayObserver:
|
// display::DisplayObserver:
|
||||||
void OnDisplayAdded(const display::Display& new_display) override;
|
void OnDisplayAdded(const display::Display& new_display) override;
|
||||||
void OnDisplayRemoved(const display::Display& old_display) override;
|
void OnDisplayRemoved(const display::Display& old_display) override;
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
// Copyright (c) 2017 GitHub, Inc.
|
|
||||||
// Use of this source code is governed by the MIT license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import "atom/browser/api/atom_api_screen.h"
|
|
||||||
|
|
||||||
namespace atom {
|
|
||||||
|
|
||||||
namespace api {
|
|
||||||
|
|
||||||
// TODO(codebytere): deprecated; remove in 3.0
|
|
||||||
int Screen::getMenuBarHeight() {
|
|
||||||
return [[NSApp mainMenu] menuBarHeight];
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace api
|
|
||||||
|
|
||||||
} // namespace atom
|
|
|
@ -821,7 +821,7 @@ void Session::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("setDownloadPath", &Session::SetDownloadPath)
|
.SetMethod("setDownloadPath", &Session::SetDownloadPath)
|
||||||
.SetMethod("enableNetworkEmulation", &Session::EnableNetworkEmulation)
|
.SetMethod("enableNetworkEmulation", &Session::EnableNetworkEmulation)
|
||||||
.SetMethod("disableNetworkEmulation", &Session::DisableNetworkEmulation)
|
.SetMethod("disableNetworkEmulation", &Session::DisableNetworkEmulation)
|
||||||
.SetMethod("_setCertificateVerifyProc", &Session::SetCertVerifyProc)
|
.SetMethod("setCertificateVerifyProc", &Session::SetCertVerifyProc)
|
||||||
.SetMethod("setPermissionRequestHandler",
|
.SetMethod("setPermissionRequestHandler",
|
||||||
&Session::SetPermissionRequestHandler)
|
&Session::SetPermissionRequestHandler)
|
||||||
.SetMethod("clearHostResolverCache", &Session::ClearHostResolverCache)
|
.SetMethod("clearHostResolverCache", &Session::ClearHostResolverCache)
|
||||||
|
|
|
@ -40,16 +40,6 @@ struct Converter<atom::TrayIcon::HighlightMode> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool highlight;
|
|
||||||
if (ConvertFromV8(isolate, val, &highlight)) {
|
|
||||||
if (highlight)
|
|
||||||
*out = atom::TrayIcon::HighlightMode::SELECTION;
|
|
||||||
else
|
|
||||||
*out = atom::TrayIcon::HighlightMode::NEVER;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1296,15 +1296,9 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||||
state = "detach";
|
state = "detach";
|
||||||
}
|
}
|
||||||
if (args && args->Length() == 1) {
|
if (args && args->Length() == 1) {
|
||||||
bool detach = false;
|
|
||||||
mate::Dictionary options;
|
mate::Dictionary options;
|
||||||
if (args->GetNext(&options)) {
|
if (args->GetNext(&options)) {
|
||||||
options.Get("mode", &state);
|
options.Get("mode", &state);
|
||||||
|
|
||||||
// TODO(kevinsawicki) Remove in 2.0
|
|
||||||
options.Get("detach", &detach);
|
|
||||||
if (state.empty() && detach)
|
|
||||||
state = "detach";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
managed_web_contents()->SetDockState(state);
|
managed_web_contents()->SetDockState(state);
|
||||||
|
|
|
@ -143,10 +143,6 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
|
||||||
std::string command = AppCommandToString(command_id);
|
std::string command = AppCommandToString(command_id);
|
||||||
NotifyWindowExecuteWindowsCommand(command);
|
NotifyWindowExecuteWindowsCommand(command);
|
||||||
|
|
||||||
if (command_id == APPCOMMAND_MEDIA_PLAY_PAUSE)
|
|
||||||
// FIXME(htk3): Remove media-play_pause in 3.0
|
|
||||||
NotifyWindowExecuteWindowsCommand("media-play_pause");
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ void WebContentsPreferences::AppendCommandLineSwitches(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable blink features.
|
// Enable blink features.
|
||||||
if (dict_.GetString(options::kBlinkFeatures, &s))
|
if (dict_.GetString(options::kEnableBlinkFeatures, &s))
|
||||||
command_line->AppendSwitchASCII(::switches::kEnableBlinkFeatures, s);
|
command_line->AppendSwitchASCII(::switches::kEnableBlinkFeatures, s);
|
||||||
|
|
||||||
// Disable blink features.
|
// Disable blink features.
|
||||||
|
|
|
@ -517,9 +517,6 @@ mate::Handle<NativeImage> NativeImage::CreateFromBuffer(
|
||||||
options.Get("width", &width);
|
options.Get("width", &width);
|
||||||
options.Get("height", &height);
|
options.Get("height", &height);
|
||||||
options.Get("scaleFactor", &scale_factor);
|
options.Get("scaleFactor", &scale_factor);
|
||||||
} else {
|
|
||||||
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
|
|
||||||
args->GetNext(&scale_factor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::ImageSkia image_skia;
|
gfx::ImageSkia image_skia;
|
||||||
|
|
|
@ -127,8 +127,7 @@ const char kOpenerID[] = "openerId";
|
||||||
const char kScrollBounce[] = "scrollBounce";
|
const char kScrollBounce[] = "scrollBounce";
|
||||||
|
|
||||||
// Enable blink features.
|
// Enable blink features.
|
||||||
// TODO(kevinsawicki) Rename to enableBlinkFeatures in 2.0
|
const char kEnableBlinkFeatures[] = "enableBlinkFeatures";
|
||||||
const char kBlinkFeatures[] = "blinkFeatures";
|
|
||||||
|
|
||||||
// Disable blink features.
|
// Disable blink features.
|
||||||
const char kDisableBlinkFeatures[] = "disableBlinkFeatures";
|
const char kDisableBlinkFeatures[] = "disableBlinkFeatures";
|
||||||
|
|
|
@ -64,7 +64,7 @@ extern const char kExperimentalFeatures[];
|
||||||
extern const char kExperimentalCanvasFeatures[];
|
extern const char kExperimentalCanvasFeatures[];
|
||||||
extern const char kOpenerID[];
|
extern const char kOpenerID[];
|
||||||
extern const char kScrollBounce[];
|
extern const char kScrollBounce[];
|
||||||
extern const char kBlinkFeatures[];
|
extern const char kEnableBlinkFeatures[];
|
||||||
extern const char kDisableBlinkFeatures[];
|
extern const char kDisableBlinkFeatures[];
|
||||||
extern const char kNodeIntegrationInWorker[];
|
extern const char kNodeIntegrationInWorker[];
|
||||||
extern const char kWebviewTag[];
|
extern const char kWebviewTag[];
|
||||||
|
|
|
@ -206,12 +206,6 @@ void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
|
||||||
web_frame_->SetSpellCheckPanelHostClient(spell_check_client_.get());
|
web_frame_->SetSpellCheckPanelHostClient(spell_check_client_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrame::RegisterURLSchemeAsSecure(const std::string& scheme) {
|
|
||||||
// TODO(pfrazee): Remove 2.0
|
|
||||||
blink::SchemeRegistry::RegisterURLSchemeAsSecure(
|
|
||||||
WTF::String::FromUTF8(scheme.data(), scheme.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) {
|
void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) {
|
||||||
// Register scheme to bypass pages's Content Security Policy.
|
// Register scheme to bypass pages's Content Security Policy.
|
||||||
blink::SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy(
|
blink::SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy(
|
||||||
|
@ -243,10 +237,6 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
||||||
// Register scheme to privileged list (https, wss, data, chrome-extension)
|
// Register scheme to privileged list (https, wss, data, chrome-extension)
|
||||||
WTF::String privileged_scheme(
|
WTF::String privileged_scheme(
|
||||||
WTF::String::FromUTF8(scheme.data(), scheme.length()));
|
WTF::String::FromUTF8(scheme.data(), scheme.length()));
|
||||||
if (secure) {
|
|
||||||
// TODO(pfrazee): Remove 2.0
|
|
||||||
blink::SchemeRegistry::RegisterURLSchemeAsSecure(privileged_scheme);
|
|
||||||
}
|
|
||||||
if (bypassCSP) {
|
if (bypassCSP) {
|
||||||
blink::SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy(
|
blink::SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy(
|
||||||
privileged_scheme);
|
privileged_scheme);
|
||||||
|
@ -442,13 +432,13 @@ v8::Local<v8::Value> WebFrame::FindFrameByName(const std::string& name) const {
|
||||||
|
|
||||||
v8::Local<v8::Value> WebFrame::FindFrameByRoutingId(int routing_id) const {
|
v8::Local<v8::Value> WebFrame::FindFrameByRoutingId(int routing_id) const {
|
||||||
content::RenderFrame* render_frame =
|
content::RenderFrame* render_frame =
|
||||||
content::RenderFrame::FromRoutingID(routing_id);
|
content::RenderFrame::FromRoutingID(routing_id);
|
||||||
blink::WebLocalFrame* local_frame = nullptr;
|
blink::WebLocalFrame* local_frame = nullptr;
|
||||||
if (render_frame)
|
if (render_frame)
|
||||||
local_frame = render_frame->GetWebFrame();
|
local_frame = render_frame->GetWebFrame();
|
||||||
if (local_frame)
|
if (local_frame)
|
||||||
return mate::CreateHandle(isolate(),
|
return mate::CreateHandle(isolate(), new WebFrame(isolate(), local_frame))
|
||||||
new WebFrame(isolate(), local_frame)).ToV8();
|
.ToV8();
|
||||||
else
|
else
|
||||||
return v8::Null(isolate());
|
return v8::Null(isolate());
|
||||||
}
|
}
|
||||||
|
@ -479,8 +469,6 @@ void WebFrame::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("attachGuest", &WebFrame::AttachGuest)
|
.SetMethod("attachGuest", &WebFrame::AttachGuest)
|
||||||
.SetMethod("detachGuest", &WebFrame::DetachGuest)
|
.SetMethod("detachGuest", &WebFrame::DetachGuest)
|
||||||
.SetMethod("setSpellCheckProvider", &WebFrame::SetSpellCheckProvider)
|
.SetMethod("setSpellCheckProvider", &WebFrame::SetSpellCheckProvider)
|
||||||
.SetMethod("registerURLSchemeAsSecure",
|
|
||||||
&WebFrame::RegisterURLSchemeAsSecure)
|
|
||||||
.SetMethod("registerURLSchemeAsBypassingCSP",
|
.SetMethod("registerURLSchemeAsBypassingCSP",
|
||||||
&WebFrame::RegisterURLSchemeAsBypassingCSP)
|
&WebFrame::RegisterURLSchemeAsBypassingCSP)
|
||||||
.SetMethod("registerURLSchemeAsPrivileged",
|
.SetMethod("registerURLSchemeAsPrivileged",
|
||||||
|
|
|
@ -66,7 +66,6 @@ class WebFrame : public mate::Wrappable<WebFrame> {
|
||||||
bool auto_spell_correct_turned_on,
|
bool auto_spell_correct_turned_on,
|
||||||
v8::Local<v8::Object> provider);
|
v8::Local<v8::Object> provider);
|
||||||
|
|
||||||
void RegisterURLSchemeAsSecure(const std::string& scheme);
|
|
||||||
void RegisterURLSchemeAsBypassingCSP(const std::string& scheme);
|
void RegisterURLSchemeAsBypassingCSP(const std::string& scheme);
|
||||||
void RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
void RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
||||||
mate::Arguments* args);
|
mate::Arguments* args);
|
||||||
|
|
|
@ -309,7 +309,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||||
canvas features. Default is `false`.
|
canvas features. Default is `false`.
|
||||||
* `scrollBounce` Boolean (optional) - Enables scroll bounce (rubber banding) effect on
|
* `scrollBounce` Boolean (optional) - Enables scroll bounce (rubber banding) effect on
|
||||||
macOS. Default is `false`.
|
macOS. Default is `false`.
|
||||||
* `blinkFeatures` String (optional) - A list of feature strings separated by `,`, like
|
* `enableBlinkFeatures` String (optional) - A list of feature strings separated by `,`, like
|
||||||
`CSSVariables,KeyboardEventKey` to enable. The full list of supported feature
|
`CSSVariables,KeyboardEventKey` to enable. The full list of supported feature
|
||||||
strings can be found in the [RuntimeEnabledFeatures.json5][runtime-enabled-features]
|
strings can be found in the [RuntimeEnabledFeatures.json5][runtime-enabled-features]
|
||||||
file.
|
file.
|
||||||
|
|
|
@ -22,7 +22,7 @@ win.loadURL('https://github.com')
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** For the reverse (access the renderer process from the main process),
|
**Note:** For the reverse (access the renderer process from the main process),
|
||||||
you can use [webContents.executeJavascript](web-contents.md#contentsexecutejavascriptcode-usergesture-callback).
|
you can use [webContents.executeJavaScript](web-contents.md#contentsexecutejavascriptcode-usergesture-callback).
|
||||||
|
|
||||||
## Remote Objects
|
## Remote Objects
|
||||||
|
|
||||||
|
|
|
@ -95,10 +95,6 @@ Returns [`Point`](structures/point.md)
|
||||||
|
|
||||||
The current absolute position of the mouse pointer.
|
The current absolute position of the mouse pointer.
|
||||||
|
|
||||||
### `screen.getMenuBarHeight()` _macOS_
|
|
||||||
|
|
||||||
Returns `Integer` - The height of the menu bar in pixels.
|
|
||||||
|
|
||||||
### `screen.getPrimaryDisplay()`
|
### `screen.getPrimaryDisplay()`
|
||||||
|
|
||||||
Returns [`Display`](structures/display.md) - The primary display.
|
Returns [`Display`](structures/display.md) - The primary display.
|
||||||
|
|
|
@ -81,16 +81,6 @@ webFrame.setSpellCheckProvider('en-US', true, {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### `webFrame.registerURLSchemeAsSecure(scheme)`
|
|
||||||
|
|
||||||
* `scheme` String
|
|
||||||
|
|
||||||
Registers the `scheme` as secure scheme.
|
|
||||||
|
|
||||||
Secure schemes do not trigger mixed content warnings. For example, `https` and
|
|
||||||
`data` are secure schemes because they cannot be corrupted by active network
|
|
||||||
attackers.
|
|
||||||
|
|
||||||
### `webFrame.registerURLSchemeAsBypassingCSP(scheme)`
|
### `webFrame.registerURLSchemeAsBypassingCSP(scheme)`
|
||||||
|
|
||||||
* `scheme` String
|
* `scheme` String
|
||||||
|
|
|
@ -214,10 +214,10 @@ A name by itself is given a `true` boolean value.
|
||||||
A preference can be set to another value by including an `=`, followed by the value.
|
A preference can be set to another value by including an `=`, followed by the value.
|
||||||
Special values `yes` and `1` are interpreted as `true`, while `no` and `0` are interpreted as `false`.
|
Special values `yes` and `1` are interpreted as `true`, while `no` and `0` are interpreted as `false`.
|
||||||
|
|
||||||
### `blinkfeatures`
|
### `enableblinkfeatures`
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<webview src="https://www.github.com/" blinkfeatures="PreciseMemoryInfo, CSSVariables"></webview>
|
<webview src="https://www.github.com/" enableblinkfeatures="PreciseMemoryInfo, CSSVariables"></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
A list of strings which specifies the blink features to be enabled separated by `,`.
|
A list of strings which specifies the blink features to be enabled separated by `,`.
|
||||||
|
|
93
docs/development/build-instructions-gn.md
Normal file
93
docs/development/build-instructions-gn.md
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
# Build Instructions (experimental GN build)
|
||||||
|
|
||||||
|
Follow the guidelines below for building Electron with the experimental GN
|
||||||
|
build.
|
||||||
|
|
||||||
|
> **NOTE**: The GN build system is in _experimental_ status, and currently only
|
||||||
|
> works on macOS and Linux, in debug mode, as a component build.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
See the [macOS](build-instructions-osx.md#prerequisites) or
|
||||||
|
[Linux](build-instructions-linux.md#prerequisites) build instructions for the
|
||||||
|
requirements for your platform. In addition, you'll need to install
|
||||||
|
[`depot_tools`][depot-tools], the toolset used for fetching Chromium and its
|
||||||
|
dependencies.
|
||||||
|
|
||||||
|
[depot-tools]: http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
|
||||||
|
|
||||||
|
## Getting the Code
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ mkdir electron-gn && cd electron-gn
|
||||||
|
$ cat > .gclient <<-GCLIENT
|
||||||
|
solutions = [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/electron/electron",
|
||||||
|
"managed": False,
|
||||||
|
"name": "src/electron",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
GCLIENT
|
||||||
|
$ gclient sync --with_branch_heads --with_tags
|
||||||
|
# This will take a while, go get a coffee.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ cd src
|
||||||
|
$ export CHROMIUM_BUILDTOOLS_PATH=`pwd`/buildtools
|
||||||
|
$ gn gen out/Default --args='root_extra_deps=["//electron"] is_electron_build=true is_component_build=true use_jumbo_build=true v8_promise_internal_field_count=1 v8_typed_array_max_size_in_heap=0'
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate all the ninja files needed for the build. You shouldn't have
|
||||||
|
to run `gn gen` again—if you want to change the build arguments you can run `gn
|
||||||
|
args out/Default` to bring up an editor.
|
||||||
|
|
||||||
|
To build, run `ninja` with the `electron:electron_app` target:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ ninja -C out/Default electron:electron_app
|
||||||
|
# This will also take a while and probably heat up your lap.
|
||||||
|
```
|
||||||
|
|
||||||
|
This will build all of what was previously 'libchromiumcontent' (i.e. the
|
||||||
|
`content/` directory of `chromium` and its dependencies, incl. WebKit and V8),
|
||||||
|
so it will take a while.
|
||||||
|
|
||||||
|
To speed up subsequent builds, you can use [sccache][sccache]. Add the GN arg
|
||||||
|
`cc_wrapper="sccache"` by running `gn args out/Default` to bring up an editor.
|
||||||
|
|
||||||
|
[sccache]: https://github.com/mozilla/sccache
|
||||||
|
|
||||||
|
The built executable will be under `./out/Default`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ ./out/Default/Electron.app/Contents/MacOS/Electron
|
||||||
|
# or, on Linux
|
||||||
|
$ ./out/Default/electron
|
||||||
|
```
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
To run the tests, you'll first need to build the test modules against the
|
||||||
|
same version of node.js that was built as part of the build process.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ (cd electron/spec && npm i --nodedir=../../third_party/electron_node)
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, run Electron with `electron/spec` as the argument:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ ./out/Default/Electron.app/Contents/MacOS/Electron electron/spec
|
||||||
|
```
|
||||||
|
|
||||||
|
If you're debugging something, it can be helpful to pass some extra flags to
|
||||||
|
the Electron binary:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ ./out/Default/Electron.app/Contents/MacOS/Electron electron/spec \
|
||||||
|
--ci --enable-logging -g 'BrowserWindow module'
|
||||||
|
```
|
|
@ -12,7 +12,7 @@ Follow the guidelines below for building Electron on Linux.
|
||||||
For a quick test, run the following script:
|
For a quick test, run the following script:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ python ./script/check-tls.py
|
$ python ./script/tls.py
|
||||||
```
|
```
|
||||||
|
|
||||||
If the script returns that your configuration is using an outdated security
|
If the script returns that your configuration is using an outdated security
|
||||||
|
|
|
@ -15,7 +15,7 @@ Please also ensure that your system and Python version support at least TLS 1.2.
|
||||||
This depends on both your version of macOS and Python. For a quick test, run:
|
This depends on both your version of macOS and Python. For a quick test, run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ python ./script/check-tls.py
|
$ python ./script/tls.py
|
||||||
```
|
```
|
||||||
|
|
||||||
If the script returns that your configuration is using an outdated security
|
If the script returns that your configuration is using an outdated security
|
||||||
|
|
|
@ -61,7 +61,7 @@ the notification away.
|
||||||
## macOS
|
## macOS
|
||||||
|
|
||||||
Notifications are straight-forward on macOS, but you should be aware of
|
Notifications are straight-forward on macOS, but you should be aware of
|
||||||
[Apple's Human Interface guidelines regarding notifications](https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/NotificationCenter.html).
|
[Apple's Human Interface guidelines regarding notifications](https://developer.apple.com/macos/human-interface-guidelines/system-capabilities/notifications/).
|
||||||
|
|
||||||
Note that notifications are limited to 256 bytes in size and will be truncated
|
Note that notifications are limited to 256 bytes in size and will be truncated
|
||||||
if you exceed that limit.
|
if you exceed that limit.
|
||||||
|
|
|
@ -78,7 +78,7 @@ improve the security of your application.
|
||||||
7. [Override and disable `eval`](#7-override-and-disable-eval), which allows strings to be executed as code.
|
7. [Override and disable `eval`](#7-override-and-disable-eval), which allows strings to be executed as code.
|
||||||
8. [Do not set `allowRunningInsecureContent` to `true`](#8-do-not-set-allowrunninginsecurecontent-to-true)
|
8. [Do not set `allowRunningInsecureContent` to `true`](#8-do-not-set-allowrunninginsecurecontent-to-true)
|
||||||
9. [Do not enable experimental features](#9-do-not-enable-experimental-features)
|
9. [Do not enable experimental features](#9-do-not-enable-experimental-features)
|
||||||
10. [Do not use `blinkFeatures`](#10-do-not-use-blinkfeatures)
|
10. [Do not use `enableBlinkFeatures`](#10-do-not-use-enableblinkfeatures)
|
||||||
11. [WebViews: Do not use `allowpopups`](#11-do-not-use-allowpopups)
|
11. [WebViews: Do not use `allowpopups`](#11-do-not-use-allowpopups)
|
||||||
12. [WebViews: Verify the options and params of all `<webview>` tags](#12-verify-webview-options-before-creation)
|
12. [WebViews: Verify the options and params of all `<webview>` tags](#12-verify-webview-options-before-creation)
|
||||||
|
|
||||||
|
@ -452,12 +452,12 @@ const mainWindow = new BrowserWindow({})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 10) Do Not Use `blinkFeatures`
|
## 10) Do Not Use `enableBlinkFeatures`
|
||||||
|
|
||||||
_Recommendation is Electron's default_
|
_Recommendation is Electron's default_
|
||||||
|
|
||||||
Blink is the name of the rendering engine behind Chromium. As with
|
Blink is the name of the rendering engine behind Chromium. As with
|
||||||
`experimentalFeatures`, the `blinkFeatures` property allows developers to
|
`experimentalFeatures`, the `enableBlinkFeatures` property allows developers to
|
||||||
enable features that have been disabled by default.
|
enable features that have been disabled by default.
|
||||||
|
|
||||||
### Why?
|
### Why?
|
||||||
|
@ -473,7 +473,7 @@ no circumstances should you enable features speculatively.
|
||||||
// Bad
|
// Bad
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
blinkFeatures: ['ExecCommandInJavaScript']
|
enableBlinkFeatures: ['ExecCommandInJavaScript']
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
|
@ -152,7 +152,6 @@
|
||||||
'atom/browser/api/atom_api_render_process_preferences.h',
|
'atom/browser/api/atom_api_render_process_preferences.h',
|
||||||
'atom/browser/api/atom_api_screen.cc',
|
'atom/browser/api/atom_api_screen.cc',
|
||||||
'atom/browser/api/atom_api_screen.h',
|
'atom/browser/api/atom_api_screen.h',
|
||||||
'atom/browser/api/atom_api_screen_mac.mm',
|
|
||||||
'atom/browser/api/atom_api_session.cc',
|
'atom/browser/api/atom_api_session.cc',
|
||||||
'atom/browser/api/atom_api_session.h',
|
'atom/browser/api/atom_api_session.h',
|
||||||
'atom/browser/api/atom_api_system_preferences.cc',
|
'atom/browser/api/atom_api_system_preferences.cc',
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
const {deprecate} = require('electron')
|
|
||||||
const {screen, Screen} = process.atomBinding('screen')
|
const {screen, Screen} = process.atomBinding('screen')
|
||||||
|
|
||||||
// Screen is an EventEmitter.
|
// Screen is an EventEmitter.
|
||||||
Object.setPrototypeOf(Screen.prototype, EventEmitter.prototype)
|
Object.setPrototypeOf(Screen.prototype, EventEmitter.prototype)
|
||||||
EventEmitter.call(screen)
|
EventEmitter.call(screen)
|
||||||
|
|
||||||
const nativeFn = screen.getMenuBarHeight
|
|
||||||
screen.getMenuBarHeight = function () {
|
|
||||||
if (!process.noDeprecations) {
|
|
||||||
deprecate.warn('screen.getMenuBarHeight', 'screen.getPrimaryDisplay().workArea')
|
|
||||||
}
|
|
||||||
return nativeFn.call(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = screen
|
module.exports = screen
|
||||||
|
|
|
@ -20,18 +20,3 @@ Object.setPrototypeOf(Cookies.prototype, EventEmitter.prototype)
|
||||||
Session.prototype._init = function () {
|
Session.prototype._init = function () {
|
||||||
app.emit('session-created', this)
|
app.emit('session-created', this)
|
||||||
}
|
}
|
||||||
|
|
||||||
Session.prototype.setCertificateVerifyProc = function (verifyProc) {
|
|
||||||
if (verifyProc != null && verifyProc.length > 2) {
|
|
||||||
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
|
|
||||||
this._setCertificateVerifyProc(({hostname, certificate, verificationResult}, cb) => {
|
|
||||||
verifyProc(hostname, certificate, (result) => {
|
|
||||||
// Disabled due to false positive in StandardJS
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
cb(result ? 0 : -2)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this._setCertificateVerifyProc(verifyProc)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,20 +1,6 @@
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
const {deprecate} = require('electron')
|
|
||||||
const {Tray} = process.atomBinding('tray')
|
const {Tray} = process.atomBinding('tray')
|
||||||
|
|
||||||
Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype)
|
Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype)
|
||||||
|
|
||||||
// TODO(codebytere): remove in 3.0
|
|
||||||
const nativeSetHighlightMode = Tray.prototype.setHighlightMode
|
|
||||||
Tray.prototype.setHighlightMode = function (param) {
|
|
||||||
if (!process.noDeprecations && typeof param === 'boolean') {
|
|
||||||
if (param) {
|
|
||||||
deprecate.warn('tray.setHighlightMode(true)', `tray.setHighlightMode("on")`)
|
|
||||||
} else {
|
|
||||||
deprecate.warn('tray.setHighlightMode(false)', `tray.setHighlightMode("off")`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nativeSetHighlightMode.call(this, param)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Tray
|
module.exports = Tray
|
||||||
|
|
|
@ -165,14 +165,6 @@ for (const method of webFrameMethodsWithResult) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const nativeOpenDevTools = WebContents.prototype.openDevTools
|
|
||||||
WebContents.prototype.openDevTools = function (params) {
|
|
||||||
if (!process.noDeprecations && params && 'detach' in params) {
|
|
||||||
deprecate.warn('webContents.openDevTools({detach: true})', `webContents.openDevTools({mode: 'detach'})`)
|
|
||||||
}
|
|
||||||
return nativeOpenDevTools.call(this, params)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure WebContents::executeJavaScript would run the code only when the
|
// Make sure WebContents::executeJavaScript would run the code only when the
|
||||||
// WebContents has been loaded.
|
// WebContents has been loaded.
|
||||||
WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callback) {
|
WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callback) {
|
||||||
|
|
|
@ -217,7 +217,7 @@ const attachGuest = function (event, elementInstanceId, guestInstanceId, params)
|
||||||
plugins: params.plugins,
|
plugins: params.plugins,
|
||||||
zoomFactor: embedder._getZoomFactor(),
|
zoomFactor: embedder._getZoomFactor(),
|
||||||
webSecurity: !params.disablewebsecurity,
|
webSecurity: !params.disablewebsecurity,
|
||||||
blinkFeatures: params.blinkfeatures,
|
enableBlinkFeatures: params.blinkfeatures,
|
||||||
disableBlinkFeatures: params.disableblinkfeatures
|
disableBlinkFeatures: params.disableblinkfeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,41 +2,8 @@ if (process.platform === 'linux' && process.type === 'renderer') {
|
||||||
// On Linux we could not access clipboard in renderer process.
|
// On Linux we could not access clipboard in renderer process.
|
||||||
module.exports = require('electron').remote.clipboard
|
module.exports = require('electron').remote.clipboard
|
||||||
} else {
|
} else {
|
||||||
const {deprecate} = require('electron')
|
|
||||||
const clipboard = process.atomBinding('clipboard')
|
const clipboard = process.atomBinding('clipboard')
|
||||||
|
|
||||||
// TODO(codebytere): remove in 3.0
|
|
||||||
clipboard.readHtml = function () {
|
|
||||||
if (!process.noDeprecations) {
|
|
||||||
deprecate.warn('clipboard.readHtml', 'clipboard.readHTML')
|
|
||||||
}
|
|
||||||
return clipboard.readHTML()
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(codebytere): remove in 3.0
|
|
||||||
clipboard.writeHtml = function () {
|
|
||||||
if (!process.noDeprecations) {
|
|
||||||
deprecate.warn('clipboard.writeHtml', 'clipboard.writeHTML')
|
|
||||||
}
|
|
||||||
return clipboard.writeHTML()
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(codebytere): remove in 3.0
|
|
||||||
clipboard.readRtf = function () {
|
|
||||||
if (!process.noDeprecations) {
|
|
||||||
deprecate.warn('clipboard.readRtf', 'clipboard.writeRTF')
|
|
||||||
}
|
|
||||||
return clipboard.readRTF()
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(codebytere): remove in 3.0
|
|
||||||
clipboard.writeRtf = function () {
|
|
||||||
if (!process.noDeprecations) {
|
|
||||||
deprecate.warn('clipboard.writeRtf', 'clipboard.writeRTF')
|
|
||||||
}
|
|
||||||
return clipboard.writeRTF()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read/write to find pasteboard over IPC since only main process is notified
|
// Read/write to find pasteboard over IPC since only main process is notified
|
||||||
// of changes
|
// of changes
|
||||||
if (process.platform === 'darwin' && process.type === 'renderer') {
|
if (process.platform === 'darwin' && process.type === 'renderer') {
|
||||||
|
|
|
@ -4,7 +4,7 @@ const {spawn} = require('child_process')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const {app, deprecate} = process.type === 'browser' ? electron : electron.remote
|
const {app} = process.type === 'browser' ? electron : electron.remote
|
||||||
const binding = process.atomBinding('crash_reporter')
|
const binding = process.atomBinding('crash_reporter')
|
||||||
|
|
||||||
class CrashReporter {
|
class CrashReporter {
|
||||||
|
@ -21,12 +21,7 @@ class CrashReporter {
|
||||||
} = options
|
} = options
|
||||||
|
|
||||||
if (uploadToServer == null) {
|
if (uploadToServer == null) {
|
||||||
if (options.autoSubmit) {
|
uploadToServer = true
|
||||||
deprecate.warn('autoSubmit', 'uploadToServer')
|
|
||||||
uploadToServer = options.autoSubmit
|
|
||||||
} else {
|
|
||||||
uploadToServer = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreSystemCrashHandler == null) ignoreSystemCrashHandler = false
|
if (ignoreSystemCrashHandler == null) ignoreSystemCrashHandler = false
|
||||||
|
|
|
@ -87,20 +87,33 @@ deprecate.getHandler = () => deprecationHandler
|
||||||
// return this[member][method].apply(this[member], arguments)
|
// return this[member][method].apply(this[member], arguments)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// // Deprecate a property.
|
// Deprecate the old name of a property
|
||||||
// deprecate.property = (object, property, method) => {
|
deprecate.property = (object, deprecatedName, newName) => {
|
||||||
// return Object.defineProperty(object, property, {
|
let warned = false
|
||||||
// get: function () {
|
let warn = () => {
|
||||||
// let warned = false
|
if (!(warned || process.noDeprecation)) {
|
||||||
// if (!(warned || process.noDeprecation)) {
|
warned = true
|
||||||
// warned = true
|
deprecate.warn(deprecatedName, newName)
|
||||||
// deprecate.warn(`${property} property`, `${method} method`)
|
}
|
||||||
// }
|
}
|
||||||
// return this[method]()
|
|
||||||
// }
|
if ((typeof object[newName] === 'undefined') &&
|
||||||
// })
|
(typeof object[deprecatedName] !== 'undefined')) {
|
||||||
// }
|
warn()
|
||||||
//
|
object[newName] = object[deprecatedName]
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.defineProperty(object, deprecatedName, {
|
||||||
|
get: function () {
|
||||||
|
warn()
|
||||||
|
return this[newName]
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
warn()
|
||||||
|
this[newName] = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = deprecate
|
module.exports = deprecate
|
||||||
|
|
|
@ -31,7 +31,7 @@ const {
|
||||||
warnAboutDisabledWebSecurity,
|
warnAboutDisabledWebSecurity,
|
||||||
warnAboutInsecureContentAllowed,
|
warnAboutInsecureContentAllowed,
|
||||||
warnAboutExperimentalFeatures,
|
warnAboutExperimentalFeatures,
|
||||||
warnAboutBlinkFeatures,
|
warnAboutEnableBlinkFeatures,
|
||||||
warnAboutInsecureResources,
|
warnAboutInsecureResources,
|
||||||
warnAboutInsecureCSP,
|
warnAboutInsecureCSP,
|
||||||
warnAboutAllowedPopups,
|
warnAboutAllowedPopups,
|
||||||
|
@ -177,7 +177,7 @@ window.addEventListener('load', function loadHandler () {
|
||||||
warnAboutInsecureResources()
|
warnAboutInsecureResources()
|
||||||
warnAboutInsecureContentAllowed()
|
warnAboutInsecureContentAllowed()
|
||||||
warnAboutExperimentalFeatures()
|
warnAboutExperimentalFeatures()
|
||||||
warnAboutBlinkFeatures()
|
warnAboutEnableBlinkFeatures()
|
||||||
warnAboutInsecureCSP()
|
warnAboutInsecureCSP()
|
||||||
warnAboutAllowedPopups()
|
warnAboutAllowedPopups()
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,9 @@ const getWebPreferences = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const moreInformation = '\nFor more information and help, consult ' +
|
const moreInformation = `\nFor more information and help, consult
|
||||||
'https://electronjs.org/docs/tutorial/security.\n' +
|
https://electronjs.org/docs/tutorial/security.\n This warning will not show up
|
||||||
'This warning will not show up once the app is packaged.'
|
once the app is packaged.`
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
shouldLogSecurityWarnings,
|
shouldLogSecurityWarnings,
|
||||||
|
@ -119,11 +119,10 @@ module.exports = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let warning = 'This renderer process loads resources using insecure protocols. ' +
|
const warning = `This renderer process loads resources using insecure
|
||||||
'This exposes users of this app to unnecessary security risks. ' +
|
protocols.This exposes users of this app to unnecessary security risks.
|
||||||
'Consider loading the following resources over HTTPS or FTPS. \n' +
|
Consider loading the following resources over HTTPS or FTPS. \n ${resources}
|
||||||
resources + '\n' +
|
\n ${moreInformation}`
|
||||||
moreInformation
|
|
||||||
|
|
||||||
console.warn('%cElectron Security Warning (Insecure Resources)',
|
console.warn('%cElectron Security Warning (Insecure Resources)',
|
||||||
'font-weight: bold;', warning)
|
'font-weight: bold;', warning)
|
||||||
|
@ -137,10 +136,9 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
warnAboutNodeWithRemoteContent: () => {
|
warnAboutNodeWithRemoteContent: () => {
|
||||||
if (getIsRemoteProtocol()) {
|
if (getIsRemoteProtocol()) {
|
||||||
let warning = 'This renderer process has Node.js integration enabled ' +
|
const warning = `This renderer process has Node.js integration enabled
|
||||||
'and attempted to load remote content. This exposes users of this app to severe ' +
|
and attempted to load remote content. This exposes users of this app to
|
||||||
'security risks.\n' +
|
severe security risks.\n ${moreInformation}`
|
||||||
moreInformation
|
|
||||||
|
|
||||||
console.warn('%cElectron Security Warning (Node.js Integration with Remote Content)',
|
console.warn('%cElectron Security Warning (Node.js Integration with Remote Content)',
|
||||||
'font-weight: bold;', warning)
|
'font-weight: bold;', warning)
|
||||||
|
@ -162,9 +160,8 @@ module.exports = {
|
||||||
const webPreferences = getWebPreferences()
|
const webPreferences = getWebPreferences()
|
||||||
if (!webPreferences || webPreferences.webSecurity !== false) return
|
if (!webPreferences || webPreferences.webSecurity !== false) return
|
||||||
|
|
||||||
let warning = 'This renderer process has "webSecurity" disabled. ' +
|
const warning = `This renderer process has "webSecurity" disabled. This
|
||||||
'This exposes users of this app to severe security risks.\n' +
|
exposes users of this app to severe security risks.\n ${moreInformation}`
|
||||||
moreInformation
|
|
||||||
|
|
||||||
console.warn('%cElectron Security Warning (Disabled webSecurity)',
|
console.warn('%cElectron Security Warning (Disabled webSecurity)',
|
||||||
'font-weight: bold;', warning)
|
'font-weight: bold;', warning)
|
||||||
|
@ -180,10 +177,9 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
warnAboutInsecureCSP: () => {
|
warnAboutInsecureCSP: () => {
|
||||||
if (isUnsafeEvalEnabled()) {
|
if (isUnsafeEvalEnabled()) {
|
||||||
let warning = 'This renderer process has either no Content Security Policy set ' +
|
const warning = `This renderer process has either no Content Security
|
||||||
'or a policy with "unsafe-eval" enabled. This exposes users of this ' +
|
Policy set or a policy with "unsafe-eval" enabled. This exposes users of
|
||||||
'app to unnecessary security risks.\n' +
|
this app to unnecessary security risks.\n ${moreInformation}`
|
||||||
moreInformation
|
|
||||||
|
|
||||||
console.warn('%cElectron Security Warning (Insecure Content-Security-Policy)',
|
console.warn('%cElectron Security Warning (Insecure Content-Security-Policy)',
|
||||||
'font-weight: bold;', warning)
|
'font-weight: bold;', warning)
|
||||||
|
@ -199,9 +195,9 @@ module.exports = {
|
||||||
const webPreferences = getWebPreferences()
|
const webPreferences = getWebPreferences()
|
||||||
if (!webPreferences || !webPreferences.allowRunningInsecureContent) return
|
if (!webPreferences || !webPreferences.allowRunningInsecureContent) return
|
||||||
|
|
||||||
let warning = 'This renderer process has "allowRunningInsecureContent" ' +
|
const warning = `This renderer process has "allowRunningInsecureContent"
|
||||||
'enabled. This exposes users of this app to severe security risks.\n' +
|
enabled. This exposes users of this app to severe security risks.\n
|
||||||
moreInformation
|
${moreInformation}`
|
||||||
|
|
||||||
console.warn('%cElectron Security Warning (allowRunningInsecureContent)',
|
console.warn('%cElectron Security Warning (allowRunningInsecureContent)',
|
||||||
'font-weight: bold;', warning)
|
'font-weight: bold;', warning)
|
||||||
|
@ -219,33 +215,32 @@ module.exports = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let warning = 'This renderer process has "experimentalFeatures" ' +
|
const warning = `This renderer process has "experimentalFeatures" enabled.
|
||||||
'enabled. This exposes users of this app to some security risk. ' +
|
This exposes users of this app to some security risk. If you do not need
|
||||||
'If you do not need this feature, you should disable it.\n' +
|
this feature, you should disable it.\n ${moreInformation}`
|
||||||
moreInformation
|
|
||||||
|
|
||||||
console.warn('%cElectron Security Warning (experimentalFeatures)',
|
console.warn('%cElectron Security Warning (experimentalFeatures)',
|
||||||
'font-weight: bold;', warning)
|
'font-weight: bold;', warning)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #10 on the checklist: Do not use blinkFeatures
|
* #10 on the checklist: Do not use enableBlinkFeatures
|
||||||
*
|
*
|
||||||
* Logs a warning message about blinkFeatures
|
* Logs a warning message about enableBlinkFeatures
|
||||||
*/
|
*/
|
||||||
warnAboutBlinkFeatures: () => {
|
warnAboutEnableBlinkFeatures: () => {
|
||||||
const webPreferences = getWebPreferences()
|
const webPreferences = getWebPreferences()
|
||||||
if (!webPreferences || !webPreferences.blinkFeatures ||
|
if (webPreferences === null ||
|
||||||
(webPreferences.blinkFeatures.length && webPreferences.blinkFeatures.length === 0)) {
|
!webPreferences.hasOwnProperty('enableBlinkFeatures') ||
|
||||||
|
webPreferences.enableBlinkFeatures.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let warning = 'This renderer process has additional "blinkFeatures" ' +
|
const warning = `This renderer process has additional "enableBlinkFeatures"
|
||||||
'enabled. This exposes users of this app to some security risk. ' +
|
enabled. This exposes users of this app to some security risk. If you do not
|
||||||
'If you do not need this feature, you should disable it.\n' +
|
need this feature, you should disable it.\n ${moreInformation}`
|
||||||
moreInformation
|
|
||||||
|
|
||||||
console.warn('%cElectron Security Warning (blinkFeatures)',
|
console.warn('%cElectron Security Warning (enableBlinkFeatures)',
|
||||||
'font-weight: bold;', warning)
|
'font-weight: bold;', warning)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -262,10 +257,10 @@ module.exports = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let warning = 'A <webview> has "allowpopups" set to true. ' +
|
const warning = `A <webview> has "allowpopups" set to true. This exposes
|
||||||
'This exposes users of this app to some security risk, since popups are just ' +
|
users of this app to some security risk, since popups are just
|
||||||
'BrowserWindows. If you do not need this feature, you should disable it.\n' +
|
BrowserWindows. If you do not need this feature, you should disable it.\n
|
||||||
moreInformation
|
${moreInformation}`
|
||||||
|
|
||||||
console.warn('%cElectron Security Warning (allowpopups)',
|
console.warn('%cElectron Security Warning (allowpopups)',
|
||||||
'font-weight: bold;', warning)
|
'font-weight: bold;', warning)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"dugite": "^1.45.0",
|
"dugite": "^1.45.0",
|
||||||
"electabul": "~0.0.4",
|
"electabul": "~0.0.4",
|
||||||
"electron-docs-linter": "^2.3.4",
|
"electron-docs-linter": "^2.3.4",
|
||||||
"electron-typescript-definitions": "^1.3.4",
|
"electron-typescript-definitions": "^1.3.5",
|
||||||
"github": "^9.2.0",
|
"github": "^9.2.0",
|
||||||
"husky": "^0.14.3",
|
"husky": "^0.14.3",
|
||||||
"lint": "^1.1.2",
|
"lint": "^1.1.2",
|
||||||
|
|
|
@ -14,7 +14,8 @@ if sys.platform == "win32":
|
||||||
from lib.config import BASE_URL, PLATFORM, enable_verbose_mode, \
|
from lib.config import BASE_URL, PLATFORM, enable_verbose_mode, \
|
||||||
get_target_arch, get_zip_name, build_env
|
get_target_arch, get_zip_name, build_env
|
||||||
from lib.util import scoped_cwd, rm_rf, get_electron_version, make_zip, \
|
from lib.util import scoped_cwd, rm_rf, get_electron_version, make_zip, \
|
||||||
execute, electron_gyp, electron_features
|
execute, electron_gyp, electron_features, parse_version
|
||||||
|
from lib.env_util import get_vs_location
|
||||||
|
|
||||||
|
|
||||||
ELECTRON_VERSION = get_electron_version()
|
ELECTRON_VERSION = get_electron_version()
|
||||||
|
@ -146,22 +147,28 @@ def copy_chrome_binary(binary):
|
||||||
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
|
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
|
||||||
|
|
||||||
def copy_vcruntime_binaries():
|
def copy_vcruntime_binaries():
|
||||||
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
|
||||||
r"SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC", 0,
|
|
||||||
_winreg.KEY_READ | _winreg.KEY_WOW64_32KEY) as key:
|
|
||||||
crt_dir = _winreg.QueryValueEx(key, "ProductDir")[0]
|
|
||||||
|
|
||||||
arch = get_target_arch()
|
arch = get_target_arch()
|
||||||
if arch == "ia32":
|
if arch == "ia32":
|
||||||
arch = "x86"
|
arch = "x86"
|
||||||
|
subkey = r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\\"
|
||||||
|
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey + arch, 0,
|
||||||
|
_winreg.KEY_READ | _winreg.KEY_WOW64_32KEY) as key:
|
||||||
|
runtime_version = _winreg.QueryValueEx(key, "Version")[0][1:]
|
||||||
|
|
||||||
crt_dir += r"redist\{0}\Microsoft.VC140.CRT\\".format(arch)
|
version_parts = parse_version(runtime_version)
|
||||||
|
if len(version_parts) > 3:
|
||||||
|
runtime_version = '.'.join(version_parts[0:3])
|
||||||
|
|
||||||
|
vs_location = get_vs_location('[15.0,16.0)')
|
||||||
|
|
||||||
|
crt_dir = os.path.join(vs_location, 'VC', 'Redist', 'MSVC', runtime_version,
|
||||||
|
arch, 'Microsoft.VC141.CRT')
|
||||||
|
|
||||||
dlls = ["msvcp140.dll", "vcruntime140.dll"]
|
dlls = ["msvcp140.dll", "vcruntime140.dll"]
|
||||||
|
|
||||||
# Note: copyfile is used to remove the read-only flag
|
# Note: copyfile is used to remove the read-only flag
|
||||||
for dll in dlls:
|
for dll in dlls:
|
||||||
shutil.copyfile(crt_dir + dll, os.path.join(DIST_DIR, dll))
|
shutil.copyfile(os.path.join(crt_dir, dll), os.path.join(DIST_DIR, dll))
|
||||||
TARGET_BINARIES_EXT.append(dll)
|
TARGET_BINARIES_EXT.append(dll)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -58,29 +59,40 @@ def get_environment_from_batch_command(env_cmd, initial=None):
|
||||||
proc.communicate()
|
proc.communicate()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_vs_location(vs_version):
|
||||||
|
"""
|
||||||
|
Returns the location of the VS building environment.
|
||||||
|
|
||||||
|
The vs_version can be strings like "[15.0,16.0)", meaning 2017, but not the next version.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# vswhere can't handle spaces, like "[15.0, 16.0)" should become "[15.0,16.0)"
|
||||||
|
vs_version = vs_version.replace(" ", "")
|
||||||
|
|
||||||
|
program_files = os.environ.get('ProgramFiles(x86)')
|
||||||
|
# Find visual studio
|
||||||
|
proc = subprocess.Popen(
|
||||||
|
program_files + "\\Microsoft Visual Studio\\Installer\\vswhere.exe "
|
||||||
|
"-property installationPath "
|
||||||
|
"-requires Microsoft.VisualStudio.Component.VC.CoreIde "
|
||||||
|
"-format value "
|
||||||
|
"-version {0}".format(vs_version),
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
|
||||||
|
location = proc.stdout.readline().rstrip()
|
||||||
|
return location
|
||||||
|
|
||||||
def get_vs_env(vs_version, arch):
|
def get_vs_env(vs_version, arch):
|
||||||
"""
|
"""
|
||||||
Returns the env object for VS building environment.
|
Returns the env object for VS building environment.
|
||||||
|
|
||||||
The vs_version can be strings like "[15.0,16.0)", meaning 2017, but not the next version.
|
vs_version is the version of Visual Studio to use. See get_vs_location for
|
||||||
|
more details.
|
||||||
The arch has to be one of "x86", "amd64", "arm", "x86_amd64", "x86_arm", "amd64_x86",
|
The arch has to be one of "x86", "amd64", "arm", "x86_amd64", "x86_arm", "amd64_x86",
|
||||||
"amd64_arm", e.g. the args passed to vcvarsall.bat.
|
"amd64_arm", i.e. the args passed to vcvarsall.bat.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# vswhere can't handle spaces, like "[15.0, 16.0)" should become "[15.0,16.0)"
|
location = get_vs_location(vs_version)
|
||||||
vs_version = vs_version.replace(" ", "")
|
|
||||||
|
|
||||||
# Find visual studio
|
|
||||||
proc = subprocess.Popen(
|
|
||||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe "
|
|
||||||
"-property installationPath "
|
|
||||||
"-requires Microsoft.VisualStudio.Component.VC.CoreIde "
|
|
||||||
"-format value "
|
|
||||||
"-version {0}".format(vs_version),
|
|
||||||
stdout=subprocess.PIPE)
|
|
||||||
|
|
||||||
location = proc.stdout.readline().rstrip()
|
|
||||||
|
|
||||||
# Launch the process.
|
# Launch the process.
|
||||||
vsvarsall = "{0}\\VC\\Auxiliary\\Build\\vcvarsall.bat".format(location)
|
vsvarsall = "{0}\\VC\\Auxiliary\\Build\\vcvarsall.bat".format(location)
|
||||||
|
|
|
@ -49,6 +49,46 @@ describe('deprecations', () => {
|
||||||
assert.equal(typeof nativeImage.createFromDataUrl, 'function')
|
assert.equal(typeof nativeImage.createFromDataUrl, 'function')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('renames a property', () => {
|
||||||
|
let msg
|
||||||
|
deprecations.setHandler((m) => { msg = m })
|
||||||
|
|
||||||
|
const oldPropertyName = 'dingyOldName'
|
||||||
|
const newPropertyName = 'shinyNewName'
|
||||||
|
|
||||||
|
let value = 0
|
||||||
|
let o = { [newPropertyName]: value }
|
||||||
|
assert.strictEqual(typeof o[oldPropertyName], 'undefined')
|
||||||
|
assert.strictEqual(typeof o[newPropertyName], 'number')
|
||||||
|
|
||||||
|
deprecate.property(o, oldPropertyName, newPropertyName)
|
||||||
|
assert.notEqual(typeof msg, 'string')
|
||||||
|
o[oldPropertyName] = ++value
|
||||||
|
|
||||||
|
assert.strictEqual(typeof msg, 'string')
|
||||||
|
assert.ok(msg.includes(oldPropertyName))
|
||||||
|
assert.ok(msg.includes(newPropertyName))
|
||||||
|
|
||||||
|
assert.strictEqual(o[newPropertyName], value)
|
||||||
|
assert.strictEqual(o[oldPropertyName], value)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('warns if deprecated property is already set', () => {
|
||||||
|
let msg
|
||||||
|
deprecations.setHandler((m) => { msg = m })
|
||||||
|
|
||||||
|
const oldPropertyName = 'dingyOldName'
|
||||||
|
const newPropertyName = 'shinyNewName'
|
||||||
|
const value = 0
|
||||||
|
|
||||||
|
let o = { [oldPropertyName]: value }
|
||||||
|
deprecate.property(o, oldPropertyName, newPropertyName)
|
||||||
|
|
||||||
|
assert.strictEqual(typeof msg, 'string')
|
||||||
|
assert.ok(msg.includes(oldPropertyName))
|
||||||
|
assert.ok(msg.includes(newPropertyName))
|
||||||
|
})
|
||||||
|
|
||||||
it('throws an exception if no deprecation handler is specified', () => {
|
it('throws an exception if no deprecation handler is specified', () => {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
deprecate.log('this is deprecated')
|
deprecate.log('this is deprecated')
|
||||||
|
|
|
@ -587,35 +587,6 @@ describe('session module', () => {
|
||||||
w.loadURL(`https://127.0.0.1:${server.address().port}`)
|
w.loadURL(`https://127.0.0.1:${server.address().port}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('deprecated function signature', () => {
|
|
||||||
it('supports accepting the request', (done) => {
|
|
||||||
session.defaultSession.setCertificateVerifyProc((hostname, certificate, callback) => {
|
|
||||||
assert.equal(hostname, '127.0.0.1')
|
|
||||||
callback(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
w.webContents.once('did-finish-load', () => {
|
|
||||||
assert.equal(w.webContents.getTitle(), 'hello')
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
w.loadURL(`https://127.0.0.1:${server.address().port}`)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('supports rejecting the request', (done) => {
|
|
||||||
session.defaultSession.setCertificateVerifyProc((hostname, certificate, callback) => {
|
|
||||||
assert.equal(hostname, '127.0.0.1')
|
|
||||||
callback(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
const url = `https://127.0.0.1:${server.address().port}`
|
|
||||||
w.webContents.once('did-finish-load', () => {
|
|
||||||
assert.equal(w.webContents.getTitle(), url)
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
w.loadURL(url)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('rejects the request when the callback is called with -2', (done) => {
|
it('rejects the request when the callback is called with -2', (done) => {
|
||||||
session.defaultSession.setCertificateVerifyProc(({hostname, certificate, verificationResult}, callback) => {
|
session.defaultSession.setCertificateVerifyProc(({hostname, certificate, verificationResult}, callback) => {
|
||||||
assert.equal(hostname, '127.0.0.1')
|
assert.equal(hostname, '127.0.0.1')
|
||||||
|
|
|
@ -133,16 +133,16 @@ describe('security warnings', () => {
|
||||||
w.loadURL(`http://127.0.0.1:8881/base-page-security.html`)
|
w.loadURL(`http://127.0.0.1:8881/base-page-security.html`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should warn about blinkFeatures', (done) => {
|
it('should warn about enableBlinkFeatures', (done) => {
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow({
|
||||||
show: false,
|
show: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
blinkFeatures: ['my-cool-feature'],
|
enableBlinkFeatures: ['my-cool-feature'],
|
||||||
nodeIntegration: false
|
nodeIntegration: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
w.webContents.once('console-message', (e, level, message) => {
|
w.webContents.once('console-message', (e, level, message) => {
|
||||||
assert(message.includes('blinkFeatures'), message)
|
assert(message.includes('enableBlinkFeatures'), message)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue