From 6ce52ad79290297495442c731d7d7b3f579da44d Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 11:59:57 -0500 Subject: [PATCH] fix: potential devtools crash on empty (#49489) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- 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 23b4d507a6..5b8755748a 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -833,7 +833,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; }