Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: change examples in docs to use for..of and async/await (#14842) #15196

Merged
merged 5 commits into from Oct 16, 2018
@@ -12,24 +12,28 @@ title is `Electron`:
// In the renderer process.
const { desktopCapturer } = require('electron')
desktopCapturer.getSources({ types: ['window', 'screen'] }, (error, sources) => {
desktopCapturer.getSources({ types: ['window', 'screen'] }, async (error, sources) => {
if (error) throw error
for (let i = 0; i < sources.length; ++i) {
if (sources[i].name === 'Electron') {
navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: sources[i].id,
minWidth: 1280,
maxWidth: 1280,
minHeight: 720,
maxHeight: 720
for (const source in sources) {

This comment has been minimized.

Copy link
@BinaryMuse

BinaryMuse Oct 16, 2018

Member

Based on the PR title, I assume this should be of :)

Suggested change
for (const source in sources) {
for (const source of sources) {

This comment has been minimized.

Copy link
@AbhilashJN

AbhilashJN Oct 16, 2018

Author Contributor

Whoops!

if (source.name === 'Electron') {
try {
const stream = await navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: source.id,
minWidth: 1280,
maxWidth: 1280,
minHeight: 720,
maxHeight: 720
}
}
}
}).then((stream) => handleStream(stream))
.catch((e) => handleError(e))
})
handleStream(stream)
} catch (e) {
handleError(e)
}
return
}
}
@@ -20,32 +20,33 @@ $ npm install --save-dev spectron

```javascript
// A simple test to verify a visible window is opened with a title
var Application = require('spectron').Application
var assert = require('assert')
const Application = require('spectron').Application
const assert = require('assert')
var app = new Application({
const myApp = new Application({
path: '/Applications/MyApp.app/Contents/MacOS/MyApp'
})
app.start().then(function () {
// Check if the window is visible
return app.browserWindow.isVisible()
}).then(function (isVisible) {
// Verify the window is visible
assert.strictEqual(isVisible, true)
}).then(function () {
// Get the window's title
return app.client.getTitle()
}).then(function (title) {
// Verify the window's title
assert.strictEqual(title, 'My App')
}).catch(function (error) {
// Log any failures
console.error('Test failed', error.message)
}).then(function () {
const verifyWindowIsVisibleWithTitle = async (app) => {
await app.start()
try {
// Check if the window is visible
const isVisible = await app.browserWindow.isVisible()
// Verify the window is visible
assert.strictEqual(isVisible, true)
// Get the window's title
const title = await app.client.getTitle()
// Verify the window's title
assert.strictEqual(title, 'My App')
} catch (error) {
// Log any failures
console.error('Test failed', error.message)
}
// Stop the application
return app.stop()
})
await app.stop()
}
verifyWindowIsVisibleWithTitle(myApp)
```

## Setting up with WebDriverJs
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.