Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwrap function before calling IsConstructor #17250

Merged
merged 1 commit into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion components/script/dom/customelementregistry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use dom::window::Window;
use dom_struct::dom_struct;
use html5ever::{LocalName, Namespace, Prefix};
use js::conversions::ToJSValConvertible;
use js::glue::UnwrapObject;
use js::jsapi::{Construct1, IsCallable, IsConstructor, HandleValueArray, HandleObject, MutableHandleValue};
use js::jsapi::{Heap, JS_GetProperty, JSAutoCompartment, JSContext};
use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue};
Expand Down Expand Up @@ -193,7 +194,15 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
let name = LocalName::from(&*name);

// Step 1
if unsafe { !IsConstructor(constructor.get()) } {
// We must unwrap the constructor as all wrappers are constructable if they are callable.
rooted!(in(cx) let unwrapped_constructor = unsafe { UnwrapObject(constructor.get(), 1) });

if unwrapped_constructor.is_null() {
// We do not have permission to access the unwrapped constructor.
return Err(Error::Security);
}

if unsafe { !IsConstructor(unwrapped_constructor.get()) } {
return Err(Error::Type("Second argument of CustomElementRegistry.define is not a constructor".to_owned()));
}

Expand Down

This file was deleted.