Commit graph

456 commits

Author SHA1 Message Date
Milan Burda
7a3d220347 refactor: implement Chrome Extension APIs without the remote module (#16686)
* refactor: implement Chrome Extension APIs without the remote module

* remove unused potentiallyRemoteRequire
2019-02-10 10:38:14 -08:00
Cheng Zhao
d16b581140 fix: remove memory leak when using webFrame and spell checker (#16770)
* fix: do not create native api::WebFrame in webFrame

When reloading a page without restarting renderer process (for example
sandbox mode), the blink::WebFrame is not destroyed, but api::WebFrame
is always recreated for the new page context. This leaves a leak of
api::WebFrame.

* fix: remove spell checker when page context is released
2019-02-08 13:38:31 -08:00
Milan Burda
1632c4b837 refactor: implement chrome.i18n.getMessage() without the remote module (#16739)
* refactor: implement chrome.i18n.getMessage() without the remote module

* replace navigator.language with app.getLocale()
2019-02-08 12:07:09 -08:00
Milan Burda
4211a9c69f refactor: use ipcRendererUtils.invokeSync / ipcMainUtils.handleSync (#16759) 2019-02-06 09:53:28 -08:00
Milan Burda
6d674eebb1 refactor: crashReporterInit (#16729) 2019-02-05 12:56:44 -08:00
Milan Burda
7dc565fc2e refactor: implement inspector APIs without the remote module (#16607) 2019-02-01 19:56:46 +01:00
Shelley Vohr
5a35c3a279
chore: fix promisify helper (#16544)
* chore: fix promise deprecation helper

* fix deprecations

* update deprecation tests
2019-01-25 14:23:24 -08:00
Milan Burda
713df08e3e chore: remove deprecated modules internally using remote.require in sandboxed renderer context (#15957) 2019-01-24 10:53:52 -08:00
Milan Burda
fef262f829 fix: check process.isMainFrame in sandboxed_renderer/init.js (#16500) 2019-01-24 10:53:16 -08:00
Milan Burda
cc90919384 refactor: pass internal flag via IPC message struct for consistency (#16490) 2019-01-23 08:24:57 -08:00
Samuel Attard
58a6fe13d6
feat: preloads and nodeIntegration in iframes (#16425)
* feat: add support for node / preloads in subframes

This feature has delibrately been built / implemented in such a way
that it has minimum impact on existing apps / code-paths.
Without enabling the new "nodeSupportInSubFrames" option basically none of this
new code will be hit.

The things that I believe need extra scrutiny are:

* Introduction of `event.reply` for IPC events and usage of `event.reply` instead of `event.sender.send()`
* Usage of `node::FreeEnvironment(env)` when the new option is enabled in order to avoid memory leaks.  I have tested this quite a bit and haven't managed to cause a crash but it is still feature flagged behind the "nodeSupportInSubFrames" flag to avoid potential impact.

Closes #10569
Closes #10401
Closes #11868
Closes #12505
Closes #14035

* feat: add support preloads in subframes for sandboxed renderers

* spec: add tests for new nodeSupportInSubFrames option

* spec: fix specs for .reply and ._replyInternal for internal messages

* chore: revert change to use flag instead of environment set size

* chore: clean up subframe impl

* chore: apply suggestions from code review

Co-Authored-By: MarshallOfSound <samuel.r.attard@gmail.com>

* chore: clean up reply usage

* chore: fix TS docs generation

* chore: cleanup after rebase

* chore: rename wrap to add in event fns
2019-01-22 11:24:46 -08:00
Samuel Attard
ff9b23ebe5
fix: dont run window-setup on chrome:// protocol, introduced in b965e54efc (#16489) 2019-01-22 10:32:18 -08:00
Milan Burda
6cba2c50a2 feat: make ipc-message and ipc-message-sync events public (#16468) 2019-01-22 08:47:58 -08:00
Milan Burda
b965e54efc fix: <webview> not working with contextIsolation + sandbox (#16469) 2019-01-22 10:08:16 +09:00
Shelley Vohr
441c9ce376
feat: promisify desktopCapturer.getSources (#16427)
* feat: promisify desktopCapturer.getSources

* fix doc

* fix docs lint error
2019-01-18 15:29:32 -08:00
Milan Burda
7d4a1223fd feat: add preload-error event to webContents (#16411) 2019-01-18 12:03:43 +01:00
Shelley Vohr
720197f9c8
fix: correctly handle IPC for promise-based methods (#16433) 2019-01-17 12:08:54 -08:00
Robo
52fe92d02e feat: Upgrade to Chromium 71.0.3578.98 (#15966) 2019-01-11 17:00:43 -08:00
Milan Burda
fade3eb679 chore: make "nodeIntegration" and "webviewTag" default to false (#16235) 2019-01-07 22:19:27 +03:00
Milan Burda
3f1d22759a refactor: use helpers for command-line parsing in renderer/init.js (#16239) 2019-01-03 11:22:34 -05:00
Milan Burda
547097b036 security: allow to block desktopCapturer.getSources() calls (#15964)
* security: allow to block desktopCapturer.getSources() calls

* return empty instead of error

* fix: release resources of DesktopCapturer on exit
2018-12-20 11:44:30 +09:00
Milan Burda
7a6fe00f49 chore: simplify code for modules internally using remote.require in sandbox (#16104) 2018-12-17 22:47:41 +03:00
Cheng Zhao
8584c2f14b
fix: register webview in main world when using contextIsolation (#16067) 2018-12-14 15:38:35 +09:00
Cheng Zhao
897c6e93cb chore: simplify main world setup of contextIsolation (#16046) 2018-12-13 16:25:12 -05:00
Milan Burda
c65a0d90b8 chore: misc cleanup (#16037) 2018-12-12 15:31:16 -06:00
Milan Burda
177091ca6f chore: rename nativeRequire to potentiallyRemoteRequire (#15971) 2018-12-06 18:12:50 -08:00
Milan Burda
ab2a061b59 refactor: use helpers when using the remote module in sandboxed renderers (#15960) 2018-12-05 10:07:32 -08:00
Milan Burda
d561c5531b feat: deprecate modules internally using remote.require in sandboxed renderer context (#15145) 2018-12-05 10:34:09 +01:00
Milan Burda
aa2b2f7c8f fix: security: don't allow arbitrary methods to be invoked on webContents via IPC (#15919) 2018-12-04 16:12:21 +01:00
Cheng Zhao
ca7dec2082 fix: default prop of location should be empty str 2018-12-04 17:11:26 +09:00
Cheng Zhao
fc4e10b6c0 fix: set setter of window.location 2018-12-04 16:23:52 +09:00
Anrock
e80e3a53e9 feat: introduce LocationProxy for BrowserWindowProxy 2018-12-04 16:23:52 +09:00
Julien Isorce
1f55f1635f feat: add support for DesktopCapturerSource.appIcon
Useful to get the icon of the application owning the source.
Only available for sources of type window, i.e. not for screen.

https://github.com/electron/electron/issues/14845
2018-12-04 15:42:49 +09:00
Milan Burda
8483cb4aa7 security: only handle related IPCs when <webview> tag is enabled (#15859)
* refactor: move guest-view-manager related IPC handling out of rpc-server

* feat: only handle related IPCs when <webview> tag is enabled
2018-11-30 18:44:38 +09:00
Samuel Attard
fe8965efa2 fix: use sendToAll method correctly in chrome-api (#15518) 2018-11-01 07:16:49 -07:00
Cheng Zhao
a8f2646ba6 Fix missing remote object error when calling remote function created in preload script (#15444)
* fix: report wrong context error based on contextId

* fix: destroyed remote renderer warning is now async
2018-10-31 11:26:57 -04:00
Shelley Vohr
d21d83cfc8
fix: folder open not working in devtools (#15387) 2018-10-25 08:36:48 -07:00
Adam Meyer
d43ef97a7b add width to webview iframe (#15195) 2018-10-17 09:33:31 +09:00
Milan Burda
70c49b78ae fix: Memory > Profiles > Load in DevTools (#15151) 2018-10-14 17:30:49 +11:00
Milan Burda
d3efc52745 feat: add webPreferences.enableRemoteModule option (#13028) 2018-10-13 20:50:07 +03:00
Milan Burda
9177dbb584 refactor: use boolean for nodeIntegration / webviewTag (#15005) 2018-10-08 15:51:31 +02:00
Milan Burda
b50f86ef43 refactor: use separate ipc-renderer-internal / ipc-main-internal APIs for Electron internals (#13940) 2018-10-07 00:48:00 +13:00
Milan Burda
5efb0fdff1 feat: add security warnings to sandboxed renderers (#14869)
Also refactor not to use the remote module.
2018-10-03 21:36:12 +02:00
Milan Burda
3ad3ade828 refactor: add prefer-const to .eslintrc + fix errors (#14880) 2018-10-02 11:56:31 +10:00
Milan Burda
d48f9bcf7f refactor: implement <webview> methods via dedicated IPCs without the remote module (#14377) 2018-10-01 10:07:50 +09:00
Milan Burda
c61db523c7 refactor: replace var with const / let (#14866) 2018-09-29 09:17:00 +10:00
Milan Burda
b499d57cfd refactor: use error-utils for remote exception serialization / deserialization (#14788)
* refactor: use error-utils for remote exception serialization / deserialization

* fix internal process.type in sandboxed renderer
2018-09-26 15:44:55 +10:00
Samuel Attard
176a76217c
chore: have 'use strict' consistently across our lib files (#14721) 2018-09-23 00:28:50 +12:00
Samuel Attard
32a9df2940
refactor: clean up the default app implementation (#14719)
* Disable nodeIntegration
* Enable contextIsolation
* Re-implement the CSP security check to handle running in
contextIsolation
* Disable bad DCHECKS for the promise helper
* Remove the unused "-d" flag for the electron binary
* Added a way to hide the default help output for electron devs who
don't want to see it every time
2018-09-21 15:24:42 +10:00
Samuel Attard
54ef906832
[RFC] perf: use an internal module resolver to improve require performance (#14633)
* perf: use an internal module resolver instead of relative requires

* perf: memoize the results of getting exported Electron properties

* perf: make internal module changes consistent across sandboxed / bundled files
2018-09-20 13:43:26 +10:00
Samuel Attard
558fff69e7
chore: update to standard 12 2018-09-14 14:57:01 +10:00
Milan Burda
0821edc843 refactor: cleanup web-frame-init.js (#14516)
* refactor: add error-utils.js

* fix exception handling for asyncWebFrameMethods

* remove dead code

* handle exceptions

* rename rehydratedError to deserializedError

* Revert "handle exceptions"

This reverts commit 396b179948b137f9e525e9ebba4f7c6e9bf19429.
2018-09-11 19:56:00 +10:00
Milan Burda
38419e3a6a chore: address TODO for WebContents.prototype.setSize / reportRemovedAttribute removal (#14517)
* chore: remove WebContents.prototype.setSize

* chore: remove reportRemovedAttribute

* chore: remove unused fixtures
2018-09-11 17:58:57 +10:00
Cheng Zhao
92e094c5f6 fix: manually manage WebContents of webview when it is detached 2018-09-07 15:47:58 +09:00
Charles Kerr
c5820bfabb
fix: don't use deprecated fstatNoException API (#14463) 2018-09-06 13:06:32 -05:00
Cheng Zhao
10176c71ff
fix: webview.focus() should move page focus to webview (#14427) 2018-09-03 11:41:54 +09:00
Cheng Zhao
0ecea96048 fix: use flexbox to style webview (#14400)
* fix: use flexbox to style webview

* docs: remove notes on browserplugin based webview
2018-09-01 08:53:13 +12:00
Milan Burda
3a79eacb6f refactor: don't expose CallbacksRegistry as an internal module (#14389) 2018-08-31 11:29:00 -07:00
Samuel Attard
1b7418fb7b
Revert "sec: deprecate some webPreference defaults to be secure-by-default (#14284)" (#14380)
This reverts commit 66d6ba8689.
2018-08-30 09:57:49 +12:00
Samuel Attard
66d6ba8689 sec: deprecate some webPreference defaults to be secure-by-default (#14284)
* feat: deprecate default value of nodeIntegration

* Use DeprecationStatus::Stable as the default instead of shadowing

* change wording of deprecations

* chore: also deprecate kWebviewTag and kContextIsolation

* chore: do as we preach, lets be secure-by-default in the default app
2018-08-29 13:14:04 -05:00
John Kleinschmidt
865435c491
Merge pull request #14287 from electron/miniak/ipc-refactoring
refactor: move common logic to handleRemoteCommand (rpc-server.js)
2018-08-28 17:06:38 -04:00
Cheng Zhao
459a2304b4 fix: emit focus/blur events for webview (#14344)
* fix: emit focus/blur events for webview

* test: webview can emit focus event
2018-08-28 13:35:44 -05:00
Milan Burda
28e4fcea3b refactor: move common logic to handleRemoteCommand 2018-08-27 21:06:03 +02:00
Milan Burda
c23e7fa101 refactor: implement ipcRenderer.sendTo in native code for better performance (#14285) 2018-08-24 14:14:39 -07:00
Cheng Zhao
6736d4ef29
fix: do not bubble up resize event from webview (#14271) 2018-08-23 15:42:35 +09:00
Cheng Zhao
cd8bb1d3b4
chore: print error when removed webview attribute is used (#14230)
* chore: print error when removed webview attribute is used

* docs: document removed webview features
2018-08-23 10:45:43 +09:00
Cheng Zhao
dd5b8769be fix: use OOPIF for webview tag (#13869)
* fix: use OOIF for webview tag

* fix: do not call GetNativeView for webview

* fix: OOIPF webview's WebContents is managed by embedder frame

* fix: guest view can not be focused

* fix: clear zoom controller when guest is destroyed

* fix: implement the webview resize event

The webview is no longer a browser plugin with the resize event, use
ResizeObserver instead.

* test: disable failed tests due to OOPIF webview

* fix: embedder can be destroyed earlier than guest

This happens when embedder is manually destroyed.

* fix: don't double attach

* fix: recreate iframe when webview is reattached

* fix: resize event may happen very early

* test: some tests are working after OOPIF webview

* chore: remove unused browser plugin webview code

* fix: get embedder via closure

When the "destroyed" event is emitted, the entry in guestInstances would be
cleared.

* chore: rename browserPluginNode to internalElement

* test: make the visibilityState test more robust

* chore: guestinstance can not work with OOPIF webview

* fix: element could be detached before got response from browser
2018-08-16 15:57:40 -07:00
Charles Kerr
29f07889e6
feat: add location url to "Node.js Integration with Remote Content" warning (#13973)
* docs: fix typo

* feat: add location url to Node+Remote warning
2018-08-07 20:40:21 -05:00
Cheng Zhao
305e3aad40
refactor: remove private webContents.getId() API (#13674) 2018-07-23 18:08:36 +09:00
Cheng Zhao
9d6f1a372e
fix: create WebContents for webview on request (#13713) 2018-07-21 11:11:28 +09:00
Cheng Zhao
e2029435c4 fix: use context counter as contextId
For sandboxed renderer it may not have a node::Environment in the context,
using a increasing counter as contextId works for all cases.
2018-07-19 11:00:10 -07:00
Shelley Vohr
6045d1218a
refactor: remove experimentalCanvasFeatures property (#13684) 2018-07-16 13:32:42 -07:00
Felix Rieseberg
deedf6c3f4 feat: Add isCurrentlyAudible() to WebContents (#13614)
* 🔧 Add isCurrentlyAudible() to WebContents

* ❤️ Implement feedback, use await to wait for event

* 👷 Add missing imports
2018-07-12 21:35:11 +10:00
Cheng Zhao
4cdb1b8fc3 fix double-freeing remote references
After the page does navigations, garbage collection can still happen in
the old context. This commit changes to store references to remote objects
by _pages_, instead of by _WebContents_.
2018-07-12 10:44:26 +09:00
deepak1556
7b47d69efe Remove did-get-response-details and did-get-redirect-request events
https://chromium-review.googlesource.com/c/chromium/src/+/805008
https://chromium-review.googlesource.com/c/chromium/src/+/786320
2018-06-19 11:49:41 +10:00
Alexey Kuzmin
dee9aef975 Add "enable_desktop_capturer" build flag (#13133)
* Make it possible to disable a module for a renderer

* Put DesktopCapturer API under a build flag

The name is "enable_desktop_capturer".
Enabled by default.
2018-06-13 11:15:34 -05:00
Thiago de Arruda
6ff111a141 perf: don't use JSON to send the result of ipcRenderer.sendSync. (#8953)
* Don't use JSON to send the result of `ipcRenderer.sendSync`.

- Change the return type of AtomViewHostMsg_Message_Sync from `base::string16`
  to `base::ListValue`
- Adjust lib/browser/api/web-contents.js and /lib/renderer/api/ipc-renderer.js
  to wrap/unwrap return values to/from array, instead of
  serializing/deserializing JSON.

This change can greatly improve `ipcRenderer.sendSync` calls where the return
value contains Buffer instances, because those are converted to Array before
being serialized to JSON(which has no efficient way of representing byte
arrays).

A simple benchmark where remote.require('fs') was used to read a 16mb file got
at least 5x faster, not to mention it used a lot less memory.  This difference
tends increases with larger buffers.

* Don't base64 encode Buffers

* Don't allocate V8ValueConverter on the heap

* Replace hidden global.sandbox with NodeBindings::IsInitialized()

* Refactoring: check NodeBindings::IsInitialized() in V8ValueConverter

* Refactor problematic test to make it more reliable

* Add tests for NaN and Infinity
2018-06-13 17:38:31 +10:00
Charles Kerr
b89fe86fa1
Merge pull request #13050 from electron/3.0.0-deprecations
chore: removal of 3.0.0 deprecations
2018-05-30 09:25:36 +02:00
Milan Burda
4cfe5ecaa4 add proper support for typed arrays in remote (#13055) 2018-05-24 21:05:46 +09:00
Shelley Vohr
322a303683
address changes from review 2018-05-23 15:57:58 -07:00
Shelley Vohr
5f5322c64e
rename blinkFeatures to enableBlinkFeatures 2018-05-23 14:01:34 -07:00
Thiago de Arruda
6f076f7433 Refactor sandbox preload initialization. (#12877)
Use a single synchronous IPC call to retrieve data required by early
sandbox scripts. This has two purposes:

- Optimize preload script initialization by:
  - Using one synchronous IPC call to retrieve preload script,
  webContentsId (more on that later), process.{platform,execPath,env}
  - Lazy loading as many modules as possible.
- Fix #12316 for sandbox. @MarshallOfSound addressed the issue in
  #12342, but it was still present in sandbox mode. By loading
  webContentsId very early and skipping remote module at early
  startup, we fix it for sandbox.
2018-05-21 22:56:05 +10:00
biuuu
86d023b02f fix: listeners out of limit warning (#12841)
When the Chrome Extension has too many content scripts (above default
10 counts), there will be a warning: possible EventEmitter memory leak
detected. 11 listeners added.
2018-05-08 14:10:11 +09:00
bughit
55a7f6f0ce add did-frame-navigate event to WebContents (#12723)
* add did-frame-navigate event to WebContents, pass http response code to it and did-navigate

* docs for frame routing id related api changes on WebFrame and WebContents
2018-05-01 13:34:41 +09:00
bughit
4fcd178c36 expose WebFrame#routingId (#12614)
* expose WebFrame#routingId and pass it to WebContents frame specific events along with frameProcessId; add WebContets.did-start-navigation event
* fix compilation error on ia32 Windows
2018-04-26 19:17:55 +09:00
Tatsuya Hiroishi
9c65abd746 handle remote exception (#12694)
* add cause property to exception in callFunction

* update exceptionToMeta function

* add sender argument
* and cause property to return value

* update exception convert in metaToValue function

* add from and cause properties to the exception error

* unit test for remote exception
2018-04-24 08:40:19 -04:00
Nitish Sakhawalkar
2579071b98 Deprecate did-get-response-details and did-get-redirect-request (#12615)
* Deprecate webContents events did-get-response-details and did-get-redirect-request.

* Update guest view files

* Update webview tag docs and update specs

* Update deprecate.event function

* Update comment

* Update more

* Update documentation for other deprecated event
2018-04-23 14:46:12 -05:00
Jeremy Apthorp
97fb15ac49 Enable WebFrame method forwarding in sandboxed renderers (#12538)
* Enable WebFrame method forwarding in sandboxed renderers

Fixes #9073

* Non-change to kick CI
2018-04-12 11:57:40 +10:00
Andrew MacDonald
6bfb122cd1 Add a display_id parameter to the desktopCapturer API. (#12417)
* Add a screen_api_id parameter to the desktopCapturer API.

When using the DirectX capturer on Windows, there was previously no way
to associate desktopCapturer/getUserMedia and electron.screen API
screens. This new parameter provides the association.

* Fix non-Windows build.

* Fix Mac.

* Fix Mac harder.

* JS lint

* clang-format C++ code.

* IWYU

* display_id, Linux comment, better test

* lint

* Fix tests on Linux.

* Add display_id documentation.
2018-04-09 14:43:35 +09:00
Samuel Attard
0ac883c6d4
Remove the race condition between new process creation and context release (#12342)
* Remove the race condition between new process creation and old process releasing remote context

Previously there was a race condition where the getId() method would return the new context ID even
though the release was for the old context.  This changes it to send the "initial" context ID with
the release message to ensure there is no race.

* fetch context ID from remote in sandbox mode
2018-03-20 15:54:47 +11:00
Felix Rieseberg
243ab45111 🔧 Fix security warning (#12309) 2018-03-16 06:21:38 +09:00
Charles Kerr
c2673aa970 Set appropriate defaults for webview options (#12271)
* Persist defaults to webPreferences object to JS land can read the inferred values instead of just user defined values

* Test inherited default propogation

* Refactor to remove coupling from fetching values and defaults

* Test description type

* Fix up tests
2018-03-15 13:56:46 +09:00
Shelley Vohr
9aeb61181a Fix require on network share path (#12282)
* first pass at server/network require fix

* refactor for clarity
2018-03-15 11:45:13 +09:00
Felix Rieseberg
71795ecc62 fix: Incorrect warnings in webviews (#12234)
* 🔧 Get correct webContents

* 🔧 Err, webPreferences
2018-03-13 10:55:32 +09:00
Samuel Attard
795447f61a Implement dialog (alert/confirm) blocking as a user switch after the first dialog
* This is to enable more browser-like behavior so that users who run third-party code
  will not be DOS'ed with alerts and confirms.  This is already handled like this
  in most major browsers so this will greatly help these developers
2018-03-06 11:19:15 +09:00
John Kleinschmidt
2a97e48465
Merge pull request #11968 from electron/refactor-menu-popup
Refactor menu.popup
2018-02-21 14:29:52 -05:00
Charles Kerr
708f39a1a5 update a few menu.popup() calls to use the new API 2018-02-20 14:02:24 -06:00
Shelley Vohr
211b542ae4
remove setZoomLevelLimits 2018-02-20 08:57:48 -05:00
Felix Rieseberg
d586ef2f39 feature: Hot security tips (#11810)
* 🔧 Add security issue detection (and logs)

* 🔧 Check for it on load

* 👷 Add some tests

* 👷 Make the linter happy

* 🔧 Allow them to be enabled by force

* 📝 Make message slightly prettier

* 🔧 Fix a typo in the code comment

* 🔧 Classic mistake

* 🚀 Optimize things a bit more

* 👷 Add tests, fix tests

* 📝 Document things

* 🔧 Make linter happy

* 🔧 One more piece of cleanup
2018-02-03 07:50:12 -07:00
Shelley Vohr
b74304145e
createShadowRoot => attachShadow 2018-01-31 19:29:23 -05:00