Merge pull request #11300 from electron/external-devtools

Add API to set arbitrary WebContents as devtools
This commit is contained in:
Cheng Zhao 2017-12-05 10:35:49 +09:00 committed by GitHub
commit d598aa1a67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 199 additions and 47 deletions

View file

@ -643,6 +643,30 @@ describe('<webview> tag', function () {
})
})
describe('setDevToolsWebCotnents() API', () => {
it('sets webContents of webview as devtools', (done) => {
const webview2 = new WebView()
webview2.addEventListener('did-attach', () => {
webview2.addEventListener('dom-ready', () => {
const devtools = webview2.getWebContents()
assert.ok(devtools.getURL().startsWith('chrome-devtools://devtools'))
devtools.executeJavaScript('InspectorFrontendHost.constructor.name', (name) => {
assert.ok(name, 'InspectorFrontendHostImpl')
document.body.removeChild(webview2)
done()
})
})
webview.addEventListener('dom-ready', () => {
webview.getWebContents().setDevToolsWebContents(webview2.getWebContents())
webview.getWebContents().openDevTools()
})
webview.src = 'about:blank'
document.body.appendChild(webview)
})
document.body.appendChild(webview2)
})
})
describe('devtools-opened event', () => {
it('should fire when webview.openDevTools() is called', (done) => {
const listener = () => {