Commit graph

370 commits

Author SHA1 Message Date
Robo
edd5c4b9bb fix: use OS process handle to clear object registry (#14324)
RenderProcessHost switch can happen between ipc calls when
speculative process are invvolved, which will lead to deletion
of entries on current context. Use OS process handles to
uniquely associate a destruction handler for a render process.
2018-08-28 13:32:46 -05:00
Milan Burda
e6e3ccfc50 refactor: use std::string instead of base::string16 for IPC channel names (#14286) 2018-08-24 10:30:37 -05:00
Robo
bce5bd87a8 fix: opt into location services once device service has been started (#14253)
* fix: opt into location services once device service has been started

* refactor: provide fake location provider to mock geolocation reponses

* chore: add spec for navigator.geolocation api using fake location provider
2018-08-23 08:51:46 -07:00
Milan Burda
fc85d02786 feat: expose missing process APIs in sandboxed renderers (#13505) 2018-08-21 11:05:45 -07:00
John Kleinschmidt
828e317360 Fix flaky sandbox tests
Windows apparently has issues running opening two windows at once which is causing flakiness on the mixed sandbox tests.
2018-08-13 09:30:20 -07:00
Milan Burda
9a1ad2b93f fix: ipcRemote.sendSync regression after moving away from JSON for return values (#13941) 2018-08-09 19:45:10 +10:00
Milan Burda
db38c8b620 Fix process.execPath returning parent process path instead of the helper in sandboxed renderer (#13839) 2018-07-30 11:13:42 +10:00
PalmerAL
ffc15e02a6 fix: add native function to create preload script (#13032)
* add native function to create preload script

* add tests

* fix formatting

* fix tests

* rerun CI
2018-07-13 11:17:11 +09: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
Jeremy Apthorp
bdceea6aca fix: enable spell checking, which broke in upgrade to ch66
Chromium commit [03563dd163][1] changed the way that the
spellcheck-enabled status was checked, defaulting to false.

Added the first (!) test for spellchecking, too.

Fixes #13608.

[1]: 03563dd163
2018-07-11 10:27:56 -07:00
Jeremy Apthorp
f50f8e3f3d chore: [gn] fix CSP warning in debugger API test (#13541)
There's an attempt to suppress the warning in `spec/static/main.js`, which
sets `process.env.ELECTRON_DISABLE_SECURITY_WARNINGS`. However, it sets the
variable too late in the boot process: by the time that line in main.js has
run, a child zygote has already been booted. `test.py` works around this by
setting that environment variable outside of the test process, to ensure that
it gets propagated to all children.

I've been running the GN tests directly with `./out/Default/electron
electron/spec`, rather than through the wrapper script, and the
`api-debugger-spec.js` tests were failing, because they depend on a particular
log message being the first one emitted, and the CSP warning was causing that
test to fail, since it wasn't being correctly suppressed.

Instead of writing another wrapper script, this just fixes the underlying thing
that the warning is complaining about, which I think is reasonable because the
test's pass/fail depends on this specific behaviour.
2018-07-06 15:01:33 -04:00
Cheng Zhao
e42c6d3eb7
fix the crash when loading site with jquery (#13475) 2018-06-29 09:42:04 +09:00
Cheng Zhao
44aad039c6 fix: do not expose Node's external strings (#13438) 2018-06-27 10:18:09 +10:00
Aleksei Kuzmin
417fe29dc0 Fix the media events test
Playing a media now requires a user gesture.
See https://goo.gl/xX8pDD.
2018-06-19 11:49:45 +10:00
Zhuo Lu
ab24a1e36d feat: netLog API for dynamic logging control (#13068)
* Introduce `net.{start|stop}Logging()`

- Slight regression right now as Electron won't automatically start logging net-logs at launch, will soon be fixed
- To implement callback for async controls

* Add `net.isLogging` & optional callback param for `net.stopLogging()`

* Fix small regression on --log-net-log

--log-net-log should work again

* Error on empty file path

* Only start with valid file path

* Remove unused var

* Allow setting log file path before URLRequestContextGetter starts logging

* Add net log tests

* Remove redundant checks

* Use brightray::NetLog

* Clean up code

* Should automatically stop listening

* 🎨 Attempt to fix styles

* Only run non-null callback

* Dump file to tmpdir

* Simplify net log spec

Spawned Electron process on Linux CI can fail to launch

* Separate netLog module

* Remove net logging test from net spec

* Add tests for netLog

* Fix header guard

* Clean up code

* Add netLog.currentlyLoggingPath

* Callback with filepath

* Add test for case when only .stopLogging() is called

* Add docs

* Reintroduce error on invalid arg

* Update copyright

* Update error message

* Juggle file path string types
2018-06-19 11:45:58 +10: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
Alexey Kuzmin
0d5e98a201 Slightly rewrite <webview> tag tests (#13122) 2018-06-01 10:56:48 +02:00
Milan Burda
4cfe5ecaa4 add proper support for typed arrays in remote (#13055) 2018-05-24 21:05:46 +09:00
Alexey Kuzmin
fc34076c2b Refactor <webview> tag tests (#12886) 2018-05-14 17:00:49 -05:00
Samuel Attard
5b5c161601
feat: new makeSingleInstance API (#12782)
* Refactor app.makeSingleInstance
* new API `app.isPrimaryInstance()`
* new API `app.isSingleInstance()`
* new event `app.on('second-instance')`
* deprecated old syntax `app.makeSingleInstance(cb)`
* deprecated old syntax of `app.makeSingleInstance() --> bool` in favor
of `app.isPrimaryInstance()`
* Fix spec, we don't need process.nextTick hacks any more
* Make deprecation TODO for the return value of makeSingleInstance
* Refactor makeSingleInstance to requestSingleInstanceLock and add appropriate deprecation comments
* I swear this isn't tricking the linter
* Make const
* Add deprecation warnings for release, and add to planned-breaking-changes

BREAKING CHANGE
2018-05-08 01:29:18 +10: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
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
Hari Juturu
704af29543 Exposing process.env status (#12166) 2018-03-14 12:01:40 +09:00
Cheng Zhao
cde0c1d418 Print detailed error for serviceWorker test (#12186) 2018-03-08 21:06:29 -05:00
Hari Juturu
2f4fd3324b Preload doesn't load in sandboxed render if preload path contains special chars (#12037)
* Adding missing headers

* adding ut

* Removing the file path exists check

* fixing test

* exposing window.require in UT
2018-03-07 11:40:00 -05:00
Charles Kerr
65ee977a86 Exit gracefully on linux (#12139)
* Fix timing issue in singleton fixture.

Singleton now sends the "we've started" message out only after it's
received a `'ready'` event from `app`. Previously it sent the message
out immediately, resulting in the parent test trying to manipulate it
before Singleton's event loop was fully bootstrapped.

* Check for graceful exits on Linux, too.

Rewrite the "exits gracefully on macos" spec to run on Linux too.

* Check for graceful exits everywhere.

* Tweak comment

* Better error logging in api-app-spec.js. (#12122)

In the 'exits gracefully' test for app.exit(exitCode),
print the relevant error information if the test fails.

* Run the exit-gracefully test on macOS and Linux.

Windows does not support sending signals, but Node.js offers some
emulation with process.kill(), and subprocess.kill(). Sending signal 0
can be used to test for the existence of a process. Sending SIGINT,
SIGTERM, and SIGKILL cause the unconditional termination of the target
process.

So, we'll need a different approach if we want to test this in win32.
2018-03-06 22:01:17 -05:00
Samuel Attard
b3234f634b Add ability to set arbitrary arguments in a renderer process (#11850) 2018-02-12 11:54:31 -06:00
shelley vohr
ca34978e73 add app.setLocale() (#11469)
* infrastructure for setLocale via klang

* add documentation for setLocale

* add test for setLocale

* fix spec

* add spec and update docs

* fix carriage feeds on windows

* SetLocale() sets LC_ALL on Linux

* in SetLocale() on Linux, use g_setenv()

* fix tyop: '#ifdef OSX_POSIX'

* make the linter happy

* improvements from review
2018-02-08 08:26:37 -06: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
276f758560
remove deprecated method call 2017-12-07 14:26:57 -05:00
Cheng Zhao
cb3a9c69ab Add a SessionPreferences to manage session related data
By design the BrowserClient should not be aware of the api:: classes.
2017-12-05 15:59:15 +09:00
Samuel Attard
0ddd078aaf Add ability to set global preload scripts 2017-12-05 11:35:27 +09:00
Ales Pergl
ecdbe79e29 Make the asar-video test run faster
I cut the video to 3 seconds and removed the audio track, which makes the test
finish a lot sooner. Also the asar file is 160 kB instead of 1 MB.
2017-12-02 11:30:57 +01:00
deepak1556
0b88873e77 add basic inspector module test 2017-11-24 10:58:53 +09:00
Ales Pergl
82394cc06d Use an existing host name so that it resolves quickly and tests don't time out. 2017-11-24 10:58:53 +09:00
Ahmed Mohamed Ali
b6109030a1 Fix missing eof missing from html test files 2017-11-13 21:22:36 +01:00
Ahmed Mohamed Ali
1f2c949316 Merge branch 'master' of https://github.com/ahmedmohamedali/electron 2017-11-13 21:16:52 +01:00
Ahmed Mohamed Ali
ff707a0f3d Fix issues in the file for the tests. 2017-11-13 21:13:19 +01:00
Ahmed
9b3960fe90
Merge branch 'master' into master 2017-11-08 18:03:55 +01:00
Shelley Vohr
0adf775d9a
clean fixture and fix failing travis test 2017-11-01 08:57:22 -04:00
Ahmed Mohamed Ali
1e9942c1bf Fix js coding style errors 2017-10-20 08:46:41 +02:00
Ahmed Mohamed Ali
44f91e12e1 Add tests for fix described in #10793 2017-10-19 16:15:02 +02:00
Yuya Ochiai
6326c6727e Add did-attach-webview event 2017-10-07 22:52:20 +09:00
Cheng Zhao
d87ea5713d spec: It is not certain which process starts first 2017-09-25 11:19:25 +09:00
Cheng Zhao
b4075bed87 spec: Add test case for app.makeSingleInstance 2017-09-20 11:58:32 +09:00
sungpark
eca7ff986c add webFrame to sandboxed renderer 2017-08-23 10:52:02 -07:00
sungpark
bf07c5aebd fix contextIsolation issue while webPreference sandbox is on
contextIsolation didn't work while sandbox is on. The fix is contextIsolation picked up while sandbox on
2017-08-23 10:52:02 -07:00
Kevin Sawicki
3925bfde8e Add spec for reloading opened window cross-origin 2017-07-17 11:55:15 -07:00
Kevin Sawicki
86b1deedfa Inherit enabled-sandbox in opened windows 2017-07-17 11:55:15 -07:00
Kevin Sawicki
c71b0a5441 Add spec for configuring web preferences from sandboxed new-window event 2017-07-17 11:55:15 -07:00