From bad88c6ed450dd87ce160bfaa54091db9f075714 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 22 Jan 2026 02:05:26 +0100 Subject: [PATCH] fix: potential devtools crash on empty (#49468) --- lib/renderer/inspector.ts | 14 ++++++++------ shell/renderer/api/electron_api_context_bridge.cc | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/renderer/inspector.ts b/lib/renderer/inspector.ts index 023c4ee36b..5afc958d49 100644 --- a/lib/renderer/inspector.ts +++ b/lib/renderer/inspector.ts @@ -11,12 +11,14 @@ const { contextIsolationEnabled } = internalContextBridge; * 1) Use menu API to show context menu. */ window.onload = function () { - if (contextIsolationEnabled) { - internalContextBridge.overrideGlobalValueFromIsolatedWorld([ - 'InspectorFrontendHost', 'showContextMenuAtPoint' - ], createMenu); - } else { - window.InspectorFrontendHost!.showContextMenuAtPoint = createMenu; + if (window.InspectorFrontendHost) { + if (contextIsolationEnabled) { + internalContextBridge.overrideGlobalValueFromIsolatedWorld([ + 'InspectorFrontendHost', 'showContextMenuAtPoint' + ], createMenu); + } else { + window.InspectorFrontendHost.showContextMenuAtPoint = createMenu; + } } }; diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 343fa0e70b..e9c48ef4fb 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -830,7 +830,9 @@ gin_helper::Dictionary TraceKeyPath(const gin_helper::Dictionary& start, const std::vector& key_path) { gin_helper::Dictionary current = start; for (size_t i = 0; i < key_path.size() - 1; i++) { - CHECK(current.Get(key_path[i], ¤t)); + CHECK(current.Get(key_path[i], ¤t)) + << "Failed to get property '" << key_path[i] << "' at index " << i + << " in key path"; } return current; }