From ac4658d698755db415f0af1c94e0b172cf0e8e11 Mon Sep 17 00:00:00 2001 From: Aleksey Seren Date: Mon, 6 Sep 2021 18:08:13 +0700 Subject: [PATCH] Add check if javascript was disallowed. fix https://github.com/brave/brave-browser/issues/17864 --- .../ui/webui/new_tab_page/brave_new_tab_message_handler.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc b/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc index 9a909e7142cb..b406a23eca59 100644 --- a/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc +++ b/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc @@ -431,6 +431,7 @@ void BraveNewTabMessageHandler::OnJavascriptDisallowed() { if (tor_launcher_factory_) tor_launcher_factory_->RemoveObserver(this); #endif + weak_ptr_factory_.InvalidateWeakPtrs(); } void BraveNewTabMessageHandler::HandleGetPreferences( @@ -726,6 +727,11 @@ void BraveNewTabMessageHandler::HandleTodayGetDisplayAd( if (!handler) { return; } + + if (!handler->IsJavascriptAllowed()) { + return; + } + if (!success) { handler->ResolveJavascriptCallback(base::Value(callback_id), std::move(base::Value()));