Closed
Bug 360883
Opened 19 years ago
Closed 8 years ago
Cannot call confirm() using reference to function -- "Illegal operation on WrappedNative prototype object"
Categories
(Core :: XPConnect, defect)
Tracking
()
RESOLVED
INACTIVE
Future
People
(Reporter: Cloink_Friggson, Unassigned)
References
Details
(Whiteboard: [Future = Gecko 2.0])
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8
The following javascript function generates an 'uncaught exception' (details after func).
Tu_conf.routeTo = confirm; // allows an app-func to receive message instead.
{
return Tu_conf.routeTo(Tu_msgFmt(arguments)) ; // doesn't work
}
Error details.
Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: http://localhost/Utilhtml/Tu.js :: Tu_conf :: line 228" data: no]
Reproducible: Always
Steps to Reproduce:
See details.
Actual Results:
Error as per details.
Expected Results:
No error, confirm dialogue should appear.
It works in IE.
| Reporter | ||
Comment 1•19 years ago
|
||
Bugger, I've deleted a line by accident, the javascript should look like this:
Tu_conf.routeTo = confirm; // allows an app-func to receive message instead.
function Tu_conf(msg)
{
return Tu_conf.routeTo(Tu_msgFmt(arguments)) ; // doesn't work
}
Comment 2•19 years ago
|
||
Here's a simple testcase:
javascript:foo={bar:alert}; foo.bar(3)
On trunk, this causes the same error:
Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: javascript:foo={bar:alert}; foo.bar(3) :: <TOP_LEVEL> :: line 1" data: no]
This is probably because confirm expects its "this" pointer to be a window. The following code does work:
javascript:foo={bar:alert}; foo.bar.call(window, 3)
Summary: JavaScript: Cannot invoke confirm() using reference to function → Cannot call confirm() using reference to function -- "Illegal operation on WrappedNative prototype object"
Comment 3•19 years ago
|
||
Exactly. This is as designed, in fact. But it *may* change in mozilla 2.0 (i.e. Firefox 4), but that's not known for sure yet. This will *not* be fixed before 4.0, that's for sure.
| Reporter | ||
Comment 4•19 years ago
|
||
Whaddya mean "Exactly. This is as designed.." ?! JavaScript allows, even encourages, functions to be invoked via references. Full stop. The confirm function is not exempt just because it's a native function.
Comment 5•19 years ago
|
||
I mean we intentionally break those rules, and have been for the last 6 years. The reasons for this goes way back and way deep into the XPConnect code that exposes these function objects in a way that uses as little memory as reasonably possible, and because of that the functions are shared function objects that do not carry their own |this| property and thus won't be callable on objects other than the object they belong to.
I'm not saying this is good, or ever was. But it is what it is and changing it would be an *enormous* change in the source code in a very critical piece of code, and we simply can not do that w/o allowing for a lot of time to make sure things didn't break, let alone the fact that we don't have a reasonable way to fix this at this point.
Comment 6•17 years ago
|
||
Confirming based on test case attached to Bug 417004(document.getElementById case).
Setting dependency of 417004.
Blocks: 417004
Updated•17 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Version: unspecified → Trunk
Comment 7•17 years ago
|
||
(In reply to comment #3)
> This will *not* be fixed before 4.0, that's for sure.
Where can we request blocking-firefox-4.0?
Simplest workaround by site is; (but very tough work when some sites)
f=native_code_function; => function f(parm){return native_code_function(parm):}
obj.f=native_code_function; => obj.f=f; with function definition of f();
When we need to request site to modify script code, we have to explain why & how (and which code also) each time. Is there any documentation which describes about it?
Updated•17 years ago
|
URL: (software development in progress)
Component: General → XPConnect
Product: Firefox → Core
QA Contact: general → xpconnect
Whiteboard: [Future = Gecko 2.0]
Target Milestone: --- → Future
Comment 8•8 years ago
|
||
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INACTIVE
You need to log in
before you can comment on or make changes to this bug.
Description
•