Falling to pass FB::JSAPIAuto as argument to second <object>

31 views
Skip to first unread message

Jacques-Olivier Haché

unread,
Apr 26, 2017, 12:12:34 AM4/26/17
to firebreath-dev
Hi,

I have a JSAPIAuto child class (let's call it class A). 
I create an instance of it from a plugin <object>
I can easily pass that back to my <object> as argument.

At some point, I want to pass that instance back to my plugin code, but to a different plugin <object> in the DOM (a second, or third one. The first on is still present in the DOM)
I have tried a few solutions that consistently fail.

1. I tried passing a APtr (boost::shared_ptr<A>) to the second object :
bool pluginAPI::foo(APtr ptr) {...}
This fails to even start the call on foo, I get a "Error: Error calling method on NPObject." error in Safari

2. I tried passing A as an FB::variant, and using is_of_type and can_be_type to cast the object back into a APtr:
bool pluginAPI::foo(FB::variant ptr) {
  if(ptr.is_of_type<FB::JSObjectPtr>()) {
    if (ptr.can_be_type<APtr>()) {
      ...
    }
  }
  ...
}

but ptr.can_be_type<APtr>() returns false when the call is not made on the first <object> injected in the DOM.

Is this a known limitation of FB/ActiveX/NPAPI ?
Is there a standard way of passing such a value back to a new <object>

Regards,
J-O

Alexandre GOUAILLARD

unread,
Apr 26, 2017, 12:53:13 AM4/26/17
to firebre...@googlegroups.com
with such e-mail signature, it seems dangerous for us to answer. :-)

Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this email is strictly prohibited and may be unlawful."

also, we're not in 2016 anymore.


This email and any files transmitted with it are for the sole use of the intended recipient and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply email and destroy all copies and the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this email is strictly prohibited and may be unlawful. Thank you for your cooperation.

2016, Temasys (www.temasys.io)

--

---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alex. Gouaillard, PhD, PhD, MBA
------------------------------------------------------------------------------------
President - CoSMo Software Consulting, Singapore
------------------------------------------------------------------------------------

Richard Bateman

unread,
Apr 26, 2017, 11:11:12 AM4/26/17
to FireBreath Dev Group
Unfortunately several years ago a change was made to most browsers and
when you pass an NPObject back into the plugin there is no way to get
the original object, which means it's not possible to get the original
JSAPIPtr from it. In other words, what you want to do is
unfortunately not possible.

I recommend using some sort of identifier in a std::map<int,
FB::JSAPIWeakPtr> and when you get the JSObjectPtr back in you can
call a "getId" or similar type function which would tell you what the
id of that object is, then you look it up in the map.

(yes, you'd have to implement all of that yourself)

Richard
> ________________________________
> This email and any files transmitted with it are for the sole use of the
> intended recipient and may contain confidential and privileged information.
> If you are not the intended recipient, please contact the sender by reply
> email and destroy all copies and the original message. Any unauthorized
> review, use, disclosure, dissemination, forwarding, printing or copying of
> this email or any action taken in reliance on this email is strictly
> prohibited and may be unlawful. Thank you for your cooperation.
> ________________________________
> 2016, Temasys (www.temasys.io)
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "firebreath-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to firebreath-de...@googlegroups.com.

Jacques-Olivier Haché

unread,
Apr 26, 2017, 10:30:09 PM4/26/17
to firebreath-dev
Alright, if that's the best solution, I'll use it.

Thanks Richard

Richard Bateman

unread,
Apr 27, 2017, 1:14:46 PM4/27/17
to FireBreath Dev Group
Just make sure you use weak_ptrs so that you don't create a reference loop.

Richard

On Wed, Apr 26, 2017 at 8:30 PM, Jacques-Olivier Haché
Reply all
Reply to author
Forward
0 new messages