mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1491488 - Stop waiving the return value of the Sandbox constructor when wantXrays is false. r=kmag
MozReview-Commit-ID: 9DrgknOT0Z3
This commit is contained in:
parent
d8b5efe2e3
commit
d5bb8045ce
@ -1878,13 +1878,6 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative* wrappe
|
|||||||
return ThrowAndFail(rv, cx, _retval);
|
return ThrowAndFail(rv, cx, _retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have this crazy behavior where wantXrays=false also implies that the
|
|
||||||
// returned sandbox is implicitly waived. We've stopped advertising it, but
|
|
||||||
// keep supporting it for now.
|
|
||||||
if (!options.wantXrays && !xpc::WrapperFactory::WaiveXrayAndWrap(cx, args.rval())) {
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
*_retval = true;
|
*_retval = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596
|
|||||||
|
|
||||||
ok(Cu.evalInSandbox("('foo' in this.document);", sandbox),
|
ok(Cu.evalInSandbox("('foo' in this.document);", sandbox),
|
||||||
"can see expandos");
|
"can see expandos");
|
||||||
ok(("foo" in Cu.evalInSandbox("this.document", sandbox)),
|
ok(!("foo" in Cu.evalInSandbox("this.document", sandbox)),
|
||||||
"must see expandos in wrappers returned from the sandbox");
|
"must not see expandos in wrappers returned from the sandbox");
|
||||||
|
ok(("foo" in Cu.waiveXrays(Cu.evalInSandbox("this.document", sandbox))),
|
||||||
|
"must see expandos in waived wrappers returned from the sandbox");
|
||||||
|
|
||||||
ok(("foo" in sandbox.document),
|
ok(!("foo" in sandbox.document),
|
||||||
|
"must not see expandos in wrappers obtained from the sandbox");
|
||||||
|
ok("foo" in Cu.waiveXrays(sandbox.document),
|
||||||
"must see expandos in wrappers obtained from the sandbox");
|
"must see expandos in wrappers obtained from the sandbox");
|
||||||
|
|
||||||
testDone();
|
testDone();
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
function run_test() {
|
function run_test() {
|
||||||
// We rely on the crazy "wantXrays:false also causes values return from the
|
var sb = new Cu.Sandbox('http://www.example.com');
|
||||||
// sandbox to be waived" behavior, because it's the simplest way to get
|
|
||||||
// waivers out of the sandbox (which has no native objects). :-(
|
|
||||||
var sb = new Cu.Sandbox('http://www.example.com', {wantXrays: false});
|
|
||||||
Cu.evalInSandbox("this.foo = {}; Object.defineProperty(foo, 'bar', {get: function() {return {};}});", sb);
|
Cu.evalInSandbox("this.foo = {}; Object.defineProperty(foo, 'bar', {get: function() {return {};}});", sb);
|
||||||
Assert.ok(sb.foo != XPCNativeWrapper(sb.foo), "sb.foo is waived");
|
var desc = Object.getOwnPropertyDescriptor(Cu.waiveXrays(sb.foo), 'bar');
|
||||||
var desc = Object.getOwnPropertyDescriptor(sb.foo, 'bar');
|
|
||||||
var b = desc.get();
|
var b = desc.get();
|
||||||
Assert.ok(b != XPCNativeWrapper(b), "results from accessor descriptors are waived");
|
Assert.ok(b != XPCNativeWrapper(b), "results from accessor descriptors are waived");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user