Closed Bug 385986 Opened 18 years ago Closed 4 years ago

Plugin (NPRuntime) functions don't behave like normal JS function (apply doesn't work)

Categories

(Core Graveyard :: Plug-ins, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: netdragon, Unassigned)

References

()

Details

Attachments

(1 file, 2 obsolete files)

If you request a reference to a Flash embed using document.getElementById or some other method, then attempt to use the .apply method on it, Flash complains .apply doesn't exist. flashObj["functionName"]('foo') works, and flashObj.functionName('foo') works, but flashObj["functionName"].apply(flashObj,args) doesn't work, where args is an array of arguments. The error claims that method apply doesn't exist. Internet Explorer, on the other hand, has implemented apply for embedded objects. I'm thinking, therefore, with the way Javascript binds to embedded objects, but I'm not sure which component to file this under. This issue has caused difficulty for me to attempt to abstract EI in a way that keeps a lot of the details of some checking I do out of the hand of developers that shouldn't be dealing with it on a day-to-day basis. http://www.thescripts.com/forum/thread648096.html provides an example of someone else having the same issue as I am. Here is some sample JS (written off the top of my head): var _args = new Array(); _args[0] = "hello"; var flashObj = document.getElementById("embedID"); flashObj["sendText"].apply(flashObj, _args); I've provided some sample Adobe Flash code that can be used to test: import flash.external.ExternalInterface; _dtext = "blah"; // _dtext is a dynamic text symbol on the Flash timeline _root.sendText = function(text) { // Do something _dtext = text; } ExternalInterface.addCallback("sendText", this, _root.sendText); Here are some more details on Flash ExternalInterface: http://livedocs.adobe.com/flex/2/langref/flash/external/ExternalInterface.html
This is asking for a change to the NPRuntime spec and code, I think. It's a reasonable request, similar to complaints heard (and commented on in Ajax libs such as MochiKit) about IE's alert not being a function object in the sense that you can't alert.apply. /be
Assignee: general → nobody
Component: JavaScript Engine → Plug-ins
QA Contact: general → plugins
A test showing the results. Compare between IE7 and Firefox. I marked other two patches as obsolete because even though they aren't truly obsolete, they are only files used by this one, and thus aren't important to look at directly.
Attachment #269934 - Attachment is obsolete: true
Attachment #269939 - Attachment is obsolete: true
By the way, I just found a workaround until this is fixed (not sure yet if it's type-safe for passed and returned values yet, but I know it allows return values, and seems to work): Instead of using .attach, I'm using this: var _args = new Object(); var _argsString = ""; for( var i = 1; i < arguments.length; i++ ) { if (i!=1) _argsString += ","; _argsString += "_args[" + (i-1) + "]"; _args[i-1] = arguments[i]; } var execString = 'flashObj.'+functionName+'('+_argsString+')'; return eval(execString);
Priority: -- → P3
Summary: Flash ExternalInterface doesn't implement .apply → Plugin (NPRuntime) functions don't behave like normal JS function (apply doesn't work)
Resolving as wont fix, plugin support deprecated in Firefox 85.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: