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)
Tracking
()
        RESOLVED
        FIXED
        
    
  
        
            mozilla1.9alpha1
        
    
  
People
(Reporter: blacklion, Assigned: mrbkap)
References
()
Details
(Keywords: fixed1.8.0.1, fixed1.8.1, regression)
Attachments
(1 file)
| 
        
        
         2.16 KB,
          patch         
       | 
      
           mrbkap
 :
              
              review+
          brendan
 :
              
              superreview+
          dveditz
 :
              
              approval1.8.0.1+
          dveditz
 :
              
              approval1.8.1+
           | 
      Details | Diff | Splinter Review | 
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.
          Updated•19 years ago
           
         | 
      
Assignee: general → dbradley
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → XPConnect
Ever confirmed: true
QA Contact: general → pschwartau
| Assignee | ||
          Comment 1•19 years ago
           
         | 
      ||
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).
| Reporter | ||
          Comment 2•19 years ago
           
         | 
      ||
(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 3•19 years ago
           
         | 
      ||
Comment on attachment 205112 [details] [diff] [review]
Innerize the global object
sr=me, if you want it.
/be
        Attachment #205112 -
        Flags: superreview+
| Assignee | ||
          Updated•19 years ago
           
         | 
      
Priority: -- → P2
Target Milestone: --- → mozilla1.9alpha
| Assignee | ||
          Comment 4•19 years ago
           
         | 
      ||
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+
| Assignee | ||
          Comment 5•19 years ago
           
         | 
      ||
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
          Updated•19 years ago
           
         | 
      
Flags: blocking1.8.1?
Flags: blocking1.8.1+
Flags: blocking1.8.0.1?
Flags: blocking1.8.0.1+
          Comment 6•19 years ago
           
         | 
      ||
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+
          Updated•19 years ago
           
         | 
      
Whiteboard: need branch checkin
| Assignee | ||
          Comment 7•19 years ago
           
         | 
      ||
Sorry, I checked this into the branches last Friday.
Keywords: fixed1.8.0.1, 
          
            fixed1.8.1
Whiteboard: need branch checkin
          Comment 8•19 years ago
           
         | 
      ||
Bug 359159 looks similar.
          You need to log in
          before you can comment on or make changes to this bug.
        
Description
•