Bug 890081 - Make 'document' permanent in nsIDocument::WrapObject. r=bz

This commit is contained in:
Bobby Holley 2013-07-08 10:31:21 -07:00
parent 873d2309bf
commit aa04d7f824
3 changed files with 19 additions and 7 deletions

View File

@ -11382,7 +11382,7 @@ nsIDocument::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
(doc_str.get()),
doc_str.Length(), JS::ObjectValue(*obj),
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_READONLY | JSPROP_ENUMERATE)) {
JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT)) {
return nullptr;
}

View File

@ -4510,8 +4510,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
false);
NS_ENSURE_SUCCESS(rv, rv);
// The PostCreate hook for the document will handle defining the
// property
// nsIDocument::WrapObject will handle defining the property.
*objp = obj;
// NB: We need to do this for any Xray wrapper.

View File

@ -37,14 +37,27 @@ ok(canDefine, "Should have access to __defineGetter__ and __defineSetter__");
try {
this.__defineGetter__('window', function() {});
ok(false, "should not be able to defineGetter(window)");
} catch (e) {
}
} catch (e) { }
try {
this.__defineGetter__('document', function() {});
ok(false, "should not be able to defineGetter(document)");
} catch (e) { }
try {
this.__defineGetter__.call(window, 'location', function(){});
ok(false, "should not be able to defineGetter(window.location)");
} catch (e) {
}
} catch (e) { }
try {
this.__defineGetter__.call(window, 'document', function(){});
ok(false, "should not be able to defineGetter(window.document)");
} catch (e) { }
try {
this.__defineGetter__.call(document, 'location', function(){});
ok(false, "should not be able to defineGetter(document.location)");
} catch (e) { }
try {
this.__defineGetter__.call(window.location, 'href', function(){});