NS_ERROR_UNEXPECTED when using evalInSandbox with XPCNativeWrapper

RESOLVED FIXED

Status

()

Core
XPConnect
RESOLVED FIXED
12 years ago
11 years ago

People

(Reporter: Aaron Boodman, Assigned: mrbkap)

Tracking

({fixed1.8, testcase})

Trunk
x86
Windows XP
fixed1.8, testcase
Points:
---
Bug Flags:
blocking1.8b5 +

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(2 attachments)

(Reporter)

Description

12 years ago
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.

Updated

12 years ago
Assignee: nobody → dbradley
Component: General → XPConnect
Keywords: testcase
Product: Firefox → Core
QA Contact: general → pschwartau
Version: unspecified → Trunk
Calling Dr. BKap!  Calling Dr. BKap!

/be
Status: UNCONFIRMED → NEW
Ever confirmed: true
(Assignee)

Comment 2

12 years ago
Aaron, is there a testcase that wants to be attached to this bug?
Created attachment 195768 [details]
testcase

Well, just look at the url, not? 
This is the testcase from the url.
(Assignee)

Comment 4

12 years ago
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.
Assignee: dbradley → mrbkap
(Assignee)

Comment 5

12 years ago
Created attachment 195793 [details] [diff] [review]
Fix

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
case.
Attachment #195793 - Flags: superreview?(brendan)
Attachment #195793 - Flags: review?(jst)
(Assignee)

Updated

12 years ago
Status: NEW → ASSIGNED
Comment on attachment 195793 [details] [diff] [review]
Fix

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

/be
Attachment #195793 - Flags: superreview?(brendan) → superreview+
We need this fixed for 1.8final/Firefox 1.5.

/be
Flags: blocking1.8b5+
Comment on attachment 195793 [details] [diff] [review]
Fix

r=jst
Attachment #195793 - Flags: review?(jst) → review+
(Assignee)

Updated

12 years ago
Attachment #195793 - Flags: approval1.8b5?
(Assignee)

Comment 9

12 years ago
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → FIXED

Updated

12 years ago
Attachment #195793 - Flags: approval1.8b5? → approval1.8b5+
(Assignee)

Comment 10

12 years ago
Fix checked into MOZILLA_1_8_BRANCH.
Keywords: fixed1.8
You need to log in before you can comment on or make changes to this bug.