Commit graph

1468 commits

Author SHA1 Message Date
Milan Burda
6f5c850d60 refactor: add emitCustomEvent() helper (#17960) 2019-05-01 09:07:57 -04:00
Shelley Vohr
8d83518f9a
refactor: make name a prop on app (#17701)
Update app.name to be a property on app.
2019-04-30 13:55:33 -07:00
Shelley Vohr
d87b3ead76 chore: remove promisification deprecation callbacks (#17907)
* chore: remove promisification deprecation callbacks

* update docs

* fix smoke test

* fix executejs issue

* cleanup leftovers

* fix webContents.executeJavaScript tests

* cleanup WebContents.prototype.takeHeapSnapshot

* fix "sets arbitrary webContents as devtools" test

* fix executeJavaScriptInFrame related tests
2019-04-30 07:08:32 -07:00
Shelley Vohr
7b55ee9d36 refactor: allow requiring modules with no side effects (#17496) 2019-04-30 09:46:08 +09:00
Samuel Attard
77a4946069
refactor: rewire the desktop capturer API to remove race conditions (#18029)
We now create a new instance of atom::api::DesktopCapturer for every
request instead of weirdly re-using the same instance and queuing
requests.  This means there is now a 1:1 relationship between request
and DesktopCapturer so there isn't a race condition between the observer
for one request calling back before the observer of another.  This is an
issue ever since the backing APIs moved to worker threads.

This also does a few things to ensure memory management
* Only ever listen to one event per-request, after that we wipe the emit
function to ignore all future events
* Ensures we clean up the window_capturer_, screen_capturer_ and
captured_sources_ in native land once the request is over.

This _in theory_ fixes a flake we've been seeing on CI where we try to
resolve the promise for a request that no longerr exists.
2019-04-29 13:21:28 -07:00
Milan Burda
9714a91392 refactor: use fs.promises API, which is stable since Node 12 (#17999) 2019-04-29 11:18:03 -07:00
Milan Burda
7574f91f31 refactor: natively promisify WebContents.prototype.takeHeapSnapshot (#18000) 2019-04-29 10:11:11 -07:00
Milan Burda
18b77a4de6 chore: rename atom-binding-setup.ts to electron-binding-setup.ts (#17949) 2019-04-29 10:57:32 -04:00
Cheng Zhao
a4fcc32799
feat: upgrade to Node 12 (#17838)
* fix: add boringssl backport to support node upgrade

* fix: Update node_includes.h, add DCHECK macros

* fix: Update node Debug Options parser usage

* fix: Fix asar setup

* fix: using v8Util in isolated context

* fix: make "process" available in preload scripts

* fix: use proper options parser and remove setting of _breakFirstLine

_breakFirstLine was being set on the process, but that has changed in node 12 and so is no longer needed. Node will handle it properly when --inspect-brk is provided

* chore: update node dep sha

* fix: process.binding => _linkedBinding in sandboxed isolated preload

* fix: make original-fs work with streams

* build: override node module version

* fix: use _linkedBinding in content_script/init.js

* chore: update node ref in DEPS

* build: node_module_version should be 73
2019-04-26 18:55:12 +09:00
Shelley Vohr
075b818a8e
fixes (#17363) 2019-04-25 15:44:54 -07:00
Shelley Vohr
c2c3a04628
fix: crash when failed to get devices in desktopCapturer (#17557)
* fix: crash when failed to get devices in desktopCapturer

* return after emit
2019-04-25 15:12:38 -07:00
Milan Burda
253d049ac9 chore: remove deprecated app.enableMixedSandbox() (#17894) 2019-04-23 21:07:40 -07:00
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