Closed Bug 319172 Opened 19 years ago Closed 19 years ago

"function eval must be called directly, and not by way of a function of another name" in loaded sub-scripts.

Categories

(Core :: XPConnect, defect, P2)

x86
Windows XP
defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: blacklion, Assigned: mrbkap)

References

()

Details

(Keywords: fixed1.8.0.1, fixed1.8.1, regression)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5

When "eval" is called in function, defined in subscript, loaded with JSSubscriptLoader, this error occurs in recent trunk builds.

Reproducible: Always

Steps to Reproduce:
1. Create two JavaScript files:
============== main.js
var loader =
Components.classes['...@mozilla.org/moz/jssubscript-loader;1'].getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript('chrome://application/content/test.js');
TEST();
==============
============== test.js
function TEST()
{
  dump("EVAL: " + eval("1 + 1;") + "\n");
}
==============
2. Load "main.js" into XUL file with <script/> element.
3. Get this error in JavaScript console.

Actual Results:  
"function eval must be called directly, and not by way of a function of another name" error.

Expected Results:  
EVAL: 2
dumped into console.
Assignee: general → dbradley
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → XPConnect
Ever confirmed: true
QA Contact: general → pschwartau
Walking up the parent chain outerizes the global object (wrongly). We need to innerize at the top so that the script is loaded with the correct parent chain (pointing at the inner chrome window).
Assignee: dbradley → mrbkap
Status: NEW → ASSIGNED
Attachment #205112 - Flags: review?(shaver)
(In reply to comment #1)

> Walking up the parent chain outerizes the global object (wrongly). We need to
> innerize at the top so that the script is loaded with the correct parent chain
> (pointing at the inner chrome window).
 Patch works for me (reporter) on very recent trunk build (updated from CVS about 06 Dec 2005 22:00 GMT+3).
Comment on attachment 205112 [details] [diff] [review]
Innerize the global object

sr=me, if you want it.

/be
Attachment #205112 - Flags: superreview+
Priority: -- → P2
Target Milestone: --- → mozilla1.9alpha
Comment on attachment 205112 [details] [diff] [review]
Innerize the global object

Shaver gave me r=him in person. I also fixed the fprintf to print the correct thing.
Attachment #205112 - Flags: review?(shaver) → review+
Fix checked in. Nominating for branches since this is a relatively large regression from 1.0.x.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Flags: blocking1.8.1?
Flags: blocking1.8.0.1?
Keywords: regression
Resolution: --- → FIXED
Flags: blocking1.8.1?
Flags: blocking1.8.1+
Flags: blocking1.8.0.1?
Flags: blocking1.8.0.1+
Comment on attachment 205112 [details] [diff] [review]
Innerize the global object

a=dveditz for drivers
Attachment #205112 - Flags: approval1.8.1+
Attachment #205112 - Flags: approval1.8.0.1+
Whiteboard: need branch checkin
Sorry, I checked this into the branches last Friday.
Whiteboard: need branch checkin
Bug 359159 looks similar.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: