mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
WebView: Bring back support for unbeforeunload when closing tab
This commit is contained in:
parent
c042d86467
commit
bfad9eb0aa
|
@ -431,7 +431,7 @@ void TabWidget::closeTab(int index, bool force)
|
|||
return;
|
||||
|
||||
// window.onbeforeunload handling
|
||||
if (!webView->onBeforeUnload())
|
||||
if (!force && !webView->onBeforeUnload())
|
||||
return;
|
||||
|
||||
// Save tab url and history
|
||||
|
|
|
@ -226,13 +226,11 @@ void WebView::restoreHistory(const QByteArray &data)
|
|||
|
||||
bool WebView::onBeforeUnload()
|
||||
{
|
||||
#if QTWEBENGINE_DISABLED
|
||||
const QString res = page()->mainFrame()->evaluateJavaScript("window.onbeforeunload(new Event(\"beforeunload\"))").toString();
|
||||
const QString &source = QSL("window.onbeforeunload(new Event('beforeunload'))");
|
||||
const QString &res = page()->execJavaScript(source, 200).toString();
|
||||
|
||||
if (!res.isEmpty()) {
|
||||
return page()->javaScriptConfirm(page()->mainFrame(), res);
|
||||
}
|
||||
#endif
|
||||
if (!res.isEmpty())
|
||||
return page()->javaScriptConfirm(url(), res);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user