feat: promisify executeJavaScript (#17312)
This commit is contained in:
parent
878538f2e8
commit
2e89348541
14 changed files with 164 additions and 100 deletions
|
@ -789,11 +789,7 @@ describe('<webview> tag', function () {
|
|||
const devtools = webview2.getWebContents()
|
||||
assert.ok(devtools.getURL().startsWith('chrome-devtools://devtools'))
|
||||
|
||||
const name = await new Promise((resolve) => {
|
||||
devtools.executeJavaScript('InspectorFrontendHost.constructor.name', (name) => {
|
||||
resolve(name)
|
||||
})
|
||||
})
|
||||
const name = await devtools.executeJavaScript('InspectorFrontendHost.constructor.name')
|
||||
document.body.removeChild(webview2)
|
||||
|
||||
expect(name).to.be.equal('InspectorFrontendHostImpl')
|
||||
|
@ -1001,6 +997,19 @@ describe('<webview> tag', function () {
|
|||
const jsScript = "'4'+2"
|
||||
const expectedResult = '42'
|
||||
|
||||
const result = await webview.executeJavaScript(jsScript)
|
||||
assert.strictEqual(result, expectedResult)
|
||||
})
|
||||
|
||||
// TODO(miniak): remove when promisification is complete
|
||||
it('can return the result of the executed script (callback)', async () => {
|
||||
await loadWebView(webview, {
|
||||
src: 'about:blank'
|
||||
})
|
||||
|
||||
const jsScript = "'4'+2"
|
||||
const expectedResult = '42'
|
||||
|
||||
const result = await new Promise((resolve) => {
|
||||
webview.executeJavaScript(jsScript, false, (result) => {
|
||||
resolve(result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue