Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NPN_Evaluate changed from FFx 14 to FFx 15

40 views
Skip to first unread message

Rudi Sherry

unread,
Sep 10, 2012, 5:24:03 PM9/10/12
to dev-tech...@lists.mozilla.org
We have a plugin that calls NPNEvaluate with "new Array;"

NPVariant outObj;
NPString str = { "new Array;", 10 };
NPBool success = NPN_Evaluate(ourInstance, jsObjectForPlugin, str, &outObj);

where 'jsObjectForPlugin' was set by the SetProperty callback, in the class returned when the container asked for NPPVpluginScriptableNPObject.

The HTML Javascript looks something like:

pluginObj.objForPlugin = { onMessage: function(msg) {}, onError: function(data) {} };

(which invokes the SetProperty method in our plugin class).

...so jsObjForPlugin corresponds to the inline object containing those two function properties.

In Firefox 14 (and every Firefox back to 3.x), NPN_Evaluate() returns 'true' and the outObj is type NPObject/
In Firefox 15, NPN_Evaluate() returns 'false' and the outObj is of type NPNull.

I looked briefly at the changes from 14 to 15 but there were too many, and some were too subtle, for me to figure out.

Does anyone have any suggestions? I tried "new Array();" instead of "new Array;" with no success.


Benjamin Smedberg

unread,
Sep 11, 2012, 9:57:36 AM9/11/12
to Rudi Sherry, dev-tech...@lists.mozilla.org
On 9/10/2012 5:24 PM, Rudi Sherry wrote:
> We have a plugin that calls NPNEvaluate with "new Array;"
>
> NPVariant outObj;
> NPString str = { "new Array;", 10 };
> NPBool success = NPN_Evaluate(ourInstance, jsObjectForPlugin, str, &outObj);
>
> where 'jsObjectForPlugin' was set by the SetProperty callback, in the class returned when the container asked for NPPVpluginScriptableNPObject.
I am pretty certain that `jsObjectForPlugin` is not the value you want.

This parameter is supposed to identify the *scope* object that you're
evaluating against. In almost all cases, you should be passing `window`
as your scope object, and I'm certain that's what you want in this case.

I'm not sure why we allow you to specify other scope objects, or whether
we should just ignore the scope parameter because `window` is always
correct.

I'm also interested in figuring out why this used to work but doesn't
any more; I'll try to look at this.

--BDS

Benjamin Smedberg

unread,
Sep 12, 2012, 1:57:35 PM9/12/12
to Rudi Sherry, dev-tech...@lists.mozilla.org
On 9/10/2012 5:24 PM, Rudi Sherry wrote:
> We have a plugin that calls NPNEvaluate with "new Array;"
>
> NPVariant outObj;
> NPString str = { "new Array;", 10 };
> NPBool success = NPN_Evaluate(ourInstance, jsObjectForPlugin, str, &outObj);
>
> where 'jsObjectForPlugin' was set by the SetProperty callback, in the class returned when the container asked for NPPVpluginScriptableNPObject.
>
> The HTML Javascript looks something like:
>
> pluginObj.objForPlugin = { onMessage: function(msg) {}, onError: function(data) {} };
>
> (which invokes the SetProperty method in our plugin class).
>
> ...so jsObjForPlugin corresponds to the inline object containing those two function properties.
>
> In Firefox 14 (and every Firefox back to 3.x), NPN_Evaluate() returns 'true' and the outObj is type NPObject/
> In Firefox 15, NPN_Evaluate() returns 'false' and the outObj is of type NPNull.

I was not able to replicate your problem. I created a simple test plugin
(sources at https://github.com/bsmedberg/blue-fishmonger-testplugin) and
in both Firefox 15 and mozilla trunk I get NPN_Evaluate working
correctly with the NPPVpluginScriptableNPObject as the scope object.

Is it possible that the code in question is running across multiple
frames? We did make changes in Firefox 15 related to how JS runs when it
touches objects from other frames/windows, and that could be affecting
the scope lookups here. I'd love to see this problem in action with the
smallest testcase you can come up with. File a bug and cc me if appropriate.

--BDS

Rudi Sherry

unread,
Sep 12, 2012, 2:14:53 PM9/12/12
to Benjamin Smedberg, dev-tech...@lists.mozilla.org
I'm having trouble with reproducing this with simple cases; I'll get back to the person that reported it to me and see if it's a cross-frame issue (that's very possible).

Thanks,
Rudi


0 new messages