Skip to content

Commit

Permalink
fix smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Apr 24, 2019
1 parent ecf6754 commit 9f20402
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/api/session.md
Expand Up @@ -118,7 +118,7 @@ Returns `Promise<void>` - resolves when the storage data has been cleared.

#### `ses.flushStorageData()`

Writes any unwritten DOMStorage data to disk.s
Writes any unwritten DOMStorage data to disk.

#### `ses.setProxy(config)`

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -22,7 +22,7 @@
"colors": "^1.1.2",
"dotenv-safe": "^4.0.4",
"dugite": "^1.45.0",
"electron-docs-linter": "^3.0.1",
"electron-docs-linter": "^3.0.3",
"electron-typescript-definitions": "^8.2.2",
"eslint": "^5.13.0",
"eslint-config-standard": "^12.0.0",
Expand Down
18 changes: 9 additions & 9 deletions spec/ts-smoke/electron/main.ts
Expand Up @@ -92,14 +92,14 @@ app.on('ready', () => {
printBackground: true,
printSelectionOnly: true,
landscape: true
}, (error: Error, data: Buffer) => console.log(error))
}).then((data: Buffer) => console.log(data))

mainWindow.webContents.printToPDF({}, (err, data) => console.log(err))
mainWindow.webContents.printToPDF({}).then(data => console.log(data))

mainWindow.webContents.executeJavaScript('return true;').then((v: boolean) => console.log(v))
mainWindow.webContents.executeJavaScript('return true;', true).then((v: boolean) => console.log(v))
mainWindow.webContents.executeJavaScript('return true;', true)
mainWindow.webContents.executeJavaScript('return true;', true, (result: boolean) => console.log(result))
mainWindow.webContents.executeJavaScript('return true;', true).then((result: boolean) => console.log(result))
mainWindow.webContents.insertText('blah, blah, blah')
mainWindow.webContents.startDrag({ file: '/path/to/img.png', icon: nativeImage.createFromPath('/path/to/icon.png') })
mainWindow.webContents.findInPage('blah')
Expand Down Expand Up @@ -138,10 +138,10 @@ app.on('ready', () => {
})

mainWindow.webContents.debugger.sendCommand('Network.enable')
mainWindow.webContents.capturePage((image) => {
mainWindow.webContents.capturePage().then(image => {
console.log(image.toDataURL())
})
mainWindow.webContents.capturePage({ x: 0, y: 0, width: 100, height: 200 }, (image) => {
mainWindow.webContents.capturePage({ x: 0, y: 0, width: 100, height: 200 }).then(image => {
console.log(image.toPNG())
})
})
Expand Down Expand Up @@ -467,11 +467,11 @@ const options = {
traceOptions: 'record-until-full,enable-sampling'
}

contentTracing.startRecording(options, function () {
contentTracing.startRecording(options).then(() => {
console.log('Tracing started')
setTimeout(function () {
contentTracing.stopRecording('', function (path) {
console.log('Tracing data recorded to ' + path)
contentTracing.stopRecording('').then(path => {
console.log(`Tracing data recorded to ${path}`)
})
}, 5000)
})
Expand Down Expand Up @@ -850,7 +850,7 @@ app.on('ready', () => {
console.log(error ? error.message : 'ok')
})

protocol.isProtocolHandled('atom', (handled) => {
protocol.isProtocolHandled('atom').then(handled => {
console.log(handled)
})
})
Expand Down
12 changes: 5 additions & 7 deletions spec/ts-smoke/electron/renderer.ts
Expand Up @@ -5,7 +5,6 @@ import {
webFrame,
clipboard,
crashReporter,
nativeImage,
screen,
shell
} from 'electron'
Expand Down Expand Up @@ -34,15 +33,15 @@ remote.getCurrentWindow().on('close', () => {
// blabla...
})

remote.getCurrentWindow().capturePage(buf => {
remote.getCurrentWindow().capturePage().then(buf => {
fs.writeFile('/tmp/screenshot.png', buf, err => {
console.log(err)
})
})

remote.getCurrentWebContents().print()

remote.getCurrentWindow().capturePage(buf => {
remote.getCurrentWindow().capturePage().then(buf => {
remote.require('fs').writeFile('/tmp/screenshot.png', buf, (err: Error) => {
console.log(err)
})
Expand Down Expand Up @@ -75,7 +74,7 @@ webFrame.insertText('text')
webFrame.executeJavaScript('return true;').then((v: boolean) => console.log(v))
webFrame.executeJavaScript('return true;', true).then((v: boolean) => console.log(v))
webFrame.executeJavaScript('return true;', true)
webFrame.executeJavaScript('return true;', true, (result: boolean) => console.log(result))
webFrame.executeJavaScript('return true;', true).then((result: boolean) => console.log(result))

console.log(webFrame.getResourceUsage())
webFrame.clearCache()
Expand Down Expand Up @@ -111,8 +110,7 @@ crashReporter.start({

const desktopCapturer = require('electron').desktopCapturer

desktopCapturer.getSources({ types: ['window', 'screen'] }, function (error, sources) {
if (error) throw error
desktopCapturer.getSources({ types: ['window', 'screen'] }).then(sources => {
for (let i = 0; i < sources.length; ++i) {
if (sources[i].name == 'Electron') {
(navigator as any).webkitGetUserMedia({
Expand Down Expand Up @@ -253,7 +251,7 @@ webview.addEventListener('ipc-message', function (event) {
console.log(event.channel) // Prints "pong"
})
webview.send('ping')
webview.capturePage((image) => { console.log(image) })
webview.capturePage().then(image => { console.log(image) })

{
const opened: boolean = webview.isDevToolsOpened()
Expand Down

0 comments on commit 9f20402

Please sign in to comment.