Search code examples
firebreath

Why is there differences in behavior of convert_cast in firebreath 2.0 plugin method using Chrome and IE


Good day.

I have next method in my firebreath 2.0 plugin:

void A::get_string(const FB::JSObjectPtr& myclassObj)
{
    FB::variantPromise a = myclassObj->Invoke("mymethod", FB::VariantList{ "test" });
    a.then<void>([this](FB::variant ret) {
        std::string Str = ret.convert_cast<std::string>();
        return;
    });
}

mymethod in myclassObj is:

std::string B::mymethod(std::string tStr)
{
    return tStr;
}

std::string "test" is expected to be in Str, but after i call get_string from browser, there is behavior difference: When i'm using Chrome i get string in ret and conversion is ok. When i'm using IE i get shared_ptr in ret and i can not get my string from it. In that case i get exception in conversion.

Please, help me determine what i'm doing wrong :)

p.s. It is not matter, what i'm trying to get: std::string, long, or smth else, in chrome conversion is ok, but in IE in ret i get only shared_ptr.

In fact, i want to get a pointer to myclassObj in get_string method, but i'm stuck because of proxy-classes. So, i'm trying to get pointer using std::string.


Solution

  • You'd have to debug into what is actually happening; it's possible there is a bug in the IE interface of FireBreath 2, since I don't think it's been extensively tested. If so, you could probably find and fix it -- that's the advantage of open source!

    Rather than pass objects back in from the browser, though, I'd recommend using some sort of identifier that you pass in and then look up the object with a map or something on the plugin side. That way you don't have all the overhead of going through the browser's proxies