feat: add <webview>.getWebContentsId() (#17407)

This commit is contained in:
Milan Burda 2019-03-26 02:57:27 +01:00 committed by Cheng Zhao
parent 9e26dfaa06
commit 546466b209
6 changed files with 32 additions and 24 deletions

View file

@ -1124,7 +1124,7 @@ describe('<webview> tag', function () {
assert.ok(webview.partition)
const listener = function (webContents, permission, callback) {
if (webContents.id === webview.getWebContents().id) {
if (webContents.id === webview.getWebContentsId()) {
// requestMIDIAccess with sysex requests both midi and midiSysex so
// grant the first midi one and then reject the midiSysex one
if (requestedPermission === 'midiSysex' && permission === 'midi') {
@ -1210,7 +1210,7 @@ describe('<webview> tag', function () {
webview.partition = 'permissionTest'
webview.setAttribute('nodeintegration', 'on')
session.fromPartition(webview.partition).setPermissionRequestHandler((webContents, permission, callback) => {
if (webContents.id === webview.getWebContents().id) {
if (webContents.id === webview.getWebContentsId()) {
assert.strictEqual(permission, 'notifications')
setTimeout(() => { callback(true) }, 10)
}
@ -1219,6 +1219,15 @@ describe('<webview> tag', function () {
})
})
describe('<webview>.getWebContentsId', () => {
it('can return the WebContents ID', async () => {
const src = 'about:blank'
await loadWebView(webview, { src })
expect(webview.getWebContentsId()).to.be.equal(webview.getWebContents().id)
})
})
describe('<webview>.getWebContents', () => {
it('can return the webcontents associated', async () => {
const src = 'about:blank'