diff --git a/browser/brave_ads/ads_tab_helper.cc b/browser/brave_ads/ads_tab_helper.cc index c745bfc53c4c4..7eaeb39a3fe89 100644 --- a/browser/brave_ads/ads_tab_helper.cc +++ b/browser/brave_ads/ads_tab_helper.cc @@ -10,6 +10,7 @@ #include "brave/browser/brave_ads/ads_service_factory.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/common/chrome_isolated_world_ids.h" #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" #include "components/dom_distiller/content/browser/distiller_page_web_contents.h" #include "components/sessions/content/session_tab_helper.h" @@ -45,6 +46,11 @@ AdsTabHelper::AdsTabHelper(content::WebContents* web_contents) OnBrowserSetLastActive(BrowserList::GetInstance()->GetLastActive()); #endif OnVisibilityChanged(web_contents->GetVisibility()); + + // Set the JavaScript world ID if not assigned yet. + if (!dom_distiller::DistillerJavaScriptWorldIdIsSet()) + dom_distiller::SetDistillerJavaScriptWorldId( + ISOLATED_WORLD_ID_BRAVE_INTERNAL); } AdsTabHelper::~AdsTabHelper() {