From 099a2b6dedd850c281c97c30a02cfe63f08cbfa7 Mon Sep 17 00:00:00 2001 From: rhysd Date: Wed, 23 Nov 2016 23:34:40 +0900 Subject: [PATCH] electron: Support Electron 1.4.6 --- electron/github-electron-main-tests.ts | 2 +- electron/github-electron-renderer-tests.ts | 2 +- electron/index.d.ts | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/electron/github-electron-main-tests.ts b/electron/github-electron-main-tests.ts index e5e0795025..40cb34501c 100644 --- a/electron/github-electron-main-tests.ts +++ b/electron/github-electron-main-tests.ts @@ -93,7 +93,7 @@ app.on('ready', () => { mainWindow.webContents.printToPDF({}, (err, data) => {}); - mainWindow.webContents.executeJavaScript('return true;'); + mainWindow.webContents.executeJavaScript('return 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.insertText('blah, blah, blah'); diff --git a/electron/github-electron-renderer-tests.ts b/electron/github-electron-renderer-tests.ts index 9de01360ea..a7e3be9836 100644 --- a/electron/github-electron-renderer-tests.ts +++ b/electron/github-electron-renderer-tests.ts @@ -77,7 +77,7 @@ webFrame.insertText('text'); webFrame.executeJavaScript('JSON.stringify({})', false, (result) => { console.log(result); -}); +}).then((result: string) => console.log('OK:' + result)); console.log(webFrame.getResourceUsage()); webFrame.clearCache(); diff --git a/electron/index.d.ts b/electron/index.d.ts index d6c9848137..0cfcd50636 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron v1.4.5 +// Type definitions for Electron v1.4.6 // Project: http://electron.atom.io/ // Definitions by: jedmao , rhysd , Milan Burda , aliib // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -4415,8 +4415,10 @@ declare namespace Electron { /** * Evaluates code in page. * @param code Code to evaluate. + * + * @returns Promise */ - executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise; /** * Mute the audio on the current web page. */ @@ -5176,8 +5178,10 @@ declare namespace Electron { * In the browser window some HTML APIs like `requestFullScreen` can only be * invoked by a gesture from the user. Setting `userGesture` to `true` will remove * this limitation. + * + * @returns Promise */ - executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise; /** * @returns Object describing usage information of Blink’s internal memory caches. */ @@ -5399,8 +5403,10 @@ declare namespace Electron { /** * Evaluates code in page. If userGesture is set, it will create the user gesture context in the page. * HTML APIs like requestFullScreen, which require user action, can take advantage of this option for automation. + * + * @returns Promise */ - executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise; /** * Opens a DevTools window for guest page. */