feat: add WebFrameMain detached property (#43473)
* feat: add WebFrameMain detached property fix: throw instead of returning null senderFrame test: detached frames fix: ensure IPCs of pending deletion RFHs are dispatched fix: lookup WFM by FTN ID to dispatch IPCs feat: add frame.isDestroyed() return null fix: return undefined docs: add null to all frame properties refactor: option c, return null and emit warning refactor: add routingId & processId to navigation events test: null frame property docs: clarify warning message better wording clarify null frame fix: browserwindow spec * maybe fix 🤷 * fix: use updated util #43722 * docs: add notice for frame change of behavior * docs: clarify why frame properties may be null * lint * wip * fix: content::FrameTreeNodeId lookup and converter * refactor: avoid holey array deoptimization --------- Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
parent
527efc01a4
commit
8b3d70a2a3
20 changed files with 410 additions and 126 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "content/public/browser/render_process_host.h"
|
||||
#include "shell/browser/api/electron_api_web_frame_main.h"
|
||||
#include "shell/common/gin_helper/accessor.h"
|
||||
#include "shell/common/node_util.h"
|
||||
|
||||
namespace gin {
|
||||
|
||||
|
@ -17,6 +18,13 @@ v8::Persistent<v8::ObjectTemplate> rfh_templ;
|
|||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Converter<content::FrameTreeNodeId>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const content::FrameTreeNodeId& val) {
|
||||
return v8::Number::New(isolate, val.value());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Converter<content::RenderFrameHost*>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
|
@ -94,8 +102,17 @@ bool Converter<gin_helper::AccessorValue<content::RenderFrameHost*>>::FromV8(
|
|||
const int routing_id = routing_id_wrapper.As<v8::Number>()->Value();
|
||||
|
||||
auto* rfh = content::RenderFrameHost::FromID(process_id, routing_id);
|
||||
if (!rfh)
|
||||
return false;
|
||||
|
||||
if (!rfh) {
|
||||
// Lazily evaluted property accessed after RFH has been destroyed.
|
||||
// Continue to return nullptr, but emit warning to inform developers
|
||||
// what occurred.
|
||||
electron::util::EmitWarning(
|
||||
isolate,
|
||||
"Frame property was accessed after it navigated or was destroyed. "
|
||||
"Avoid asynchronous tasks prior to indexing.",
|
||||
"electron");
|
||||
}
|
||||
|
||||
out->Value = rfh;
|
||||
return true;
|
||||
|
|
|
@ -5,15 +5,23 @@
|
|||
#ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_FRAME_CONVERTER_H_
|
||||
#define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_FRAME_CONVERTER_H_
|
||||
|
||||
#include "content/public/browser/frame_tree_node_id.h"
|
||||
#include "gin/converter.h"
|
||||
#include "shell/common/gin_helper/accessor.h"
|
||||
|
||||
namespace content {
|
||||
class RenderFrameHost;
|
||||
|
||||
}
|
||||
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<content::FrameTreeNodeId> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const content::FrameTreeNodeId& val);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<content::RenderFrameHost*> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue