The default bug view has changed. See this FAQ.

instanceof operators doesn't work in a sandbox

RESOLVED FIXED

Status

()

Core
XPConnect
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: Honza, Assigned: mrbkap)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
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
(Assignee)

Comment 2

6 years ago
Created attachment 532885 [details] [diff] [review]
Proposed fix

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)
(Assignee)

Comment 3

6 years ago
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?
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/57ef10a3d925
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED

Updated

5 years ago
Attachment #532885 - Flags: review?(gal) → review+
You need to log in before you can comment on or make changes to this bug.