Merge pull request #5711 from electron/extension-code-cleanup
Implement partial chrome.* API for devtools extension
This commit is contained in:
commit
9f0fc96025
32 changed files with 1151 additions and 216 deletions
|
@ -3,11 +3,8 @@
|
|||
const assert = require('assert')
|
||||
const path = require('path')
|
||||
|
||||
const ipcRenderer = require('electron').ipcRenderer
|
||||
const remote = require('electron').remote
|
||||
|
||||
const ipcMain = remote.require('electron').ipcMain
|
||||
const BrowserWindow = remote.require('electron').BrowserWindow
|
||||
const {ipcRenderer, remote} = require('electron')
|
||||
const {ipcMain, webContents, BrowserWindow} = remote
|
||||
|
||||
const comparePaths = function (path1, path2) {
|
||||
if (process.platform === 'win32') {
|
||||
|
@ -244,6 +241,30 @@ describe('ipc module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('ipcRenderer.sendTo', function () {
|
||||
let contents = null
|
||||
beforeEach(function () {
|
||||
contents = webContents.create({})
|
||||
})
|
||||
afterEach(function () {
|
||||
ipcRenderer.removeAllListeners('pong')
|
||||
contents.destroy()
|
||||
contents = null
|
||||
})
|
||||
|
||||
it('sends message to WebContents', function (done) {
|
||||
const webContentsId = remote.getCurrentWebContents().id
|
||||
ipcRenderer.once('pong', function (event, id) {
|
||||
assert.equal(webContentsId, id)
|
||||
done()
|
||||
})
|
||||
contents.once('did-finish-load', function () {
|
||||
ipcRenderer.sendTo(contents.id, 'ping', webContentsId)
|
||||
})
|
||||
contents.loadURL('file://' + path.join(fixtures, 'pages', 'ping-pong.html'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('remote listeners', function () {
|
||||
var w = null
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue