Compare commits

..

7 Commits

Author SHA1 Message Date
Electron Bot
61bd57f851 Bump v13.0.0-beta.13 2021-04-12 08:02:26 -07:00
trop[bot]
5ab8cb7482 fix: load source maps from custom protocols and asar bundles (#28615)
* fix: load source maps from custom protocols and asar bundles

* chore: fix lint

Co-authored-by: deepak1556 <hop2deep@gmail.com>
2021-04-12 06:18:34 -07:00
trop[bot]
d1bb54d175 docs: define the name of the preload script (#28609)
Co-authored-by: KSneijders <32707500+KSneijders@users.noreply.github.com>
2021-04-12 00:14:18 -07:00
trop[bot]
c104b510b0 docs: systemPreferences.subscribeWorkspaceNotification return type (#28613)
Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>
2021-04-12 00:12:50 -07:00
trop[bot]
02a2d33edc build: give ASAN tests more memory to avoid SIGKILL or disabling tests (#28592)
* build: give ASAN tests more memory

* test: re-eanble asan tests

Co-authored-by: Samuel Attard <sattard@slack-corp.com>
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
2021-04-09 18:53:06 +09:00
trop[bot]
ad8f93517e chore: don't minimize js in development (#28586)
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
2021-04-09 16:09:53 +09:00
trop[bot]
a58b5ec3f0 docs: note that new-window event is deprecated (#28582)
* docs: note that new-window event is deprecated

* Update breaking-changes.md

* Update docs/breaking-changes.md

Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2021-04-08 12:12:45 -04:00
21 changed files with 147 additions and 85 deletions

View File

@@ -2326,7 +2326,7 @@ jobs:
<<: *steps-tests
linux-x64-testing-asan-tests:
<<: *machine-linux-medium
<<: *machine-linux-xlarge
environment:
<<: *env-linux-medium
<<: *env-headless-testing

View File

@@ -1 +1 @@
13.0.0-beta.12
13.0.0-beta.13

View File

@@ -163,7 +163,7 @@ if ((globalThis.process || binding.process).argv.includes("--profile-electron-in
setImmediate: false
},
optimization: {
minimize: true,
minimize: env.mode === 'production',
minimizer: [
new TerserPlugin({
terserOptions: {

View File

@@ -22,6 +22,11 @@ template("webpack_build") {
"//electron/typings/internal-electron.d.ts",
] + invoker.inputs
mode = "development"
if (is_official_build) {
mode = "production"
}
args = [
"--config",
rebase_path(invoker.config_file),
@@ -29,6 +34,7 @@ template("webpack_build") {
"--output-path=" + rebase_path(get_path_info(invoker.out_file, "dir")),
"--env.buildflags=" +
rebase_path("$target_gen_dir/buildflags/buildflags.h"),
"--env.mode=" + mode,
]
deps += [ "buildflags" ]

View File

@@ -130,6 +130,8 @@ This is necessary for events such as `NSUserDefaultsDidChangeNotification`.
* `userInfo` Record<String, unknown>
* `object` String
Returns `Number` - The ID of this subscription
Same as `subscribeNotification`, but uses `NSWorkspace.sharedWorkspace.notificationCenter`.
This is necessary for events such as `NSWorkspaceDidActivateApplicationNotification`.

View File

@@ -136,6 +136,22 @@ systemPreferences.isHighContrastColorScheme()
nativeTheme.shouldUseHighContrastColors
```
### Deprecated: WebContents `new-window` event
The `new-window` event of WebContents has been deprecated. It is replaced by [`webContents.setWindowOpenHandler()`](api/web-contents.md#contentssetwindowopenhandlerhandler).
```js
// Deprecated in Electron 13
webContents.on('new-window', (event) => {
event.preventDefault()
})
// Replace with
webContents.setWindowOpenHandler((details) => {
return { action: 'deny' }
})
```
## Planned Breaking API Changes (12.0)
### Removed: Pepper Flash support

View File

@@ -123,7 +123,7 @@ The `index.html` page looks as follows:
#### Define a preload script
Your preload script acts as a bridge between Node.js and your web page. It allows you to expose specific APIs and behaviors to your web page rather than insecurely exposing the entire Node.js API. In this example we will use the preload script to read version information from the `process` object and update the web page with that info.
Your preload script (in our case, the `preload.js` file) acts as a bridge between Node.js and your web page. It allows you to expose specific APIs and behaviors to your web page rather than insecurely exposing the entire Node.js API. In this example we will use the preload script to read version information from the `process` object and update the web page with that info.
```javascript fiddle='docs/fiddles/quick-start'
window.addEventListener('DOMContentLoaded', () => {

View File

@@ -404,6 +404,8 @@ filenames = {
"shell/browser/native_window_observer.h",
"shell/browser/net/asar/asar_url_loader.cc",
"shell/browser/net/asar/asar_url_loader.h",
"shell/browser/net/asar/asar_url_loader_factory.cc",
"shell/browser/net/asar/asar_url_loader_factory.h",
"shell/browser/net/cert_verifier_client.cc",
"shell/browser/net/cert_verifier_client.h",
"shell/browser/net/electron_url_loader_factory.cc",

View File

@@ -1,6 +1,6 @@
{
"name": "electron",
"version": "13.0.0-beta.12",
"version": "13.0.0-beta.13",
"repository": "https://github.com/electron/electron",
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
"devDependencies": {

View File

@@ -0,0 +1,42 @@
// Copyright (c) 2021 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/net/asar/asar_url_loader_factory.h"
#include <utility>
#include "shell/browser/net/asar/asar_url_loader.h"
namespace electron {
// static
mojo::PendingRemote<network::mojom::URLLoaderFactory>
AsarURLLoaderFactory::Create() {
mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote;
// The AsarURLLoaderFactory will delete itself when there are no more
// receivers - see the SelfDeletingURLLoaderFactory::OnDisconnect method.
new AsarURLLoaderFactory(pending_remote.InitWithNewPipeAndPassReceiver());
return pending_remote;
}
AsarURLLoaderFactory::AsarURLLoaderFactory(
mojo::PendingReceiver<network::mojom::URLLoaderFactory> factory_receiver)
: network::SelfDeletingURLLoaderFactory(std::move(factory_receiver)) {}
AsarURLLoaderFactory::~AsarURLLoaderFactory() = default;
void AsarURLLoaderFactory::CreateLoaderAndStart(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
int32_t routing_id,
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
asar::CreateAsarURLLoader(request, std::move(loader), std::move(client),
new net::HttpResponseHeaders(""));
}
} // namespace electron

View File

@@ -0,0 +1,38 @@
// Copyright (c) 2021 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_NET_ASAR_ASAR_URL_LOADER_FACTORY_H_
#define SHELL_BROWSER_NET_ASAR_ASAR_URL_LOADER_FACTORY_H_
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/network/public/cpp/self_deleting_url_loader_factory.h"
namespace electron {
// Provide support for accessing asar archives in file:// protocol.
class AsarURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
public:
static mojo::PendingRemote<network::mojom::URLLoaderFactory> Create();
private:
AsarURLLoaderFactory(
mojo::PendingReceiver<network::mojom::URLLoaderFactory> factory_receiver);
~AsarURLLoaderFactory() override;
// network::mojom::URLLoaderFactory:
void CreateLoaderAndStart(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
int32_t routing_id,
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
override;
};
} // namespace electron
#endif // SHELL_BROWSER_NET_ASAR_ASAR_URL_LOADER_FACTORY_H_

View File

@@ -2,55 +2,17 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/protocol_registry.h"
#include <memory>
#include <utility>
#include "content/public/browser/web_contents.h"
#include "services/network/public/cpp/self_deleting_url_loader_factory.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/net/asar/asar_url_loader.h"
#include "shell/browser/protocol_registry.h"
#include "shell/browser/net/asar/asar_url_loader_factory.h"
namespace electron {
namespace {
// Provide support for accessing asar archives in file:// protocol.
class AsarURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
public:
static mojo::PendingRemote<network::mojom::URLLoaderFactory> Create() {
mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote;
// The AsarURLLoaderFactory will delete itself when there are no more
// receivers - see the SelfDeletingURLLoaderFactory::OnDisconnect method.
new AsarURLLoaderFactory(pending_remote.InitWithNewPipeAndPassReceiver());
return pending_remote;
}
private:
AsarURLLoaderFactory(
mojo::PendingReceiver<network::mojom::URLLoaderFactory> factory_receiver)
: network::SelfDeletingURLLoaderFactory(std::move(factory_receiver)) {}
~AsarURLLoaderFactory() override = default;
// network::mojom::URLLoaderFactory:
void CreateLoaderAndStart(
mojo::PendingReceiver<network::mojom::URLLoader> loader,
int32_t routing_id,
int32_t request_id,
uint32_t options,
const network::ResourceRequest& request,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
override {
asar::CreateAsarURLLoader(request, std::move(loader), std::move(client),
new net::HttpResponseHeaders(""));
}
};
} // namespace
// static
ProtocolRegistry* ProtocolRegistry::FromBrowserContext(
content::BrowserContext* context) {

View File

@@ -30,6 +30,7 @@ class ProtocolRegistry {
bool allow_file_access);
const HandlersMap& intercept_handlers() const { return intercept_handlers_; }
const HandlersMap& handlers() const { return handlers_; }
bool RegisterProtocol(ProtocolType type,
const std::string& scheme,

View File

@@ -50,8 +50,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 13,0,0,12
PRODUCTVERSION 13,0,0,12
FILEVERSION 13,0,0,13
PRODUCTVERSION 13,0,0,13
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L

View File

@@ -41,6 +41,8 @@
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
#include "shell/browser/net/asar/asar_url_loader_factory.h"
#include "shell/browser/protocol_registry.h"
#include "shell/browser/ui/inspectable_web_contents_delegate.h"
#include "shell/browser/ui/inspectable_web_contents_view.h"
#include "shell/browser/ui/inspectable_web_contents_view_delegate.h"
@@ -676,12 +678,20 @@ void InspectableWebContents::LoadNetworkResource(DispatchCallback callback,
resource_request.site_for_cookies = net::SiteForCookies::FromUrl(gurl);
resource_request.headers.AddHeadersFromString(headers);
auto* protocol_registry = ProtocolRegistry::FromBrowserContext(
GetDevToolsWebContents()->GetBrowserContext());
NetworkResourceLoader::URLLoaderFactoryHolder url_loader_factory;
if (gurl.SchemeIsFile()) {
mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote =
content::CreateFileURLLoaderFactory(
base::FilePath() /* profile_path */,
nullptr /* shared_cors_origin_access_list */);
AsarURLLoaderFactory::Create();
url_loader_factory = network::SharedURLLoaderFactory::Create(
std::make_unique<network::WrapperPendingSharedURLLoaderFactory>(
std::move(pending_remote)));
} else if (protocol_registry->IsProtocolRegistered(gurl.scheme())) {
auto& protocol_handler = protocol_registry->handlers().at(gurl.scheme());
mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote =
ElectronURLLoaderFactory::Create(protocol_handler.first,
protocol_handler.second);
url_loader_factory = network::SharedURLLoaderFactory::Create(
std::make_unique<network::WrapperPendingSharedURLLoaderFactory>(
std::move(pending_remote)));

View File

@@ -143,8 +143,7 @@ describe('app module', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('app.exit(exitCode)', () => {
describe('app.exit(exitCode)', () => {
let appProcess: cp.ChildProcess | null = null;
afterEach(() => {
@@ -210,8 +209,7 @@ describe('app module', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('app.requestSingleInstanceLock', () => {
describe('app.requestSingleInstanceLock', () => {
it('prevents the second launch of app', async function () {
this.timeout(120000);
const appPath = path.join(fixturesPath, 'api', 'singleton');
@@ -253,8 +251,7 @@ describe('app module', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('app.relaunch', () => {
describe('app.relaunch', () => {
let server: net.Server | null = null;
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch';
@@ -949,8 +946,7 @@ describe('app module', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('getAppPath', () => {
describe('getAppPath', () => {
it('works for directories with package.json', async () => {
const { appPath } = await runTestApp('app-path');
expect(appPath).to.equal(path.resolve(fixturesPath, 'api/app-path'));
@@ -1426,8 +1422,7 @@ describe('app module', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('sandbox options', () => {
describe('sandbox options', () => {
let appProcess: cp.ChildProcess = null as any;
let server: net.Server = null as any;
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-mixed-sandbox' : '/tmp/electron-mixed-sandbox';
@@ -1652,8 +1647,7 @@ describe('app module', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('commandLine.hasSwitch (existing argv)', () => {
describe('commandLine.hasSwitch (existing argv)', () => {
it('returns true when present', async () => {
const { hasSwitch } = await runTestApp('command-line', '--foobar');
expect(hasSwitch).to.equal(true);
@@ -1681,8 +1675,7 @@ describe('app module', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('commandLine.getSwitchValue (existing argv)', () => {
describe('commandLine.getSwitchValue (existing argv)', () => {
it('returns the value when present', async () => {
const { getSwitchValue } = await runTestApp('command-line', '--foobar=test');
expect(getSwitchValue).to.equal('test');
@@ -1709,8 +1702,7 @@ describe('app module', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('default behavior', () => {
describe('default behavior', () => {
describe('application menu', () => {
it('creates the default menu if the app does not set it', async () => {
const result = await runTestApp('default-menu');

View File

@@ -12,7 +12,7 @@ import { EventEmitter } from 'events';
import { closeWindow } from './window-helpers';
import { emittedOnce } from './events-helpers';
import { WebmGenerator } from './video-helpers';
import { delay, ifit } from './spec-helpers';
import { delay } from './spec-helpers';
const fixturesPath = path.resolve(__dirname, '..', 'spec', 'fixtures');
@@ -705,8 +705,7 @@ describe('protocol module', () => {
});
describe('protocol.registerSchemeAsPrivileged', () => {
// Running child app under ASan might receive SIGKILL because of OOM.
ifit(!process.env.IS_ASAN)('does not crash on exit', async () => {
it('does not crash on exit', async () => {
const appPath = path.join(__dirname, 'fixtures', 'api', 'custom-protocol-shutdown.js');
const appProcess = ChildProcess.spawn(process.execPath, ['--enable-logging', appPath]);
let stdout = '';

View File

@@ -367,8 +367,7 @@ describe('web security', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('command line switches', () => {
describe('command line switches', () => {
let appProcess: ChildProcess.ChildProcessWithoutNullStreams | undefined;
afterEach(() => {
if (appProcess && !appProcess.killed) {

View File

@@ -2,7 +2,6 @@ import { expect } from 'chai';
import * as cp from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import { ifdescribe } from './spec-helpers';
const fixturePath = path.resolve(__dirname, 'fixtures', 'crash-cases');
@@ -31,8 +30,7 @@ const runFixtureAndEnsureCleanExit = (args: string[]) => {
});
};
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('crash cases', () => {
describe('crash cases', () => {
afterEach(() => {
for (const child of children) {
child.kill();

View File

@@ -23,8 +23,7 @@ describe('node feature', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifit(!process.env.IS_ASAN)('does not hang when using the fs module in the renderer process', async () => {
it('does not hang when using the fs module in the renderer process', async () => {
const appPath = path.join(mainFixturesPath, 'apps', 'libuv-hang', 'main.js');
const appProcess = childProcess.spawn(process.execPath, [appPath], {
cwd: path.join(mainFixturesPath, 'apps', 'libuv-hang'),
@@ -135,8 +134,7 @@ describe('node feature', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(features.isRunAsNodeEnabled() && !process.env.IS_ASAN)('Node.js cli flags', () => {
ifdescribe(features.isRunAsNodeEnabled())('Node.js cli flags', () => {
let child: childProcess.ChildProcessWithoutNullStreams;
let exitPromise: Promise<any[]>;
@@ -178,8 +176,7 @@ describe('node feature', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifdescribe(features.isRunAsNodeEnabled() && !process.env.IS_ASAN)('inspector', () => {
ifdescribe(features.isRunAsNodeEnabled())('inspector', () => {
let child: childProcess.ChildProcessWithoutNullStreams;
let exitPromise: Promise<any[]>;
@@ -317,8 +314,7 @@ describe('node feature', () => {
});
});
// Running child app under ASan might receive SIGKILL because of OOM.
ifit(!process.env.IS_ASAN)('Can find a module using a package.json main field', () => {
it('Can find a module using a package.json main field', () => {
const result = childProcess.spawnSync(process.execPath, [path.resolve(fixtures, 'api', 'electron-main-module', 'app.asar')]);
expect(result.status).to.equal(0);
});

View File

@@ -28,8 +28,7 @@ async function loadWebView (w: WebContents, attributes: Record<string, string>,
`);
}
// The render process of webview might receive SIGKILL because of OOM.
ifdescribe(!process.env.IS_ASAN)('<webview> tag', function () {
describe('<webview> tag', function () {
const fixtures = path.join(__dirname, '..', 'spec', 'fixtures');
afterEach(closeAllWindows);