提交 eab96df4 编写于 作者: M Matt Bierner

Allow cmr+r reload from webview developer tools

Fixes #48975
上级 730eb4e5
......@@ -34,6 +34,7 @@
var loadTimeout;
var pendingMessages = [];
var enableWrappedPostMessage = false;
let isInDevelopmentMode = false;
const initData = {
initialScrollProgress: undefined
......@@ -89,7 +90,6 @@
};
const onMessage = (message) => {
// Old school webview. Forward exact message
ipcRenderer.sendToHost(message.data.command, message.data.data);
};
......@@ -322,6 +322,12 @@
// write new content onto iframe
newFrame.contentDocument.open('text/html', 'replace');
newFrame.contentWindow.onbeforeunload = () => {
if (isInDevelopmentMode) { // Allow reloads while developing a webview
ipcRenderer.sendToHost('do-reload');
return false;
}
// Block navigation when not in development mode
console.log('prevented webview navigation');
return false;
};
......@@ -395,6 +401,10 @@
initData.initialScrollProgress = progress;
});
ipcRenderer.on('devtools-opened', () => {
isInDevelopmentMode = true;
});
// Forward messages from the embedded iframe
window.onmessage = onMessage;
......
......@@ -158,6 +158,10 @@ export class WebviewElement {
this._onDidScroll.fire({ scrollYPercentage: event.args[0] });
}
return;
case 'do-reload':
this.reload();
return;
}
}),
addDisposableListener(this._webview, 'focus', () => {
......@@ -169,7 +173,10 @@ export class WebviewElement {
if (this._contextKey) {
this._contextKey.reset();
}
})
}),
addDisposableListener(this._webview, 'devtools-opened', () => {
this._send('devtools-opened');
}),
);
this._webviewFindWidget = new WebviewFindWidget(this._contextViewService, this);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册