electron13: update to 13.6.1.

This commit is contained in:
John 2021-11-11 21:51:41 +01:00
parent 32a51d8956
commit f764569db1
5 changed files with 25 additions and 473 deletions

View File

@ -0,0 +1,19 @@
--- a/third_party/electron_node/configure 2021-02-22 19:33:12.000000000 +0100
+++ - 2021-11-11 22:27:24.897070513 +0100
@@ -5,6 +5,7 @@
# as is the fact that the ] goes on a new line.
_=[ 'exec' '/bin/sh' '-c' '''
test ${FORCE_PYTHON2} && exec python2 "$0" "$@" # workaround for gclient
+command -v python3.10 >/dev/null && exec python3.10 "$0" "$@"
command -v python3.9 >/dev/null && exec python3.9 "$0" "$@"
command -v python3.8 >/dev/null && exec python3.8 "$0" "$@"
command -v python3.7 >/dev/null && exec python3.7 "$0" "$@"
@@ -21,7 +22,7 @@
from distutils.spawn import find_executable
print('Node.js configure: Found Python {0}.{1}.{2}...'.format(*sys.version_info))
-acceptable_pythons = ((3, 9), (3, 8), (3, 7), (3, 6), (3, 5), (2, 7))
+acceptable_pythons = ((3,10), (3, 9), (3, 8), (3, 7), (3, 6), (3, 5), (2, 7))
if sys.version_info[:2] in acceptable_pythons:
import configure
else:

View File

@ -1,25 +0,0 @@
From 2eed61fc21cb71082afd894c3bcd482b9ed78c0f Mon Sep 17 00:00:00 2001
From: John Zimmermann <me@johnnynator.dev>
Date: Mon, 30 Aug 2021 23:02:20 +0200
Subject: [PATCH 1/2] Revert "fix: WebFrameMain mojo pipe not reset (#30630)"
This reverts commit 7fb719f261e14a857ea4dbc6cfa8ab697670427d.
---
shell/browser/api/electron_api_web_frame_main.cc | 1 -
1 file changed, 1 deletion(-)
diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc
index 780a976..185cdc4 100644
--- a/shell/browser/api/electron_api_web_frame_main.cc
+++ b/shell/browser/api/electron_api_web_frame_main.cc
@@ -80,7 +80,6 @@ void WebFrameMain::UpdateRenderFrameHost(content::RenderFrameHost* rfh) {
// Should only be called when swapping frames.
DCHECK(render_frame_);
render_frame_ = rfh;
- renderer_api_.reset();
}
bool WebFrameMain::CheckRenderFrame() const {
--
2.33.0

View File

@ -1,442 +0,0 @@
From d4f351228c8215eea316e74fca0a2d02cd7c19dc Mon Sep 17 00:00:00 2001
From: John Zimmermann <me@johnnynator.dev>
Date: Mon, 30 Aug 2021 23:02:49 +0200
Subject: [PATCH 2/2] Revert "fix: cross-origin navigation disposing
WebFrameMain instances (#30598)"
This reverts commit 18de6be607dce5126f18216eb972061be86e3db0.
---
.../browser/api/electron_api_web_contents.cc | 51 ++--------
shell/browser/api/electron_api_web_contents.h | 5 +-
.../api/electron_api_web_frame_main.cc | 93 ++++++++++---------
.../browser/api/electron_api_web_frame_main.h | 38 +++-----
spec-main/api-web-frame-main-spec.ts | 63 ++++++-------
5 files changed, 98 insertions(+), 152 deletions(-)
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index e2fc303..6211b08 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -1386,9 +1386,7 @@ void WebContents::HandleNewRenderFrame(
if (rwh_impl)
rwh_impl->disable_hidden_ = !background_throttling_;
- auto* web_frame = WebFrameMain::FromRenderFrameHost(render_frame_host);
- if (web_frame)
- web_frame->Connect();
+ WebFrameMain::RenderFrameCreated(render_frame_host);
}
void WebContents::RenderFrameCreated(
@@ -1396,46 +1394,6 @@ void WebContents::RenderFrameCreated(
HandleNewRenderFrame(render_frame_host);
}
-void WebContents::RenderFrameDeleted(
- content::RenderFrameHost* render_frame_host) {
- // A RenderFrameHost can be deleted when:
- // - A WebContents is removed and its containing frames are disposed.
- // - An <iframe> is removed from the DOM.
- // - Cross-origin navigation creates a new RFH in a separate process which
- // is swapped by content::RenderFrameHostManager.
- //
- // WebFrameMain::FromRenderFrameHost(rfh) will use the RFH's FrameTreeNode ID
- // to find an existing instance of WebFrameMain. During a cross-origin
- // navigation, the deleted RFH will be the old host which was swapped out. In
- // this special case, we need to also ensure that WebFrameMain's internal RFH
- // matches before marking it as disposed.
- auto* web_frame = WebFrameMain::FromRenderFrameHost(render_frame_host);
- if (web_frame && web_frame->render_frame_host() == render_frame_host)
- web_frame->MarkRenderFrameDisposed();
-}
-
-void WebContents::RenderFrameHostChanged(content::RenderFrameHost* old_host,
- content::RenderFrameHost* new_host) {
- // During cross-origin navigation, a FrameTreeNode will swap out its RFH.
- // If an instance of WebFrameMain exists, it will need to have its RFH
- // swapped as well.
- //
- // |old_host| can be a nullptr in so we use |new_host| for looking up the
- // WebFrameMain instance.
- auto* web_frame =
- WebFrameMain::FromFrameTreeNodeId(new_host->GetFrameTreeNodeId());
- if (web_frame) {
- CHECK_EQ(web_frame->render_frame_host(), old_host);
- web_frame->UpdateRenderFrameHost(new_host);
- }
-}
-
-void WebContents::FrameDeleted(int frame_tree_node_id) {
- auto* web_frame = WebFrameMain::FromFrameTreeNodeId(frame_tree_node_id);
- if (web_frame)
- web_frame->Destroyed();
-}
-
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
// This event is necessary for tracking any states with respect to
// intermediate render view hosts aka speculative render view hosts. Currently
@@ -1677,6 +1635,13 @@ void WebContents::UpdateDraggableRegions(
observer.OnDraggableRegionsUpdated(regions);
}
+void WebContents::RenderFrameDeleted(
+ content::RenderFrameHost* render_frame_host) {
+ // A WebFrameMain can outlive its RenderFrameHost so we need to mark it as
+ // disposed to prevent access to it.
+ WebFrameMain::RenderFrameDeleted(render_frame_host);
+}
+
void WebContents::DidStartNavigation(
content::NavigationHandle* navigation_handle) {
EmitNavigationEvent("did-start-navigation", navigation_handle);
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 3ed91c9..3f87f8b 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -551,12 +551,9 @@ class WebContents : public gin::Wrappable<WebContents>,
void BeforeUnloadFired(bool proceed,
const base::TimeTicks& proceed_time) override;
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
- void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
- void RenderFrameHostChanged(content::RenderFrameHost* old_host,
- content::RenderFrameHost* new_host) override;
- void FrameDeleted(int frame_tree_node_id) override;
void RenderViewDeleted(content::RenderViewHost*) override;
void RenderProcessGone(base::TerminationStatus status) override;
+ void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
void DOMContentLoaded(content::RenderFrameHost* render_frame_host) override;
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) override;
diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc
index 185cdc4..9ef45ea 100644
--- a/shell/browser/api/electron_api_web_frame_main.cc
+++ b/shell/browser/api/electron_api_web_frame_main.cc
@@ -9,8 +9,8 @@
#include <utility>
#include <vector>
+#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/no_destructor.h"
#include "content/browser/renderer_host/frame_tree_node.h" // nogncheck
#include "content/public/browser/render_frame_host.h"
#include "electron/shell/common/api/api.mojom.h"
@@ -34,54 +34,36 @@ namespace electron {
namespace api {
-typedef std::unordered_map<int, WebFrameMain*> WebFrameMainIdMap;
+typedef std::unordered_map<content::RenderFrameHost*, WebFrameMain*>
+ RenderFrameMap;
+base::LazyInstance<RenderFrameMap>::DestructorAtExit g_render_frame_map =
+ LAZY_INSTANCE_INITIALIZER;
-WebFrameMainIdMap& GetWebFrameMainMap() {
- static base::NoDestructor<WebFrameMainIdMap> instance;
- return *instance;
-}
-
-// static
-WebFrameMain* WebFrameMain::FromFrameTreeNodeId(int frame_tree_node_id) {
- WebFrameMainIdMap& frame_map = GetWebFrameMainMap();
- auto iter = frame_map.find(frame_tree_node_id);
+WebFrameMain* FromRenderFrameHost(content::RenderFrameHost* rfh) {
+ auto frame_map = g_render_frame_map.Get();
+ auto iter = frame_map.find(rfh);
auto* web_frame = iter == frame_map.end() ? nullptr : iter->second;
return web_frame;
}
-// static
-WebFrameMain* WebFrameMain::FromRenderFrameHost(content::RenderFrameHost* rfh) {
- return rfh ? FromFrameTreeNodeId(rfh->GetFrameTreeNodeId()) : nullptr;
-}
-
gin::WrapperInfo WebFrameMain::kWrapperInfo = {gin::kEmbedderNativeGin};
-WebFrameMain::WebFrameMain(content::RenderFrameHost* rfh)
- : frame_tree_node_id_(rfh->GetFrameTreeNodeId()), render_frame_(rfh) {
- GetWebFrameMainMap().emplace(frame_tree_node_id_, this);
+WebFrameMain::WebFrameMain(content::RenderFrameHost* rfh) : render_frame_(rfh) {
+ g_render_frame_map.Get().emplace(rfh, this);
}
WebFrameMain::~WebFrameMain() {
- Destroyed();
-}
-
-void WebFrameMain::Destroyed() {
MarkRenderFrameDisposed();
- GetWebFrameMainMap().erase(frame_tree_node_id_);
- Unpin();
}
void WebFrameMain::MarkRenderFrameDisposed() {
- render_frame_ = nullptr;
+ if (render_frame_disposed_)
+ return;
+ Unpin();
+ g_render_frame_map.Get().erase(render_frame_);
render_frame_disposed_ = true;
}
-void WebFrameMain::UpdateRenderFrameHost(content::RenderFrameHost* rfh) {
- // Should only be called when swapping frames.
- DCHECK(render_frame_);
- render_frame_ = rfh;
-}
-
bool WebFrameMain::CheckRenderFrame() const {
if (render_frame_disposed_) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
@@ -209,7 +191,9 @@ void WebFrameMain::PostMessage(v8::Isolate* isolate,
}
int WebFrameMain::FrameTreeNodeID() const {
- return frame_tree_node_id_;
+ if (!CheckRenderFrame())
+ return -1;
+ return render_frame_->GetFrameTreeNodeId();
}
std::string WebFrameMain::Name() const {
@@ -281,13 +265,6 @@ std::vector<content::RenderFrameHost*> WebFrameMain::FramesInSubtree() const {
return frame_hosts;
}
-void WebFrameMain::Connect() {
- if (pending_receiver_) {
- render_frame_->GetRemoteInterfaces()->GetInterface(
- std::move(pending_receiver_));
- }
-}
-
// static
gin::Handle<WebFrameMain> WebFrameMain::New(v8::Isolate* isolate) {
return gin::Handle<WebFrameMain>();
@@ -310,6 +287,35 @@ gin::Handle<WebFrameMain> WebFrameMain::From(v8::Isolate* isolate,
return handle;
}
+// static
+gin::Handle<WebFrameMain> WebFrameMain::FromID(v8::Isolate* isolate,
+ int render_process_id,
+ int render_frame_id) {
+ auto* rfh =
+ content::RenderFrameHost::FromID(render_process_id, render_frame_id);
+ return From(isolate, rfh);
+}
+
+// static
+void WebFrameMain::RenderFrameDeleted(content::RenderFrameHost* rfh) {
+ auto* web_frame = FromRenderFrameHost(rfh);
+ if (web_frame)
+ web_frame->MarkRenderFrameDisposed();
+}
+
+void WebFrameMain::RenderFrameCreated(content::RenderFrameHost* rfh) {
+ auto* web_frame = FromRenderFrameHost(rfh);
+ if (web_frame)
+ web_frame->Connect();
+}
+
+void WebFrameMain::Connect() {
+ if (pending_receiver_) {
+ render_frame_->GetRemoteInterfaces()->GetInterface(
+ std::move(pending_receiver_));
+ }
+}
+
// static
v8::Local<v8::ObjectTemplate> WebFrameMain::FillObjectTemplate(
v8::Isolate* isolate,
@@ -352,10 +358,9 @@ v8::Local<v8::Value> FromID(gin_helper::ErrorThrower thrower,
return v8::Null(thrower.isolate());
}
- auto* rfh =
- content::RenderFrameHost::FromID(render_process_id, render_frame_id);
-
- return WebFrameMain::From(thrower.isolate(), rfh).ToV8();
+ return WebFrameMain::FromID(thrower.isolate(), render_process_id,
+ render_frame_id)
+ .ToV8();
}
void Initialize(v8::Local<v8::Object> exports,
diff --git a/shell/browser/api/electron_api_web_frame_main.h b/shell/browser/api/electron_api_web_frame_main.h
index 188f9c1..4d0dc98 100644
--- a/shell/browser/api/electron_api_web_frame_main.h
+++ b/shell/browser/api/electron_api_web_frame_main.h
@@ -34,8 +34,6 @@ namespace electron {
namespace api {
-class WebContents;
-
// Bindings for accessing frames from the main process.
class WebFrameMain : public gin::Wrappable<WebFrameMain>,
public gin_helper::Pinnable<WebFrameMain>,
@@ -44,12 +42,23 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
// Create a new WebFrameMain and return the V8 wrapper of it.
static gin::Handle<WebFrameMain> New(v8::Isolate* isolate);
+ static gin::Handle<WebFrameMain> FromID(v8::Isolate* isolate,
+ int render_process_id,
+ int render_frame_id);
static gin::Handle<WebFrameMain> From(
v8::Isolate* isolate,
content::RenderFrameHost* render_frame_host);
- static WebFrameMain* FromFrameTreeNodeId(int frame_tree_node_id);
- static WebFrameMain* FromRenderFrameHost(
- content::RenderFrameHost* render_frame_host);
+
+ // Called to mark any RenderFrameHost as disposed by any WebFrameMain that
+ // may be holding a weak reference.
+ static void RenderFrameDeleted(content::RenderFrameHost* rfh);
+ static void RenderFrameCreated(content::RenderFrameHost* rfh);
+
+ // Mark RenderFrameHost as disposed and to no longer access it. This can
+ // occur upon frame navigation.
+ void MarkRenderFrameDisposed();
+
+ const mojo::Remote<mojom::ElectronRenderer>& GetRendererApi();
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
@@ -58,28 +67,11 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
v8::Local<v8::ObjectTemplate>);
const char* GetTypeName() override;
- content::RenderFrameHost* render_frame_host() const { return render_frame_; }
-
protected:
explicit WebFrameMain(content::RenderFrameHost* render_frame);
~WebFrameMain() override;
private:
- friend class WebContents;
-
- // Called when FrameTreeNode is deleted.
- void Destroyed();
-
- // Mark RenderFrameHost as disposed and to no longer access it. This can
- // happen when the WebFrameMain v8 handle is GC'd or when a FrameTreeNode
- // is removed.
- void MarkRenderFrameDisposed();
-
- // Swap out the internal RFH when cross-origin navigation occurs.
- void UpdateRenderFrameHost(content::RenderFrameHost* rfh);
-
- const mojo::Remote<mojom::ElectronRenderer>& GetRendererApi();
-
// WebFrameMain can outlive its RenderFrameHost pointer so we need to check
// whether its been disposed of prior to accessing it.
bool CheckRenderFrame() const;
@@ -114,8 +106,6 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
mojo::Remote<mojom::ElectronRenderer> renderer_api_;
mojo::PendingReceiver<mojom::ElectronRenderer> pending_receiver_;
- int frame_tree_node_id_;
-
content::RenderFrameHost* render_frame_ = nullptr;
// Whether the RenderFrameHost has been removed and that it should no longer
diff --git a/spec-main/api-web-frame-main-spec.ts b/spec-main/api-web-frame-main-spec.ts
index 255fcaf..fa178f3 100644
--- a/spec-main/api-web-frame-main-spec.ts
+++ b/spec-main/api-web-frame-main-spec.ts
@@ -13,24 +13,6 @@ describe('webFrameMain module', () => {
const fileUrl = (filename: string) => url.pathToFileURL(path.join(subframesPath, filename)).href;
- type Server = { server: http.Server, url: string }
-
- /** Creates an HTTP server whose handler embeds the given iframe src. */
- const createServer = () => new Promise<Server>(resolve => {
- const server = http.createServer((req, res) => {
- const params = new URLSearchParams(url.parse(req.url || '').search || '');
- if (params.has('frameSrc')) {
- res.end(`<iframe src="${params.get('frameSrc')}"></iframe>`);
- } else {
- res.end('');
- }
- });
- server.listen(0, '127.0.0.1', () => {
- const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/`;
- resolve({ server, url });
- });
- });
-
afterEach(closeAllWindows);
describe('WebFrame traversal APIs', () => {
@@ -87,6 +69,24 @@ describe('webFrameMain module', () => {
});
describe('cross-origin', () => {
+ type Server = { server: http.Server, url: string }
+
+ /** Creates an HTTP server whose handler embeds the given iframe src. */
+ const createServer = () => new Promise<Server>(resolve => {
+ const server = http.createServer((req, res) => {
+ const params = new URLSearchParams(url.parse(req.url || '').search || '');
+ if (params.has('frameSrc')) {
+ res.end(`<iframe src="${params.get('frameSrc')}"></iframe>`);
+ } else {
+ res.end('');
+ }
+ });
+ server.listen(0, '127.0.0.1', () => {
+ const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/`;
+ resolve({ server, url });
+ });
+ });
+
let serverA = null as unknown as Server;
let serverB = null as unknown as Server;
@@ -179,32 +179,21 @@ describe('webFrameMain module', () => {
});
});
- describe('RenderFrame lifespan', () => {
+ describe('disposed WebFrames', () => {
let w: BrowserWindow;
+ let webFrame: WebFrameMain;
- beforeEach(async () => {
+ before(async () => {
w = new BrowserWindow({ show: false, webPreferences: { contextIsolation: true } });
- });
-
- it('throws upon accessing properties when disposed', async () => {
await w.loadFile(path.join(subframesPath, 'frame-with-frame-container.html'));
- const { mainFrame } = w.webContents;
+ webFrame = w.webContents.mainFrame;
w.destroy();
// Wait for WebContents, and thus RenderFrameHost, to be destroyed.
await new Promise(resolve => setTimeout(resolve, 0));
- expect(() => mainFrame.url).to.throw();
- });
-
- it('persists through cross-origin navigation', async () => {
- const server = await createServer();
- // 'localhost' is treated as a separate origin.
- const crossOriginUrl = server.url.replace('127.0.0.1', 'localhost');
- await w.loadURL(server.url);
- const { mainFrame } = w.webContents;
- expect(mainFrame.url).to.equal(server.url);
- await w.loadURL(crossOriginUrl);
- expect(w.webContents.mainFrame).to.equal(mainFrame);
- expect(mainFrame.url).to.equal(crossOriginUrl);
+ });
+
+ it('throws upon accessing properties', () => {
+ expect(() => webFrame.url).to.throw();
});
});
--
2.33.0

View File

@ -4,7 +4,7 @@
for patch_dir, repo in dirs.items():
git.import_patches(repo=repo, patch_data=patch_from_dir(patch_dir),
threeway=threeway is not None,
+ exclude=['test/mjsunit/**', 'content/test/**', 'test/cctest/**', 'test/unittests/**', 'third_party/blink/web_tests/**'],
+ exclude=['third_party/blink/tools/blinkpy/presubmit/**', 'test/mjsunit/**', 'content/test/**', 'test/cctest/**', 'test/unittests/**', 'third_party/blink/web_tests/**'],
committer_name="Electron Scripts", committer_email="scripts@electron")

View File

@ -1,9 +1,9 @@
# Template file for 'electron13'
pkgname=electron13
version=13.3.0
version=13.6.1
revision=1
_nodever=14.16.0
_chromiumver=91.0.4472.69
_chromiumver=91.0.4472.164
archs="x86_64* i686* aarch64* ppc64le*"
create_wrksrc=yes
build_wrksrc="src"
@ -23,7 +23,7 @@ makedepends="libpng-devel gtk+-devel gtk+3-devel nss-devel pciutils-devel
minizip-devel jsoncpp-devel zlib-devel libcap-devel libXdamage-devel
re2-devel fontconfig-devel freetype-devel opus-devel libatomic-devel
$(vopt_if sndio sndio-devel) ffmpeg-devel libva-devel libuv-devel c-ares-devel libnotify-devel
$(vopt_if pipewire pipewire-devel) wayland-devel libcurl-devel"
$(vopt_if pipewire pipewire-devel) wayland-devel libcurl-devel libxshmfence-devel"
short_desc="Cross platform application framework based on web technologies"
maintainer="John <me@johnnynator.dev>"
license="BSD-3-Clause"
@ -31,8 +31,8 @@ homepage="https://electronjs.org"
distfiles="https://github.com/electron/electron/archive/v$version.tar.gz>electron-${version}.tar.gz
https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$_chromiumver.tar.xz
https://github.com/nodejs/node/archive/v$_nodever.tar.gz>node-$_nodever.tar.gz"
checksum="1707f46439407ed0500e44d61c5171ce00f225d1478349472a0e45920d6a75a1
1f6843c636f4adee6b06c301193810cce103ee3e4582d4cbc31c915efc3d0c7b
checksum="288b4d437982701117d3d8ed9324be4df8d82467e171e502af8f382bd5305e70
84e56fa2ad96d910cab429c513eeaca7bfa94096fef057bd024be826ce8426bd
bcdf869b0743405515ee897b1047b5e851a717e426b4974d26537c9b10dfd53a"
case "$XBPS_TARGET_MACHINE" in