[M108 Migration][VD] Ensure plugin props are setting correctly. 91/289291/5
authorfr.fang <fr.fang@samsung.com>
Wed, 1 Mar 2023 12:59:34 +0000 (20:59 +0800)
committerBot Blink <blinkbot@samsung.com>
Fri, 10 Mar 2023 02:09:06 +0000 (02:09 +0000)
Internally, properties of plugin belong to 2 different targets,
one is HTMLPluginElement, one is the corresponding scriptable object.
Need to set properties to the correct target.

Reference:
https://review.tizen.org/gerrit/#/c/282087

Change-Id: Ic7509825520413e633114ce93c7a32dfcbed4b1c
Signed-off-by: fr.fang <fr.fang@samsung.com>
third_party/blink/renderer/bindings/core/v8/custom/v8_html_plugin_element_custom.cc

index 004130f..944ce8b 100644 (file)
@@ -106,11 +106,31 @@ void SetScriptableObjectProperty(
   v8::Local<v8::Context> context = state->GetContext();
   bool instance_has_property;
   bool holder_has_property;
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (!info.Holder()
+           ->Has(state->GetContext(), v8_name)
+           .To(&holder_has_property) ||
+      holder_has_property) {
+    // hbbtv uses Object.defineProperties to add attribututes to the
+    // scriptable object. Need to set these properties here.
+    if (!instance
+             ->HasOwnProperty(info.GetIsolate()->GetCurrentContext(), v8_name)
+             .To(&instance_has_property) ||
+        instance_has_property) {
+      [[maybe_unused]] v8::Maybe<bool> unused =
+          instance->Set(info.GetIsolate()->GetCurrentContext(), v8_name, value);
+
+      V8SetReturnValue(info, value);
+    }
+    return;
+  }
+#else
   if (!instance->HasOwnProperty(context, v8_name).To(&instance_has_property) ||
       !info.Holder()->Has(context, v8_name).To(&holder_has_property) ||
       (!instance_has_property && holder_has_property)) {
     return;
   }
+#endif
 
   // FIXME: The gTalk pepper plugin is the only plugin to make use of
   // SetProperty and that is being deprecated. This can be removed as soon as