Closed
Bug 313581
Opened 20 years ago
Closed 20 years ago
JavaScript native function aliasing error
Categories
(Firefox :: General, defect)
Firefox
General
Tracking
()
RESOLVED
DUPLICATE
of bug 252291
People
(Reporter: retal, Unassigned)
Details
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 2.0.50215)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.7.12) Gecko/20050919 Firefox/1.0.7
When aliasing a native function in the following way:
getId = document.getElementById;
And then invoking the function using the alias in the following way:
getId("typewin").style.display = "none";
Then the following error is thrown in the JavaScript Console [filename edited]:
Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: file:///[...] :: writeSyntax :: line 30" data: no]
Reproducible: Always
Steps to Reproduce:
1. Alias a native JavaScript function
2. Call the function using the new alias
Actual Results:
Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: file:///[...] :: writeSyntax :: line 30" data: no]
Expected Results:
Executed the function as if not using the alias, without error.
The constructs:
element = document.getElementById(...);
and:
getId = document.getElementById;
element = getId(...);
will produce different results.
The former supplies |document| as |this| value for the method. So it succeeds.
The later supplies the global object (i.e. |window|) as |this| value for the
method. It will fail because the method does not accept such |this| value.
This bug should be resolved as INVALID.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Updated•18 years ago
|
Resolution: INVALID → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•