|
@@ -163,6 +163,22 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
|
|
|
expect(response).to.equal(3)
|
|
|
})
|
|
|
|
|
|
+ it('connect', async () => {
|
|
|
+ const customSession = session.fromPartition(`persist:${require('uuid').v4()}`)
|
|
|
+ await customSession.loadExtension(path.join(fixtures, 'extensions', 'chrome-api'))
|
|
|
+ const w = new BrowserWindow({ show: false, webPreferences: { session: customSession, nodeIntegration: true } })
|
|
|
+ await w.loadURL(url)
|
|
|
+
|
|
|
+ const portName = require('uuid').v4()
|
|
|
+ const message = { method: 'connectTab', args: [portName] }
|
|
|
+ w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`)
|
|
|
+
|
|
|
+ const [,, responseString] = await emittedOnce(w.webContents, 'console-message')
|
|
|
+ const response = responseString.split(',')
|
|
|
+ expect(response[0]).to.equal(portName)
|
|
|
+ expect(response[1]).to.equal('howdy')
|
|
|
+ })
|
|
|
+
|
|
|
it('sendMessage receives the response', async function () {
|
|
|
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`)
|
|
|
await customSession.loadExtension(path.join(fixtures, 'extensions', 'chrome-api'))
|