Commit graph

104 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Shelley Vohr
0adf775d9a
clean fixture and fix failing travis test 2017-11-01 08:57:22 -04: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
Kevin Sawicki
48f5a66f87 Merge pull request #9983 from electron/devtools-mixed-sandbox
Fix devtools open in mixed sandbox
2017-07-14 09:41:56 -07:00
Kevin Sawicki
60f563ae5f Surface require errors so spec does not hang 2017-07-13 08:36:58 -07:00
Hari Juturu
80bd6a3e91 🎨 2017-07-11 18:36:01 -07:00
Hari Juturu
9a3b78d9fe Fix devtools open in mixed sandbox mode 2017-07-11 18:36:00 -07:00
Kevin Sawicki
2cd49f3036 Merge pull request #9644 from electron/webview-sandbox
Enable sandbox on webview
2017-06-28 10:10:25 -07:00
Kevin Sawicki
5822e718e6 Add finish helper to ensure connection 2017-06-28 09:58:23 -07:00
Kevin Sawicki
523fbe2df9 Send messages between app via socket connection 2017-06-28 09:27:19 -07:00
Kevin Sawicki
7fcc00f137 Add spec for app.enableMixedSandbox() 2017-06-28 08:33:11 -07:00
Kevin Sawicki
0eaddd1565 Verify --enable-sandbox/--no-sandbox command line 2017-06-26 14:12:03 -07:00
Hari Krishna Reddy Juturu
902b34ba39 🎨 2017-06-19 08:03:02 -07:00
Hari Krishna Reddy Juturu
e546820a4a Completing UTs 2017-06-19 07:46:14 -07:00
Hari Krishna Reddy Juturu
0b7e7458c9 WIP: Adding UT 2017-06-16 15:34:11 -07:00
Birunthan Mohanathas
7d2226e05e Let Chromium manage document.visibilityState and document.hidden
Chromium already includes the necessary plumbing to manage the
visibility properties and `visibilitychange` event so this gets rid of
most of our custom logic for `BrowserWindow` and `BrowserView`.

Note that `webview` remains unchanged and is still affected by the issues
listed below.

User facing changes:

- The `document` visibility properties and `visibilitychange` event are
  now also updated/fired in response to occlusion changes on macOS. In
  other words, `document.visibilityState` will now be `hidden` on macOS
  if the window is occluded by another window.

- Previously, `visibilitychange` was also fired by *both* Electron and
  Chromium in some cases (e.g. when hiding the window). Now it is only
  fired by Chromium so you no longer get duplicate events.

- The visiblity state of `BrowserWindow`s created with `{ show: false }`
  is now initially `visible` until the window is shown and hidden.

- The visibility state of `BrowserWindow`s with `backgroundThrottling`
  disabled is now permanently `visible`.

This should also fix #6860 (but not for `webview`).
2017-06-06 15:16:01 -07:00
Kevin Sawicki
9f49b71b89 Add cross-origin frame webview spec 2017-05-26 10:10:36 -07:00
Kevin Sawicki
36989e19f8 Add spec for cross-origin blockage 2017-05-26 10:10:36 -07:00
Kevin Sawicki
f5cf6d4ddd Add spec for native window.open from iframe 2017-05-26 10:10:36 -07:00
Kevin Sawicki
a0571e3c72 Add failing spec for native window.open returning null without allowpopups 2017-05-26 10:10:36 -07:00
Thiago de Arruda
5654ff0d43 Add test for #9387 2017-05-16 09:07:41 -03:00
Ryohei Ikegami
7ac93045b7 Merge branch 'master' into native-window-open 2017-05-11 13:51:43 +09:00
Kevin Sawicki
8c856922f3 Merge pull request #9292 from 22222/issue8911
Fix #8911
2017-05-09 09:06:26 -07:00
22222
042b511a27 Fix #8911 2017-05-03 12:47:00 -05:00
Thiago de Arruda
a8640fb8a3 Add test to verify memory is released after sandboxed popup is closed 2017-05-01 11:30:07 -03:00
Ryohei Ikegami
da97150fc9 Fix JS style in test HTMLs 2017-04-30 19:43:21 +09:00
Ryohei Ikegami
0034b306f5 Add test for nativeWindowOpen + contextIsolation 2017-04-30 19:33:40 +09:00
Ryohei Ikegami
edeac2f59e Split test HTML file into separate ones 2017-04-30 18:54:08 +09:00
Ryohei Ikegami
1d73e84a29 Merge branch 'master' into native-window-open 2017-04-27 12:03:55 +09:00
Kevin Sawicki
de62f1ea6c Restart crash service in each spec 2017-04-19 16:37:24 -07:00
Ryohei Ikegami
8dff29185b Merge branch 'master' into native-window-open 2017-04-18 21:59:22 +09:00
Kevin Sawicki
bfb9388191 Add failing spec for app.exit with >2 windows 2017-04-11 09:09:17 -07:00
Ryohei Ikegami
349ea3a15a Add test for native addon after reload 2017-04-06 11:43:57 +09:00
Thiago de Arruda
ce1a5e3c9c Fix sandboxed crashReporter for windows.
- Use `path` module from browser process in sandboxed renderer. This is required
  because the return value of `path.join` is platform-specific, and this is an
  assumtion of crash-reporter.js which is shared between sandboxed and
  non-sandboxed renderers.
- Set `process.platform` and `process.execPath` in sandboxed renderer
  environment. This is required to spawn the windows crash service from
  sandboxed renderer.
- Use a single temporary directory for all crashReporter tests. This is required
  to make tests more deterministic across platforms(since mac's crashpad doesn't
  support changing the crash dump directory). Also make a few improvements/fixes
  to the `uploadToServer` test.
2017-04-05 18:09:24 -03:00
Ryohei Ikegami
61fa8693d2 Merge branch 'master' into native-window-open 2017-04-04 20:54:37 +09:00
Ryohei Ikegami
051e133ce3 Add test for opeing HTML file 2017-04-04 19:05:13 +09:00