Last Comment Bug 307005 - NS_ERROR_UNEXPECTED when using evalInSandbox with XPCNativeWrapper
: NS_ERROR_UNEXPECTED when using evalInSandbox with XPCNativeWrapper
: fixed1.8, testcase
Product: Core
Classification: Components
Component: XPConnect (show other bugs)
: Trunk
: x86 Windows XP
: -- normal (vote)
: ---
Assigned To: Blake Kaplan (:mrbkap)
: Phil Schwartau
: Andrew Overholt [:overholt]
Depends on:
  Show dependency treegraph
Reported: 2005-09-03 20:49 PDT by Aaron Boodman
Modified: 2006-03-12 18:53 PST (History)
4 users (show)
brendan: blocking1.8b5+
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

testcase (341 bytes, text/html)
2005-09-12 10:31 PDT, Martijn Wargers [:mwargers] (not working for Mozilla)
no flags Details
Fix (4.87 KB, patch)
2005-09-12 14:23 PDT, Blake Kaplan (:mrbkap)
jst: review+
brendan: superreview+
asa: approval1.8b5+
Details | Diff | Splinter Review

Description Aaron Boodman 2005-09-03 20:49:25 PDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b3) Gecko/20050712 Firefox/1.0+
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b3) Gecko/20050712 Firefox/1.0+

If you set the __proto__ of a sandbox being used with evalInSandbox to an
XPCNativeWrapper object, it doesn't work and you only get a generic error
message. It should work the same as it does without the XPCNativeWrapper so long
as the methods being called actually exist, and it should throw a descriptive
'method not defined' error with line number if they do not.

Reproducible: Always

Steps to Reproduce:
1. Run example code.
Actual Results:  
JS console says:
Error: uncaught exception: [Exception... "Unexpected error"  nsresult:
"0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame ::
file:///C:/Documents%20and%20Settings/aa/Desktop/evalInSandbox.html ::
<TOP_LEVEL> :: line 6"  data: no]

Expected Results:  
It should show an alert box that says 'inside eval'.

If you uncomment line 5 it works correctly.
Comment 1 Brendan Eich [:brendan] 2005-09-11 23:32:45 PDT
Calling Dr. BKap!  Calling Dr. BKap!

Comment 2 Blake Kaplan (:mrbkap) 2005-09-12 09:54:05 PDT
Aaron, is there a testcase that wants to be attached to this bug?
Comment 3 Martijn Wargers [:mwargers] (not working for Mozilla) 2005-09-12 10:31:36 PDT
Created attachment 195768 [details]

Well, just look at the url, not? 
This is the testcase from the url.
Comment 4 Blake Kaplan (:mrbkap) 2005-09-12 10:46:49 PDT
Doh, I tend not to look at the URL field :(

I'll try to see what's going on when my new debug build finishes building.
Comment 5 Blake Kaplan (:mrbkap) 2005-09-12 14:23:33 PDT
Created attachment 195793 [details] [diff] [review]

So the problem here is that XPC native wrappers can have their functions called
with a |this| object that isn't a native wrapper if the native wrapper itself
is in the prototype chain. This patch makes XPCNativeWrappers deal with that
Comment 6 Brendan Eich [:brendan] 2005-09-12 14:53:43 PDT
Comment on attachment 195793 [details] [diff] [review]

Cool, glad you avoided extra null tests in the common case by testing and
throwing inside the while loop.

Comment 7 Brendan Eich [:brendan] 2005-09-12 15:20:14 PDT
We need this fixed for 1.8final/Firefox 1.5.

Comment 8 Johnny Stenback (:jst, 2005-09-12 17:35:45 PDT
Comment on attachment 195793 [details] [diff] [review]

Comment 9 Blake Kaplan (:mrbkap) 2005-09-13 09:54:39 PDT
Fix checked into trunk.
Comment 10 Blake Kaplan (:mrbkap) 2005-09-14 14:47:04 PDT
Fix checked into MOZILLA_1_8_BRANCH.

Note You need to log in before you can comment on or make changes to this bug.