Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose executeJavaScriptInIsolatedWorld on webContents #21190

Merged
merged 2 commits into from Nov 22, 2019

Conversation

MarshallOfSound
Copy link
Member

This exposes executeJavaScriptInIsolatedWorld in a similar way to executeJavaScript so that folks can call it from the main process. Also cleans up the code we use for the main-process side executeJavaScript

Notes: Exposed executeJavaScriptInIsolatedWorld on the webContents API

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Nov 19, 2019
@MarshallOfSound MarshallOfSound added semver/minor backwards-compatible functionality target/8-x-y labels Nov 19, 2019
@deepak1556 deepak1556 requested a review from a team November 19, 2019 01:58
Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me since the API is already in webFrame.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Nov 20, 2019
docs/api/web-contents.md Outdated Show resolved Hide resolved
lib/browser/api/web-contents.js Show resolved Hide resolved
spec-main/api-web-contents-spec.ts Outdated Show resolved Hide resolved
spec-main/api-web-contents-spec.ts Outdated Show resolved Hide resolved
@@ -1031,6 +1031,17 @@ contents.executeJavaScript('fetch("https://jsonplaceholder.typicode.com/users/1"
})
```

#### `contents.executeJavaScriptInIsolatedWorld(worldId, scripts[, userGesture])`

* `worldId` Integer - The ID of the world to run the javascript in, `0` is the default world, `999` is the world used by Electrons `contextIsolation` feature. You can provide any integer here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own learning: do we have any docs that guide when you'd want to use a world with an ID between 1-998?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, it's just not a world we use.

download (1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would probably be a little less confusing for consumers to use constants provided by Electron, I would think?

Co-Authored-By: loc <andy@slack-corp.com>
@jkleinsc
Copy link
Contributor

Approved for backport to 8-x-y by the releases WG.

Copy link
Contributor

@miniak miniak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see a helper wrapping the duplicated ipcMainUtils.invokeInWebContents(this, false, 'ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', method, ...args), which we now have 3 times in the code. Otherwise looks good!

@MarshallOfSound MarshallOfSound merged commit 34452ee into master Nov 22, 2019
@release-clerk
Copy link

release-clerk bot commented Nov 22, 2019

Release Notes Persisted

Exposed executeJavaScriptInIsolatedWorld on the webContents API

@trop
Copy link
Contributor

trop bot commented Nov 22, 2019

I have automatically backported this PR to "8-x-y", please check out #21267

@sofianguy sofianguy added this to Fixed in 8.0.0-beta.4 in 8.2.x Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor backwards-compatible functionality
Projects
No open projects
8.2.x
Fixed in 8.0.0-beta.4
Development

Successfully merging this pull request may close these issues.

None yet

5 participants