Skip to content

Commit

Permalink
Updates exposeInIslatedWorld worldId documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaydeo committed Sep 21, 2022
1 parent 8092577 commit e54b501
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/api/context-bridge.md
Expand Up @@ -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.

Expand Down
5 changes: 3 additions & 2 deletions shell/renderer/api/electron_api_context_bridge.cc
Expand Up @@ -575,8 +575,9 @@ void ExposeAPIInWorld(v8::Isolate* isolate,
CHECK(frame);

v8::Local<v8::Context> 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());
Expand Down

0 comments on commit e54b501

Please sign in to comment.