Add spec for devtools extension
This commit is contained in:
parent
fb6f5320e7
commit
189380d4ea
4 changed files with 51 additions and 1 deletions
|
@ -824,6 +824,30 @@ describe('browser-window module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('dev tool extensions', function () {
|
describe('dev tool extensions', function () {
|
||||||
|
describe('BrowserWindow.addDevToolsExtension', function () {
|
||||||
|
it('creates the extension', function (done) {
|
||||||
|
var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
|
||||||
|
BrowserWindow.addDevToolsExtension(extensionPath)
|
||||||
|
|
||||||
|
w.webContents.on('devtools-opened', () => {
|
||||||
|
var inputEventIntervalId = setInterval(function () {
|
||||||
|
if (w && w.devToolsWebContents) {
|
||||||
|
w.devToolsWebContents.sendInputEvent({type: 'keyDown', keyCode:'[', modifiers: ['meta']})
|
||||||
|
} else {
|
||||||
|
clearInterval(inputEventIntervalId)
|
||||||
|
}
|
||||||
|
}, 250)
|
||||||
|
})
|
||||||
|
w.loadURL('about:blank')
|
||||||
|
w.webContents.openDevTools({mode: 'bottom'})
|
||||||
|
|
||||||
|
ipcMain.once('answer', function (event, message) {
|
||||||
|
assert.equal(message, 'extension loaded')
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('serializes the registered extensions on quit', function () {
|
it('serializes the registered extensions on quit', function () {
|
||||||
var extensionName = 'foo'
|
var extensionName = 'foo'
|
||||||
var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName)
|
var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName)
|
||||||
|
|
10
spec/fixtures/devtools-extensions/foo/foo.html
vendored
Normal file
10
spec/fixtures/devtools-extensions/foo/foo.html
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>foo</title>
|
||||||
|
<script>
|
||||||
|
chrome.devtools.panels.create('Foo', 'foo.png', 'index.html')
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
</html>
|
14
spec/fixtures/devtools-extensions/foo/index.html
vendored
Normal file
14
spec/fixtures/devtools-extensions/foo/index.html
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title></title>
|
||||||
|
<script>
|
||||||
|
var sendMessage = `require('electron').ipcRenderer.send('answer', 'extension loaded')`
|
||||||
|
window.chrome.devtools.inspectedWindow.eval(sendMessage, function () {})
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
a custom devtools extension
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,3 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "foo"
|
"name": "foo",
|
||||||
|
"version": "1.0",
|
||||||
|
"devtools_page": "foo.html"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue