diff --git a/docs/api/context-bridge.md b/docs/api/context-bridge.md index 2c3e9f16fe6bf..fa5ce0a54f262 100644 --- a/docs/api/context-bridge.md +++ b/docs/api/context-bridge.md @@ -48,7 +48,7 @@ The `contextBridge` module has the following methods: ### `contextBridge.exposeInIsolatedWorld(worldId, apiKey, api)` -* `worldId` Integer - The ID of the world to inject the API into. This has to be an existing world. `0` is the default world, `999` is the world used by Electron's `contextIsolation` feature. Using 999 would expose the object for preload context. +* `worldId` Integer - The ID of the world to inject the API into. `0` is the default world, `999` is the world used by Electron's `contextIsolation` feature. Using 999 would expose the object for preload context. We recommend using 1000+ while creating isolated world. * `apiKey` string - The key to inject the API onto `window` with. The API will be accessible on `window[apiKey]`. * `api` any - Your API, more information on what this API can be and how it works is available below. diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 3aa96a80c6724..1754370a3d081 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -575,8 +575,9 @@ void ExposeAPIInWorld(v8::Isolate* isolate, CHECK(frame); v8::Local target_context = - world_id == 0 ? frame->MainWorldScriptContext() - : frame->GetScriptContextFromWorldId(isolate, world_id); + world_id == WorldIDs::MAIN_WORLD_ID + ? frame->MainWorldScriptContext() + : frame->GetScriptContextFromWorldId(isolate, world_id); gin_helper::Dictionary global(target_context->GetIsolate(), target_context->Global());