diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-09-17 08:01:35 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-09-17 18:42:27 +0200 |
commit | 91f238f3263f8a0080b9f63b808990094f61cd51 (patch) | |
tree | 80eee7e8f066af86f5e5132cfe83061d98d5a08f /components/script/dom/bindings/utils.rs | |
parent | 5281fc1a440a6a179f7f8cb4788a9694904d0520 (diff) | |
download | servo-91f238f3263f8a0080b9f63b808990094f61cd51.tar.gz servo-91f238f3263f8a0080b9f63b808990094f61cd51.zip |
script: Properly throw when "this" is not an object in a generic call.
Diffstat (limited to 'components/script/dom/bindings/utils.rs')
-rw-r--r-- | components/script/dom/bindings/utils.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 1c4682225b0..4a343cbb115 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -414,18 +414,22 @@ unsafe fn generic_call(cx: *mut JSContext, -> bool) -> bool { let args = CallArgs::from_vp(vp, argc); + + let info = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp)); + let proto_id = (*info).protoID; + let thisobj = args.thisv(); if !thisobj.get().is_null_or_undefined() && !thisobj.get().is_object() { + throw_invalid_this(cx, proto_id); return false; } + let obj = if thisobj.get().is_object() { thisobj.get().to_object() } else { GetGlobalForObjectCrossCompartment(JS_CALLEE(cx, vp).to_object_or_null()) }; rooted!(in(cx) let obj = obj); - let info = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp)); - let proto_id = (*info).protoID; let depth = (*info).depth; let proto_check = |class: &'static DOMClass| { class.interface_chain[depth as usize] as u16 == proto_id |