Commit graph

1456 commits

Author SHA1 Message Date
Jeremy Apthorp
841e31b7e6 feat: show underlying stack in errors in remote module (#17851) 2019-04-18 17:38:19 -07:00
Samuel Attard
78411db4b5
fix: maintain a ref count for objects sent over remote (#17464)
* spec: clean up after a failed window count assertion

Previously when this assertion failed all tests that ran after the
failed assertion also failed.  This ensure that the assertion fails for
the test that actually caused the issue but cleans up the left-over
windows so that future tests do not fail.

* fix: maintain a ref count for objects sent over remote

Previously there was a race condition where a GC could occur in the
renderer process between the main process sending a meta.id and the
renderer pulling the proxy out its weakmap to stop it being GC'ed.

This fixes that race condition by maintaining a "sent" ref count in the
object registry and a "received" ref count in the object cache on the
renderer side.  The deref request now sends the number of refs the
renderer thinks it owns, if the number does not match the value in the
object registry it is assumed that there is an IPC message containing a
new reference in flight and this race condition was hit.

The browser side ref count is then reduced and we wait for the new deref
message.  This guaruntees that an object will only be removed from the
registry if every reference we sent has been guarunteed to be unreffed.
2019-04-16 16:08:11 -04:00
Samuel Attard
b7b9efa875
fix: handle remote-debugging-port=0 correctly (#17800)
By default the Chromedriver will send remote-debugging-port=0 to let the
browser choose a free port to listen on.  The chosen port is written to
a known file in the user data dir that is passed to the app through the
CLI.

This PR does two things.

1. Correctly passes the USER_DATA_DIR to the remote debugging server so
it knows where to write the file
2. Adds support for --user-data-dir as we did not support that CLI
argument and Chromedriver relies on being able to tell the "browser"
where to write this file.

Fixes #17354
2019-04-16 14:22:51 -04:00
Shelley Vohr
9c3cb55ef2
refactor: make accessibilitySupportEnabled a property on app (#17362)
* refactor: make accessibilitySupport a prop on app

* fix docs

* update spec
2019-04-04 19:49:04 -07:00
Milan Burda
77d59e99b6 feat: emit process 'loaded' event in sandboxed renderers (#17680) 2019-04-04 11:35:06 -07:00
Jeremy Apthorp
127b87c713
refactor: mojofy MessageTo and MessageHost (#17613) 2019-04-03 14:22:23 -07:00
Jeremy Apthorp
53f6cbccbf
refactor: use mojo for electron internal IPC (#17406)
* refactor: use mojo for electron internal IPC

* add sender_id, drop MessageSync

* remove usages of AtomFrameMsg_Message

* iwyu

* first draft of renderer->browser direction

* refactor to reuse a single ipc interface

* implement TakeHeapSnapshot through mojo

* the rest of the owl^WtakeHeapSnapshot mojofication

* remove no-op overrides in AtomRendererClient

* delete renderer-side ElectronApiServiceImpl when its pipe is destroyed

* looks like we don't need to overlay the renderer manifest after all

* don't try to send 2 replies to a sync rpc

* undo changes to manifests.cc

* unify sandboxed + unsandboxed ipc events

* lint

* register ElectronBrowser mojo service on devtools WebContents

* fix takeHeapSnapshopt failure paths

* {electron_api => atom}::mojom

* add send_to_all to ElectronRenderer::Message

* keep interface alive until callback is called

* review comments

* use GetContext from RendererClientBase

* robustify a test that uses window.open

* MessageSync posts a task to put sync messages in the same queue as async ones

* add v8::MicrotasksScope and node::CallbackScope

* iwyu

* use weakptr to api::WebContents instead of Unretained

* make MessageSync an asynchronous message & use non-associated interface

* iwyu + comments

* remove unused WeakPtrFactory

* inline OnRendererMessage[Sync]

* cleanups & comments

* use helper methods instead of inline lambdas

* remove unneeded async in test

* add mojo to manifests deps

* add gn check for //electron/manifests and mojo

* don't register renderer side service until preload has been run

* update gn check targets list

* move interface registration back to RenderFrameCreated
2019-04-02 15:38:16 -07:00
Shelley Vohr
0431997c8d
refactor: make applicationMenu a property on app (#17361) 2019-04-02 13:36:57 -07:00
Shelley Vohr
8ea33d69ac
fix: match net module headers & http.IncomingMessage headers (#17517)
* fix: match net module headers & http.IncomingMessage headers

* update net doc for cleanliness

* address feedback from review

* Update spec/api-net-spec.js

Co-Authored-By: codebytere <codebytere@github.com>

* add special cookie case
2019-04-02 07:41:19 -07:00
Samuel Attard
75442b794f
fix: make devtools extensions load correctly (#17614) 2019-03-30 17:36:13 -07:00
Milan Burda
d597a0e8b0 refactor: expose ipcRendererInternal to the main world for window-setup using the content script world pattern (#17591) 2019-03-29 18:10:21 -07:00
Samuel Attard
953d1ea635
fix: ensure dots in content script patterns aren't used as wildcards (#17593)
* fix: ensure dots in content script patterns aren't used as wildcards

* chore: sanitise all regexp special chars

* chore: extract to helper

* chore: fixup helper
2019-03-28 14:03:37 -07:00
Shelley Vohr
808783a5e4
fix: crashReporter.getParameters() takes no params (#17459) 2019-03-28 15:04:16 -04:00
Milan Burda
8cf15cc931 feat: only allow bundled preload scripts (#17308) 2019-03-28 11:38:51 +01:00
Shelley Vohr
34eb5d0815
fix: correctly return properties on the netLog module (#17525) 2019-03-25 22:40:38 -04:00
Milan Burda
336db33d18 refactor: use ipcMainUtils.invokeInWebContents / ipcRendererUtils.handle helpers for Chrome APIs (#17417) 2019-03-26 11:38:35 +09:00
Milan Burda
546466b209 feat: add <webview>.getWebContentsId() (#17407) 2019-03-26 10:57:27 +09:00
Milan Burda
cbd884060e fix: validate sender for replies in ipcMainInternalUtils.invokeInWebContents() (#17416) 2019-03-26 10:15:51 +09:00
Milan Burda
7389dfca59 fix: report module name when require fails in sandboxed renderers (#17413) 2019-03-19 12:00:41 -07:00
Milan Burda
06a4594435 chore: remove special handling for dialog methods in remote module (#17412)
* chore: remove special handling for dialog methods in remote module

* refactor: remove callFunction helper
2019-03-19 11:59:33 -07:00
Milan Burda
ddd51525f1 refactor: make ELECTRON_INSPECTOR_CONTEXT_MENU handler async (#17411) 2019-03-19 10:37:43 -07:00
Milan Burda
53f4af7722 fix: regressions introduced by adding world isolation to Chrome extension content scripts (#17422) 2019-03-19 14:45:48 +01:00
Shelley Vohr
38d75010c7
chore: rename atomBinding to electronBinding (#17419) 2019-03-18 12:37:06 -07:00
Shelley Vohr
db29978fe0
fix: throw error when inserting menu items out-of-range (#17401)
* fix: throw error when inserting menu items out-of-range

* also check pos < 0
2019-03-18 07:58:42 -07:00
Shelley Vohr
f09f43a4a9
chore: remove unused arg parsing code in dialog (#17420) 2019-03-18 07:58:03 -07:00
Milan Burda
3a091cdea4 refactor: implement clipboard APIs without the remote module (#17200) 2019-03-15 17:32:04 -07:00
Heilig Benedek
43ef561d48 feat: enable NodeIntegrationInSubFrames for webview (#17226)
* feat: enable nodeIntegrationInSubFrames for webview

* test: add tests

* docs: document webview's nodeintegrationinsubframes

* lint: fix indent

* fix: resolve some merge bloopers
2019-03-15 10:39:20 -07:00
Shelley Vohr
961c9a88a8 feat: promisify dialog.showCertificateTrustDialog() (#17181)
* feat: promisify dialog.showCertificateTrustDialog()

* update promisification doc
2019-03-15 09:02:50 +09:00
Milan Burda
f15d0b1ed7 refactor: make ELECTRON_INSPECTOR_CONFIRM handler async (#17378) 2019-03-14 15:29:40 -07:00
Shelley Vohr
cb4ede453f
chore: add deprecation helper for fnToProperty (#17377)
* chore: add deprecation helper for fnToProperty

* add a test
2019-03-14 15:19:19 -07:00
Milan Burda
2e89348541 feat: promisify executeJavaScript (#17312) 2019-03-14 12:08:54 -07:00
Shelley Vohr
aa8b66aae1
feat: promisify session.getBlobData() (#17303) 2019-03-14 08:11:01 -07:00
Shelley Vohr
3e5a98b5f4
feat: promisify In-App Purchase (#17355)
* feat: promisify In-App Purchase

* use mate::Arguments in GetProducts
2019-03-13 13:56:01 -07:00
Milan Burda
faabd0cc8b refactor: add ipcMainUtils.invokeInWebContents / ipcRendererUtils.handle helpers (#17313) 2019-03-13 12:03:17 -07:00
Shelley Vohr
8991c0056e
feat: promisify dialog.showMessageBox() (#17298)
* feat: promisify dialog.showMessageBox()

* address feedback from review
2019-03-12 11:06:59 -07:00
Milan Burda
48a95f9677 fix: remove non-existent gpu-crashed event on <webview> (#17317) 2019-03-11 17:25:46 -07:00
Samuel Maddock
f943db7ad5 feat: Add content script world isolation (#17032)
* Execute content script in isolated world

* Inject script into newly created extension worlds

* Create new content_script_bundle for extension scripts

* Initialize chrome API in content script bundle

* Define Chrome extension isolated world ID range

1 << 20 was chosen as it provides a sufficiently large range of IDs for extensions, but also provides a large enough buffer for any user worlds in [1000, 1 << 20).

Ultimately this range can be changed if any user application raises it as an issue.

* Insert content script CSS into document

This now avoids a script wrapper to inject the style sheet. This closely matches the code used by chromium in `ScriptInjection::InjectCss`.

* Pass extension ID to isolated world via v8 private
2019-03-11 16:27:57 -07:00
Milan Burda
6072da239d feat: add global renderer-process-crashed event (#17315) 2019-03-11 16:17:24 -07:00
Milan Burda
a8698d092b chore: increase security of default_app (#17318) 2019-03-11 16:13:46 -07:00
Shelley Vohr
9ea6c01e02
feat: promisify session.clearAuthCache() (#17259)
* feat: promisify session.clearAuthCache()

* remove unused callback runner helpers
2019-03-08 18:41:42 -08:00
Samuel Maddock
8ee153dae1 feat: add support for content scripts 'all_frames' option (#17258)
* feat: add support for content scripts 'all_frames' option

* merged content script tests

'all_frames' test now runs on all variants of sandbox/contentIsolation configurations :D
2019-03-08 15:53:25 -08:00
Shelley Vohr
fc10620082
feat: promisify session cache methods (#17185) 2019-03-08 14:42:03 -08:00
Shelley Vohr
2769e75b49
feat: promisify session proxy methods (#17222) 2019-03-08 12:51:12 -08:00
Robo
5afb7dc715 refactor: load electron builtin modules with process._linkedBinding (#17247)
* refactor: load electron builtin modules with process._linkedBinding

NODE_BUILTING_MODULE_CONTEXT_AWARE and process.binding are
removed in https://github.com/nodejs/node/pull/25829. This changes
uses the alternative available without any functionality change.

* chore: roll node
2019-03-08 10:29:52 -08:00
Shelley Vohr
e5e6aa207c
feat: promisify ses.clearHostResolverCache() (#17229) 2019-03-08 10:26:17 -08:00
Shelley Vohr
bbfa63fd9d
feat: promisify session.clearStorageData() (#17249) 2019-03-08 09:02:30 -08:00
Milan Burda
d34f81972d refactor: make ELECTRON_BROWSER_SANDBOX_LOAD handler async (#17107) 2019-03-08 11:21:41 +01:00
Samuel Attard
61fc95417b
build: fix new TS linting errors (#17279)
* remove unused _args var
* handle type/variable shadowing
2019-03-07 17:18:10 -08:00
Samuel Maddock
42b7b25ac3 feat: support chrome extensions in sandboxed renderer (#16218)
* Add content script injector to sandboxed renderer

* Fix 'getRenderProcessPreferences' binding to the wrong object

* Pass getRenderProcessPreferences to content-scripts-injector

* Emit document-start and document-end  events in sandboxed renderer

* Use GetContext from RendererClientBase

* Prevent script context crash caused by lazily initialization

* Remove frame filtering logic for onExit callback

Since we're keeping track of which frames we've injected the bundle into, this logic is redundant.

* Add initial content script tests

* Add contextIsolation variants to content script tests

* Add set include

* Fix already loaded extension error

* Add tests for content scripts 'run_at' options

* Catch script injection eval error when CSP forbids it

This can occur in a rendered sandbox when a CSP is enabled. We'll need to switch to using isolated worlds to fix this.

* Fix content script tests not properly cleaning up extensions

* Fix lint and type errors
2019-03-07 16:00:28 -08:00
Milan Burda
5791a2a9ec refactor: use ipcRendererUtils.invoke / ipcMainUtils.handle for desktopCapturer.getSources() (#16619) 2019-03-07 15:31:25 -08:00