fix crash when using getWebPreferences api with devtools webContents (#12254)
This commit is contained in:
parent
e62349cffb
commit
e741bc0577
2 changed files with 12 additions and 0 deletions
|
@ -1820,6 +1820,8 @@ void WebContents::OnGetZoomLevel(content::RenderFrameHost* rfh,
|
||||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
||||||
WebContentsPreferences* web_preferences =
|
WebContentsPreferences* web_preferences =
|
||||||
WebContentsPreferences::FromWebContents(web_contents());
|
WebContentsPreferences::FromWebContents(web_contents());
|
||||||
|
if (!web_preferences)
|
||||||
|
return v8::Null(isolate);
|
||||||
return mate::ConvertToV8(isolate, *web_preferences->web_preferences());
|
return mate::ConvertToV8(isolate, *web_preferences->web_preferences());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,16 @@ describe('webContents module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('getWebPreferences() API', () => {
|
||||||
|
it('should not crash when called for devTools webContents', (done) => {
|
||||||
|
w.webContents.openDevTools()
|
||||||
|
w.webContents.once('devtools-opened', () => {
|
||||||
|
assert(!w.devToolsWebContents.getWebPreferences())
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('before-input-event event', () => {
|
describe('before-input-event event', () => {
|
||||||
it('can prevent document keyboard events', (done) => {
|
it('can prevent document keyboard events', (done) => {
|
||||||
w.loadURL(`file://${path.join(__dirname, 'fixtures', 'pages', 'key-events.html')}`)
|
w.loadURL(`file://${path.join(__dirname, 'fixtures', 'pages', 'key-events.html')}`)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue