mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 861530 - unwrap for _content. r=bholley
This commit is contained in:
parent
3e8feafcbd
commit
b3d391f39f
@ -5043,24 +5043,26 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
// compatibility, this should spit out an message on the JS
|
||||
// console.
|
||||
|
||||
JSObject *windowObj = win->GetGlobalJSObject();
|
||||
JSObject* windowObj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
||||
NS_ENSURE_TRUE(windowObj, NS_ERROR_DOM_SECURITY_ERR);
|
||||
|
||||
JSAutoCompartment ac(cx, windowObj);
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
|
||||
windowObj, "_content");
|
||||
if (!fun) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
JSObject *funObj;
|
||||
{
|
||||
JSAutoCompartment ac(cx, windowObj);
|
||||
JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
|
||||
windowObj, "_content");
|
||||
if (!fun) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
funObj = ::JS_GetFunctionObject(fun);
|
||||
}
|
||||
|
||||
JSObject *funObj = ::JS_GetFunctionObject(fun);
|
||||
|
||||
if (!::JS_DefinePropertyById(cx, windowObj, id, JSVAL_VOID,
|
||||
JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj),
|
||||
JS_StrictPropertyStub,
|
||||
JSPROP_ENUMERATE | JSPROP_GETTER |
|
||||
JSPROP_SHARED)) {
|
||||
if (!JS_WrapObject(cx, &funObj) ||
|
||||
!JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
|
||||
JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj),
|
||||
JS_StrictPropertyStub,
|
||||
JSPROP_ENUMERATE | JSPROP_GETTER |
|
||||
JSPROP_SHARED)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
|
||||
function doTest() {
|
||||
var win = $("t").contentWindow;
|
||||
var sandbox = Components.utils.Sandbox(win, { sandboxPrototype: win });
|
||||
|
||||
is(sandbox._content, sandbox.content, "_content and content returned the same thing");
|
||||
|
||||
try {
|
||||
var css = Components.utils.evalInSandbox("CSSStyleDeclaration", sandbox);
|
||||
is(css.prototype, "[object CSSStyleDeclarationPrototype]", "'CSSStyleDeclaration.prototype' in a sandbox should return the CSSStyleDeclaration interface prototype object");
|
||||
|
Loading…
Reference in New Issue
Block a user