1
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:
David Rosca 2015-09-30 13:01:14 +02:00
parent c042d86467
commit bfad9eb0aa
2 changed files with 5 additions and 7 deletions

View File

@ -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

View File

@ -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;
}