[M120 Migration][HBBTV] Forcing v8 context initialization if no <script> 29/307429/2
authorzhaodan <danys.zhao@samsung.com>
Fri, 8 Mar 2024 07:17:45 +0000 (15:17 +0800)
committerYanqing Lu <yanqing.lu@samsung.com>
Tue, 12 Mar 2024 01:17:37 +0000 (01:17 +0000)
In some hbbtv test cases, there is no <script>. hbbtv v8 extension
could not be called. This patch forces v8 context initialization at
loading time.

Reference:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/291332/

Change-Id: Ifd81763460399ce86c6bf72e79d8868aa31837f6
Signed-off-by: zhaodan <danys.zhao@samsung.com>
third_party/blink/renderer/core/loader/frame_loader.cc

index c97e4a5..61e6647 100644 (file)
 #include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
 #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "third_party/blink/public/platform/web_application_type.h"
+#include "third_party/blink/renderer/core/dom/static_node_list.h"
+#endif
+
 namespace blink {
 
 namespace {
@@ -1727,6 +1732,20 @@ void FrameLoader::DispatchDidClearDocumentOfWindowObject() {
 
   Settings* settings = frame_->GetSettings();
   LocalDOMWindow* window = frame_->DomWindow();
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (IsHbbTV() && frame_->IsMainFrame()) {
+    StaticElementList* script_elements =
+        frame_->GetDocument()->QuerySelectorAll(WebString("script"));
+    if (!script_elements || !script_elements->length()) {
+      LOG(INFO) << "There is no <script>, v8 is not initialized.";
+      if (settings && !settings->GetForceMainWorldInitialization()) {
+        LOG(INFO) << "Forcing v8 initialization for hbbtv is enabled.";
+        // Forcibly instantiate WindowProxy.
+        window->GetScriptController().WindowProxy(DOMWrapperWorld::MainWorld());
+      }
+    }
+  }
+#endif
   if (settings && settings->GetForceMainWorldInitialization()) {
     // Forcibly instantiate WindowProxy, even if script is disabled.
     window->GetScriptController().WindowProxy(DOMWrapperWorld::MainWorld());