Merge pull request #2933 from Ms2ger/initialize_global

Assert that we're handed a DOM global in initialize_global.
This commit is contained in:
Josh Matthews 2014-07-27 10:19:46 -04:00
commit 4b516c184d

View file

@ -410,9 +410,11 @@ pub extern fn ThrowingConstructor(_cx: *mut JSContext, _argc: c_uint, _vp: *mut
}
/// Construct and cache the ProtoOrIfaceArray for the given global.
/// Fails if the argument is not a DOM global.
pub fn initialize_global(global: *mut JSObject) {
let protoArray = box () ([0 as *mut JSObject, ..PrototypeList::id::IDCount as uint]);
unsafe {
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
let box_ = squirrel_away_unique(protoArray);
JS_SetReservedSlot(global,
DOM_PROTOTYPE_SLOT,