From ce200dd97d467ca01a9c9678ba9e154b72a56134 Mon Sep 17 00:00:00 2001 From: Marcin Mielczarczyk Date: Wed, 17 May 2023 13:51:39 +0200 Subject: [PATCH] ONEM-30717: Send close notification on window.close() Send close notification even when 'allowScriptsToCloseWindow' preference is not set. This patch is based on following legacy changes: * LibertyGlobal/wpe-webkit@1bf6ab0 * 0158.window_close.patch --- Source/WebCore/page/DOMWindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp index 1c431efec2609..6538aa69de68e 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -1073,8 +1073,10 @@ void DOMWindow::close() if (!frame->isMainFrame()) return; - if (!(page->openedByDOM() || page->backForward().count() <= 1 || frame->settings().allowScriptsToCloseWindows())) { - console()->addMessage(MessageSource::JS, MessageLevel::Warning, "Can't close the window since it was not opened by JavaScript"_s); + // Make allowScriptsToCloseWindow pref value take precedence when closing window + if (!frame->settings().allowScriptsToCloseWindows() || !(page->openedByDOM() || page->backForward().count() <= 1)) { + // Send close notification to give a chance for AWC to react on window.close() + page->chrome().closeWindow(); return; }