Closed Bug 654370 Opened 10 years ago Closed 10 years ago

instanceof operators doesn't work in a sandbox

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Honza, Assigned: mrbkap)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file)

I am facing a problem when using instanceof operator within a sandbox,
see the following example:

var Cu = Components.utils;
var sandbox = new Cu.Sandbox(window);
var script = "function (obj, type) { return obj instanceof type; }";
var instanceOf = Cu.evalInSandbox(script, sandbox, "1.8", "Test", 1);
instanceOf({}, Window);

I have evaluated this code in Error Console (Tools -> Error Console)
command line.
(just to note that changing wantXrays doesn't make any difference)

Firefox 3.6 returns false
Firefox 4.0 returns true
Firefox 5.0 (Aurora) returns true

So, only Firefox 3.6 works as expected.

Related thread:
http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/d082eaff53167a84/394e7b92d364e08f?hl=en#394e7b92d364e08f

Honza
OS: Windows Vista → All
Hardware: x86 → All
Version: 1.9.1 Branch → Trunk
Blake, Andreas, this sounds like proxy fail of some sort...
Component: DOM: Core & HTML → XPConnect
QA Contact: general → xpconnect
Attached patch Proposed fixSplinter Review
Everywhere except in jswrapper that we call into the JSClass's hasInstance hook, we initialize the out parameter to false. I don't know if that's an implicit part of the API, but it lead to us reading an uninitialized boolean because nsDOMClassInfo depended on this behavior.

It's a little weird to have a guaranteed-initialized out parameter coming from the JS engine, so I fixed nsDOMClassInfo to not depend on it, but also initialized the out param in the proxy code to be on the safe side.
Assignee: nobody → mrbkap
Status: NEW → ASSIGNED
Attachment #532885 - Flags: review?(gal)
http://hg.mozilla.org/tracemonkey/rev/57ef10a3d925 (gal sent me an r=him over e-mail as he's without a net connection at the moment).
Whiteboard: fixed-in-tracemonkey
was he in an airplane at the time?
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Attachment #532885 - Flags: review?(gal) → review+
You need to log in before you can comment on or make changes to this bug.