blob: 4507ed8f7b534c920dec413d7557015fd9a5d1b3 [file] [log] [blame]
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// clang-format off
// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
// Auto-generated from template: bindings/mozjs45/templates/interface.cc.template
#include "cobalt/bindings/testing/mozjs_window.h"
#include "base/debug/trace_event.h"
#include "cobalt/base/polymorphic_downcast.h"
#include "cobalt/script/global_environment.h"
#include "cobalt/script/script_value.h"
#include "cobalt/script/value_handle.h"
#include "cobalt/bindings/testing/anonymous_indexed_getter_interface.h"
#include "cobalt/bindings/testing/anonymous_named_getter_interface.h"
#include "cobalt/bindings/testing/anonymous_named_indexed_getter_interface.h"
#include "cobalt/bindings/testing/arbitrary_interface.h"
#include "cobalt/bindings/testing/base_interface.h"
#include "cobalt/bindings/testing/boolean_type_test_interface.h"
#include "cobalt/bindings/testing/callback_function_interface.h"
#include "cobalt/bindings/testing/callback_interface_interface.h"
#include "cobalt/bindings/testing/conditional_interface.h"
#include "cobalt/bindings/testing/constants_interface.h"
#include "cobalt/bindings/testing/constructor_interface.h"
#include "cobalt/bindings/testing/constructor_with_arguments_interface.h"
#include "cobalt/bindings/testing/convert_simple_object_interface.h"
#include "cobalt/bindings/testing/derived_getter_setter_interface.h"
#include "cobalt/bindings/testing/derived_interface.h"
#include "cobalt/bindings/testing/dictionary_interface.h"
#include "cobalt/bindings/testing/disabled_interface.h"
#include "cobalt/bindings/testing/dom_string_test_interface.h"
#include "cobalt/bindings/testing/enumeration_interface.h"
#include "cobalt/bindings/testing/exception_object_interface.h"
#include "cobalt/bindings/testing/exceptions_interface.h"
#include "cobalt/bindings/testing/extended_idl_attributes_interface.h"
#include "cobalt/bindings/testing/garbage_collection_test_interface.h"
#include "cobalt/bindings/testing/global_interface_parent.h"
#include "cobalt/bindings/testing/implemented_interface.h"
#include "cobalt/bindings/testing/indexed_getter_interface.h"
#include "cobalt/bindings/testing/interface_with_any.h"
#include "cobalt/bindings/testing/interface_with_any_dictionary.h"
#include "cobalt/bindings/testing/interface_with_date.h"
#include "cobalt/bindings/testing/interface_with_unsupported_properties.h"
#include "cobalt/bindings/testing/mozjs_anonymous_indexed_getter_interface.h"
#include "cobalt/bindings/testing/mozjs_anonymous_named_getter_interface.h"
#include "cobalt/bindings/testing/mozjs_anonymous_named_indexed_getter_interface.h"
#include "cobalt/bindings/testing/mozjs_arbitrary_interface.h"
#include "cobalt/bindings/testing/mozjs_base_interface.h"
#include "cobalt/bindings/testing/mozjs_boolean_type_test_interface.h"
#include "cobalt/bindings/testing/mozjs_callback_function_interface.h"
#include "cobalt/bindings/testing/mozjs_callback_interface_interface.h"
#include "cobalt/bindings/testing/mozjs_conditional_interface.h"
#include "cobalt/bindings/testing/mozjs_constants_interface.h"
#include "cobalt/bindings/testing/mozjs_constructor_interface.h"
#include "cobalt/bindings/testing/mozjs_constructor_with_arguments_interface.h"
#include "cobalt/bindings/testing/mozjs_convert_simple_object_interface.h"
#include "cobalt/bindings/testing/mozjs_derived_getter_setter_interface.h"
#include "cobalt/bindings/testing/mozjs_derived_interface.h"
#include "cobalt/bindings/testing/mozjs_dictionary_interface.h"
#include "cobalt/bindings/testing/mozjs_disabled_interface.h"
#include "cobalt/bindings/testing/mozjs_dom_string_test_interface.h"
#include "cobalt/bindings/testing/mozjs_enumeration_interface.h"
#include "cobalt/bindings/testing/mozjs_exception_object_interface.h"
#include "cobalt/bindings/testing/mozjs_exceptions_interface.h"
#include "cobalt/bindings/testing/mozjs_extended_idl_attributes_interface.h"
#include "cobalt/bindings/testing/mozjs_garbage_collection_test_interface.h"
#include "cobalt/bindings/testing/mozjs_global_interface_parent.h"
#include "cobalt/bindings/testing/mozjs_implemented_interface.h"
#include "cobalt/bindings/testing/mozjs_indexed_getter_interface.h"
#include "cobalt/bindings/testing/mozjs_interface_with_any.h"
#include "cobalt/bindings/testing/mozjs_interface_with_any_dictionary.h"
#include "cobalt/bindings/testing/mozjs_interface_with_date.h"
#include "cobalt/bindings/testing/mozjs_interface_with_unsupported_properties.h"
#include "cobalt/bindings/testing/mozjs_named_constructor_interface.h"
#include "cobalt/bindings/testing/mozjs_named_getter_interface.h"
#include "cobalt/bindings/testing/mozjs_named_indexed_getter_interface.h"
#include "cobalt/bindings/testing/mozjs_nested_put_forwards_interface.h"
#include "cobalt/bindings/testing/mozjs_no_constructor_interface.h"
#include "cobalt/bindings/testing/mozjs_no_interface_object_interface.h"
#include "cobalt/bindings/testing/mozjs_nullable_types_test_interface.h"
#include "cobalt/bindings/testing/mozjs_numeric_types_test_interface.h"
#include "cobalt/bindings/testing/mozjs_object_type_bindings_interface.h"
#include "cobalt/bindings/testing/mozjs_operations_test_interface.h"
#include "cobalt/bindings/testing/mozjs_promise_interface.h"
#include "cobalt/bindings/testing/mozjs_put_forwards_interface.h"
#include "cobalt/bindings/testing/mozjs_sequence_user.h"
#include "cobalt/bindings/testing/mozjs_single_operation_interface.h"
#include "cobalt/bindings/testing/mozjs_static_properties_interface.h"
#include "cobalt/bindings/testing/mozjs_stringifier_anonymous_operation_interface.h"
#include "cobalt/bindings/testing/mozjs_stringifier_attribute_interface.h"
#include "cobalt/bindings/testing/mozjs_stringifier_operation_interface.h"
#include "cobalt/bindings/testing/mozjs_target_interface.h"
#include "cobalt/bindings/testing/mozjs_union_types_interface.h"
#include "cobalt/bindings/testing/mozjs_window.h"
#include "cobalt/bindings/testing/named_constructor_interface.h"
#include "cobalt/bindings/testing/named_getter_interface.h"
#include "cobalt/bindings/testing/named_indexed_getter_interface.h"
#include "cobalt/bindings/testing/nested_put_forwards_interface.h"
#include "cobalt/bindings/testing/no_constructor_interface.h"
#include "cobalt/bindings/testing/no_interface_object_interface.h"
#include "cobalt/bindings/testing/nullable_types_test_interface.h"
#include "cobalt/bindings/testing/numeric_types_test_interface.h"
#include "cobalt/bindings/testing/object_type_bindings_interface.h"
#include "cobalt/bindings/testing/operations_test_interface.h"
#include "cobalt/bindings/testing/promise_interface.h"
#include "cobalt/bindings/testing/put_forwards_interface.h"
#include "cobalt/bindings/testing/sequence_user.h"
#include "cobalt/bindings/testing/single_operation_interface.h"
#include "cobalt/bindings/testing/static_properties_interface.h"
#include "cobalt/bindings/testing/stringifier_anonymous_operation_interface.h"
#include "cobalt/bindings/testing/stringifier_attribute_interface.h"
#include "cobalt/bindings/testing/stringifier_operation_interface.h"
#include "cobalt/bindings/testing/target_interface.h"
#include "cobalt/bindings/testing/union_types_interface.h"
#include "cobalt/bindings/testing/window.h"
#include "mozjs_gen_type_conversion.h"
#include "base/lazy_instance.h"
#include "cobalt/script/exception_state.h"
#include "cobalt/script/mozjs-45/callback_function_conversion.h"
#include "cobalt/script/mozjs-45/conversion_helpers.h"
#include "cobalt/script/mozjs-45/mozjs_callback_function.h"
#include "cobalt/script/mozjs-45/mozjs_exception_state.h"
#include "cobalt/script/mozjs-45/mozjs_global_environment.h"
#include "cobalt/script/mozjs-45/mozjs_property_enumerator.h"
#include "cobalt/script/mozjs-45/mozjs_user_object_holder.h"
#include "cobalt/script/mozjs-45/mozjs_value_handle.h"
#include "cobalt/script/mozjs-45/native_promise.h"
#include "cobalt/script/mozjs-45/proxy_handler.h"
#include "cobalt/script/mozjs-45/type_traits.h"
#include "cobalt/script/mozjs-45/wrapper_factory.h"
#include "cobalt/script/mozjs-45/wrapper_private.h"
#include "cobalt/script/property_enumerator.h"
#include "cobalt/script/sequence.h"
#include "third_party/mozjs-45/js/src/jsapi.h"
#include "third_party/mozjs-45/js/src/jsfriendapi.h"
namespace {
using cobalt::bindings::testing::Window;
using cobalt::bindings::testing::MozjsWindow;
using cobalt::bindings::testing::AnonymousIndexedGetterInterface;
using cobalt::bindings::testing::AnonymousNamedGetterInterface;
using cobalt::bindings::testing::AnonymousNamedIndexedGetterInterface;
using cobalt::bindings::testing::ArbitraryInterface;
using cobalt::bindings::testing::BaseInterface;
using cobalt::bindings::testing::BooleanTypeTestInterface;
using cobalt::bindings::testing::CallbackFunctionInterface;
using cobalt::bindings::testing::CallbackInterfaceInterface;
#if defined(ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::ConditionalInterface;
#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::ConstantsInterface;
using cobalt::bindings::testing::ConstructorInterface;
using cobalt::bindings::testing::ConstructorWithArgumentsInterface;
using cobalt::bindings::testing::ConvertSimpleObjectInterface;
using cobalt::bindings::testing::DOMStringTestInterface;
using cobalt::bindings::testing::DerivedGetterSetterInterface;
using cobalt::bindings::testing::DerivedInterface;
using cobalt::bindings::testing::DictionaryInterface;
#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::DisabledInterface;
#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::EnumerationInterface;
using cobalt::bindings::testing::ExceptionObjectInterface;
using cobalt::bindings::testing::ExceptionsInterface;
using cobalt::bindings::testing::ExtendedIDLAttributesInterface;
using cobalt::bindings::testing::GarbageCollectionTestInterface;
using cobalt::bindings::testing::GlobalInterfaceParent;
using cobalt::bindings::testing::ImplementedInterface;
using cobalt::bindings::testing::IndexedGetterInterface;
using cobalt::bindings::testing::InterfaceWithAny;
using cobalt::bindings::testing::InterfaceWithAnyDictionary;
using cobalt::bindings::testing::InterfaceWithDate;
using cobalt::bindings::testing::InterfaceWithUnsupportedProperties;
using cobalt::bindings::testing::MozjsAnonymousIndexedGetterInterface;
using cobalt::bindings::testing::MozjsAnonymousNamedGetterInterface;
using cobalt::bindings::testing::MozjsAnonymousNamedIndexedGetterInterface;
using cobalt::bindings::testing::MozjsArbitraryInterface;
using cobalt::bindings::testing::MozjsBaseInterface;
using cobalt::bindings::testing::MozjsBooleanTypeTestInterface;
using cobalt::bindings::testing::MozjsCallbackFunctionInterface;
using cobalt::bindings::testing::MozjsCallbackInterfaceInterface;
#if defined(ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::MozjsConditionalInterface;
#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::MozjsConstantsInterface;
using cobalt::bindings::testing::MozjsConstructorInterface;
using cobalt::bindings::testing::MozjsConstructorWithArgumentsInterface;
using cobalt::bindings::testing::MozjsConvertSimpleObjectInterface;
using cobalt::bindings::testing::MozjsDOMStringTestInterface;
using cobalt::bindings::testing::MozjsDerivedGetterSetterInterface;
using cobalt::bindings::testing::MozjsDerivedInterface;
using cobalt::bindings::testing::MozjsDictionaryInterface;
#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::MozjsDisabledInterface;
#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::MozjsEnumerationInterface;
using cobalt::bindings::testing::MozjsExceptionObjectInterface;
using cobalt::bindings::testing::MozjsExceptionsInterface;
using cobalt::bindings::testing::MozjsExtendedIDLAttributesInterface;
using cobalt::bindings::testing::MozjsGarbageCollectionTestInterface;
using cobalt::bindings::testing::MozjsGlobalInterfaceParent;
using cobalt::bindings::testing::MozjsImplementedInterface;
using cobalt::bindings::testing::MozjsIndexedGetterInterface;
using cobalt::bindings::testing::MozjsInterfaceWithAny;
using cobalt::bindings::testing::MozjsInterfaceWithAnyDictionary;
using cobalt::bindings::testing::MozjsInterfaceWithDate;
using cobalt::bindings::testing::MozjsInterfaceWithUnsupportedProperties;
using cobalt::bindings::testing::MozjsNamedConstructorInterface;
using cobalt::bindings::testing::MozjsNamedGetterInterface;
using cobalt::bindings::testing::MozjsNamedIndexedGetterInterface;
using cobalt::bindings::testing::MozjsNestedPutForwardsInterface;
using cobalt::bindings::testing::MozjsNoConstructorInterface;
using cobalt::bindings::testing::MozjsNoInterfaceObjectInterface;
using cobalt::bindings::testing::MozjsNullableTypesTestInterface;
using cobalt::bindings::testing::MozjsNumericTypesTestInterface;
using cobalt::bindings::testing::MozjsObjectTypeBindingsInterface;
using cobalt::bindings::testing::MozjsOperationsTestInterface;
using cobalt::bindings::testing::MozjsPromiseInterface;
using cobalt::bindings::testing::MozjsPutForwardsInterface;
using cobalt::bindings::testing::MozjsSequenceUser;
using cobalt::bindings::testing::MozjsSingleOperationInterface;
using cobalt::bindings::testing::MozjsStaticPropertiesInterface;
using cobalt::bindings::testing::MozjsStringifierAnonymousOperationInterface;
using cobalt::bindings::testing::MozjsStringifierAttributeInterface;
using cobalt::bindings::testing::MozjsStringifierOperationInterface;
using cobalt::bindings::testing::MozjsTargetInterface;
using cobalt::bindings::testing::MozjsUnionTypesInterface;
using cobalt::bindings::testing::MozjsWindow;
using cobalt::bindings::testing::NamedConstructorInterface;
using cobalt::bindings::testing::NamedGetterInterface;
using cobalt::bindings::testing::NamedIndexedGetterInterface;
using cobalt::bindings::testing::NestedPutForwardsInterface;
using cobalt::bindings::testing::NoConstructorInterface;
using cobalt::bindings::testing::NoInterfaceObjectInterface;
using cobalt::bindings::testing::NullableTypesTestInterface;
using cobalt::bindings::testing::NumericTypesTestInterface;
using cobalt::bindings::testing::ObjectTypeBindingsInterface;
using cobalt::bindings::testing::OperationsTestInterface;
using cobalt::bindings::testing::PromiseInterface;
using cobalt::bindings::testing::PutForwardsInterface;
using cobalt::bindings::testing::SequenceUser;
using cobalt::bindings::testing::SingleOperationInterface;
using cobalt::bindings::testing::StaticPropertiesInterface;
using cobalt::bindings::testing::StringifierAnonymousOperationInterface;
using cobalt::bindings::testing::StringifierAttributeInterface;
using cobalt::bindings::testing::StringifierOperationInterface;
using cobalt::bindings::testing::TargetInterface;
using cobalt::bindings::testing::UnionTypesInterface;
using cobalt::bindings::testing::Window;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::GlobalEnvironment;
using cobalt::script::ScriptValue;
using cobalt::script::ValueHandle;
using cobalt::script::ValueHandle;
using cobalt::script::ValueHandleHolder;
using cobalt::script::Wrappable;
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
using cobalt::script::mozjs::InterfaceData;
using cobalt::script::mozjs::MozjsCallbackFunction;
using cobalt::script::mozjs::MozjsExceptionState;
using cobalt::script::mozjs::MozjsGlobalEnvironment;
using cobalt::script::mozjs::MozjsPropertyEnumerator;
using cobalt::script::mozjs::MozjsUserObjectHolder;
using cobalt::script::mozjs::ProxyHandler;
using cobalt::script::mozjs::ToJSValue;
using cobalt::script::mozjs::TypeTraits;
using cobalt::script::mozjs::WrapperFactory;
using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagClamped;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kConversionFlagObjectOnly;
using cobalt::script::mozjs::kNoConversionFlags;
JSObject* DummyFunctor(
JSContext* context, const scoped_refptr<Wrappable>& wrappable) {
NOTREACHED();
return NULL;
}
} // namespace
namespace cobalt {
namespace bindings {
namespace testing {
namespace {
class MozjsWindowHandler : public ProxyHandler {
public:
MozjsWindowHandler()
: ProxyHandler(indexed_property_hooks, named_property_hooks) {}
private:
static NamedPropertyHooks named_property_hooks;
static IndexedPropertyHooks indexed_property_hooks;
};
ProxyHandler::NamedPropertyHooks
MozjsWindowHandler::named_property_hooks = {
NULL,
NULL,
NULL,
NULL,
NULL,
};
ProxyHandler::IndexedPropertyHooks
MozjsWindowHandler::indexed_property_hooks = {
NULL,
NULL,
NULL,
NULL,
NULL,
};
static base::LazyInstance<MozjsWindowHandler>
proxy_handler;
bool DummyConstructor(JSContext* context, unsigned int argc, JS::Value* vp) {
MozjsExceptionState exception(context);
exception.SetSimpleException(
script::kTypeError, "Window is not constructible.");
return false;
}
bool HasInstance(JSContext *context, JS::HandleObject type,
JS::MutableHandleValue vp, bool *success) {
JS::RootedObject global_object(
context, JS_GetGlobalForObject(context, type));
DCHECK(global_object);
JS::RootedObject prototype(
context, MozjsWindow::GetPrototype(context, global_object));
// |IsDelegate| walks the prototype chain of an object returning true if
// .prototype is found.
bool is_delegate;
if (!IsDelegate(context, prototype, vp, &is_delegate)) {
*success = false;
return false;
}
*success = is_delegate;
return true;
}
const JSClass instance_class_definition = {
"Window",
JSCLASS_GLOBAL_FLAGS | JSCLASS_HAS_PRIVATE,
NULL, // addProperty
NULL, // delProperty
NULL, // getProperty
NULL, // setProperty
NULL, // enumerate
NULL, // resolve
NULL, // mayResolve
&WrapperPrivate::Finalizer, // finalize
NULL, // call
NULL, // hasInstance
NULL, // construct
JS_GlobalObjectTraceHook, // trace
};
const JSClass prototype_class_definition = {
"WindowPrototype",
};
const JSClass interface_object_class_definition = {
"WindowConstructor",
0,
NULL, // addProperty
NULL, // delProperty
NULL, // getProperty
NULL, // setProperty
NULL, // enumerate
NULL, // resolve
NULL, // mayResolve
NULL, // finalize
NULL, // call
&HasInstance,
NULL,
};
bool get_windowProperty(
JSContext* context, unsigned argc, JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (!args.thisv().isObject()) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kTypeError, "Invalid this.");
return false;
}
JS::RootedObject object(context, &args.thisv().toObject());
const JSClass* proto_class =
MozjsWindow::PrototypeClass(context);
if (proto_class == JS_GetClass(object)) {
// Simply returns true if the object is this class's prototype object.
// There is no need to return any value due to the object is not a platform
// object. The execution reaches here when Object.getOwnPropertyDescriptor
// gets called on native object prototypes.
return true;
}
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
WrapperFactory* wrapper_factory = global_environment->wrapper_factory();
if (!wrapper_factory->DoesObjectImplementInterface(
object, base::GetTypeId<Window>())) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kDoesNotImplementInterface);
return false;
}
MozjsExceptionState exception_state(context);
JS::RootedValue result_value(context);
WrapperPrivate* wrapper_private =
WrapperPrivate::GetFromObject(context, object);
Window* impl =
wrapper_private->wrappable<Window>().get();
if (!exception_state.is_exception_set()) {
ToJSValue(context,
impl->window_property(),
&result_value);
}
if (!exception_state.is_exception_set()) {
args.rval().set(result_value);
}
return !exception_state.is_exception_set();
}
bool set_windowProperty(
JSContext* context, unsigned argc, JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (!args.thisv().isObject()) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kTypeError, "Invalid this.");
return false;
}
JS::RootedObject object(context, &args.thisv().toObject());
const JSClass* proto_class =
MozjsWindow::PrototypeClass(context);
if (proto_class == JS_GetClass(object)) {
// Simply returns true if the object is this class's prototype object.
// There is no need to return any value due to the object is not a platform
// object. The execution reaches here when Object.getOwnPropertyDescriptor
// gets called on native object prototypes.
return true;
}
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
WrapperFactory* wrapper_factory = global_environment->wrapper_factory();
if (!wrapper_factory->DoesObjectImplementInterface(
object, base::GetTypeId<Window>())) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kDoesNotImplementInterface);
return false;
}
MozjsExceptionState exception_state(context);
JS::RootedValue result_value(context);
WrapperPrivate* wrapper_private =
WrapperPrivate::GetFromObject(context, object);
Window* impl =
wrapper_private->wrappable<Window>().get();
TypeTraits<std::string >::ConversionType value;
if (args.length() != 1) {
NOTREACHED();
return false;
}
FromJSValue(context, args[0], kNoConversionFlags, &exception_state,
&value);
if (exception_state.is_exception_set()) {
return false;
}
impl->set_window_property(value);
result_value.set(JS::UndefinedHandleValue);
return !exception_state.is_exception_set();
}
bool get_window(
JSContext* context, unsigned argc, JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (!args.thisv().isObject()) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kTypeError, "Invalid this.");
return false;
}
JS::RootedObject object(context, &args.thisv().toObject());
const JSClass* proto_class =
MozjsWindow::PrototypeClass(context);
if (proto_class == JS_GetClass(object)) {
// Simply returns true if the object is this class's prototype object.
// There is no need to return any value due to the object is not a platform
// object. The execution reaches here when Object.getOwnPropertyDescriptor
// gets called on native object prototypes.
return true;
}
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
WrapperFactory* wrapper_factory = global_environment->wrapper_factory();
if (!wrapper_factory->DoesObjectImplementInterface(
object, base::GetTypeId<Window>())) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kDoesNotImplementInterface);
return false;
}
MozjsExceptionState exception_state(context);
JS::RootedValue result_value(context);
WrapperPrivate* wrapper_private =
WrapperPrivate::GetFromObject(context, object);
Window* impl =
wrapper_private->wrappable<Window>().get();
if (!exception_state.is_exception_set()) {
ToJSValue(context,
impl->window(),
&result_value);
}
if (!exception_state.is_exception_set()) {
args.rval().set(result_value);
}
return !exception_state.is_exception_set();
}
bool get_onEvent(
JSContext* context, unsigned argc, JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (!args.thisv().isObject()) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kTypeError, "Invalid this.");
return false;
}
JS::RootedObject object(context, &args.thisv().toObject());
const JSClass* proto_class =
MozjsWindow::PrototypeClass(context);
if (proto_class == JS_GetClass(object)) {
// Simply returns true if the object is this class's prototype object.
// There is no need to return any value due to the object is not a platform
// object. The execution reaches here when Object.getOwnPropertyDescriptor
// gets called on native object prototypes.
return true;
}
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
WrapperFactory* wrapper_factory = global_environment->wrapper_factory();
if (!wrapper_factory->DoesObjectImplementInterface(
object, base::GetTypeId<Window>())) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kDoesNotImplementInterface);
return false;
}
MozjsExceptionState exception_state(context);
JS::RootedValue result_value(context);
WrapperPrivate* wrapper_private =
WrapperPrivate::GetFromObject(context, object);
Window* impl =
wrapper_private->wrappable<Window>().get();
if (!exception_state.is_exception_set()) {
ToJSValue(context,
impl->on_event(),
&result_value);
}
if (!exception_state.is_exception_set()) {
args.rval().set(result_value);
}
return !exception_state.is_exception_set();
}
bool set_onEvent(
JSContext* context, unsigned argc, JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (!args.thisv().isObject()) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kTypeError, "Invalid this.");
return false;
}
JS::RootedObject object(context, &args.thisv().toObject());
const JSClass* proto_class =
MozjsWindow::PrototypeClass(context);
if (proto_class == JS_GetClass(object)) {
// Simply returns true if the object is this class's prototype object.
// There is no need to return any value due to the object is not a platform
// object. The execution reaches here when Object.getOwnPropertyDescriptor
// gets called on native object prototypes.
return true;
}
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
WrapperFactory* wrapper_factory = global_environment->wrapper_factory();
if (!wrapper_factory->DoesObjectImplementInterface(
object, base::GetTypeId<Window>())) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kDoesNotImplementInterface);
return false;
}
MozjsExceptionState exception_state(context);
JS::RootedValue result_value(context);
WrapperPrivate* wrapper_private =
WrapperPrivate::GetFromObject(context, object);
Window* impl =
wrapper_private->wrappable<Window>().get();
TypeTraits<::cobalt::script::CallbackInterfaceTraits<SingleOperationInterface > >::ConversionType value;
if (args.length() != 1) {
NOTREACHED();
return false;
}
FromJSValue(context, args[0], (kConversionFlagNullable), &exception_state,
&value);
if (exception_state.is_exception_set()) {
return false;
}
impl->set_on_event(value);
result_value.set(JS::UndefinedHandleValue);
return !exception_state.is_exception_set();
}
bool fcn_getStackTrace(
JSContext* context, uint32_t argc, JS::Value *vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
// Compute the 'this' value.
JS::RootedValue this_value(context, JS_ComputeThis(context, vp));
// 'this' should be an object.
JS::RootedObject object(context);
if (JS_TypeOfValue(context, this_value) != JSTYPE_OBJECT) {
return false;
}
if (!JS_ValueToObject(context, this_value, &object)) {
NOTREACHED();
return false;
}
const JSClass* proto_class =
MozjsWindow::PrototypeClass(context);
if (proto_class == JS_GetClass(object)) {
// Simply returns true if the object is this class's prototype object.
// There is no need to return any value due to the object is not a platform
// object. The execution reaches here when Object.getOwnPropertyDescriptor
// gets called on native object prototypes.
return true;
}
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
WrapperFactory* wrapper_factory = global_environment->wrapper_factory();
if (!wrapper_factory->DoesObjectImplementInterface(
object, base::GetTypeId<Window>())) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kDoesNotImplementInterface);
return false;
}
MozjsExceptionState exception_state(context);
JS::RootedValue result_value(context);
WrapperPrivate* wrapper_private =
WrapperPrivate::GetFromObject(context, object);
Window* impl =
wrapper_private->wrappable<Window>().get();
MozjsGlobalEnvironment* callwith_global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
if (!exception_state.is_exception_set()) {
ToJSValue(context,
impl->GetStackTrace(callwith_global_environment->GetStackTrace()),
&result_value);
}
if (!exception_state.is_exception_set()) {
args.rval().set(result_value);
}
return !exception_state.is_exception_set();
}
bool fcn_setTimeout(
JSContext* context, uint32_t argc, JS::Value *vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
// Compute the 'this' value.
JS::RootedValue this_value(context, JS_ComputeThis(context, vp));
// 'this' should be an object.
JS::RootedObject object(context);
if (JS_TypeOfValue(context, this_value) != JSTYPE_OBJECT) {
return false;
}
if (!JS_ValueToObject(context, this_value, &object)) {
NOTREACHED();
return false;
}
const JSClass* proto_class =
MozjsWindow::PrototypeClass(context);
if (proto_class == JS_GetClass(object)) {
// Simply returns true if the object is this class's prototype object.
// There is no need to return any value due to the object is not a platform
// object. The execution reaches here when Object.getOwnPropertyDescriptor
// gets called on native object prototypes.
return true;
}
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
WrapperFactory* wrapper_factory = global_environment->wrapper_factory();
if (!wrapper_factory->DoesObjectImplementInterface(
object, base::GetTypeId<Window>())) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kDoesNotImplementInterface);
return false;
}
MozjsExceptionState exception_state(context);
JS::RootedValue result_value(context);
WrapperPrivate* wrapper_private =
WrapperPrivate::GetFromObject(context, object);
Window* impl =
wrapper_private->wrappable<Window>().get();
const size_t kMinArguments = 1;
if (args.length() < kMinArguments) {
exception_state.SetSimpleException(script::kInvalidNumberOfArguments);
return false;
}
// Non-optional arguments
TypeTraits<Window::TimerCallback >::ConversionType handler;
// Optional arguments
TypeTraits<int32_t >::ConversionType timeout;
DCHECK_LT(0, args.length());
JS::RootedValue non_optional_value0(
context, args[0]);
FromJSValue(context,
non_optional_value0,
kNoConversionFlags,
&exception_state, &handler);
if (exception_state.is_exception_set()) {
return false;
}
size_t num_set_arguments = 1;
if (args.length() > 1) {
JS::RootedValue optional_value0(
context, args[1]);
FromJSValue(context,
optional_value0,
kNoConversionFlags,
&exception_state,
&timeout);
if (exception_state.is_exception_set()) {
return false;
}
++num_set_arguments;
}
switch (num_set_arguments) {
case 1:
{
if (!exception_state.is_exception_set()) {
ToJSValue(context,
impl->SetTimeout(handler),
&result_value);
}
if (!exception_state.is_exception_set()) {
args.rval().set(result_value);
}
return !exception_state.is_exception_set();
}
break;
case 2:
{
if (!exception_state.is_exception_set()) {
ToJSValue(context,
impl->SetTimeout(handler, timeout),
&result_value);
}
if (!exception_state.is_exception_set()) {
args.rval().set(result_value);
}
return !exception_state.is_exception_set();
}
break;
default:
NOTREACHED();
return false;
}
}
bool fcn_windowOperation(
JSContext* context, uint32_t argc, JS::Value *vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
// Compute the 'this' value.
JS::RootedValue this_value(context, JS_ComputeThis(context, vp));
// 'this' should be an object.
JS::RootedObject object(context);
if (JS_TypeOfValue(context, this_value) != JSTYPE_OBJECT) {
return false;
}
if (!JS_ValueToObject(context, this_value, &object)) {
NOTREACHED();
return false;
}
const JSClass* proto_class =
MozjsWindow::PrototypeClass(context);
if (proto_class == JS_GetClass(object)) {
// Simply returns true if the object is this class's prototype object.
// There is no need to return any value due to the object is not a platform
// object. The execution reaches here when Object.getOwnPropertyDescriptor
// gets called on native object prototypes.
return true;
}
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
WrapperFactory* wrapper_factory = global_environment->wrapper_factory();
if (!wrapper_factory->DoesObjectImplementInterface(
object, base::GetTypeId<Window>())) {
MozjsExceptionState exception(context);
exception.SetSimpleException(script::kDoesNotImplementInterface);
return false;
}
MozjsExceptionState exception_state(context);
JS::RootedValue result_value(context);
WrapperPrivate* wrapper_private =
WrapperPrivate::GetFromObject(context, object);
Window* impl =
wrapper_private->wrappable<Window>().get();
impl->WindowOperation();
result_value.set(JS::UndefinedHandleValue);
return !exception_state.is_exception_set();
}
const JSPropertySpec prototype_properties[] = {
{ // Read/Write property
"windowProperty",
JSPROP_SHARED | JSPROP_ENUMERATE,
{ { &get_windowProperty, NULL } },
{ { &set_windowProperty, NULL } },
},
{ // Readonly attribute
"window",
JSPROP_SHARED | JSPROP_ENUMERATE,
{ { &get_window, NULL } },
JSNATIVE_WRAPPER(NULL),
},
{ // Read/Write property
"onEvent",
JSPROP_SHARED | JSPROP_ENUMERATE,
{ { &get_onEvent, NULL } },
{ { &set_onEvent, NULL } },
},
JS_PS_END
};
const JSFunctionSpec prototype_functions[] = {
JS_FNSPEC(
"getStackTrace", fcn_getStackTrace, NULL,
0, JSPROP_ENUMERATE, NULL),
JS_FNSPEC(
"setTimeout", fcn_setTimeout, NULL,
1, JSPROP_ENUMERATE, NULL),
JS_FNSPEC(
"windowOperation", fcn_windowOperation, NULL,
0, JSPROP_ENUMERATE, NULL),
JS_FS_END
};
const JSPropertySpec interface_object_properties[] = {
JS_PS_END
};
const JSFunctionSpec interface_object_functions[] = {
JS_FS_END
};
const JSPropertySpec own_properties[] = {
JS_PS_END
};
void InitializePrototypeAndInterfaceObject(
InterfaceData* interface_data, JSContext* context,
JS::HandleObject global_object) {
DCHECK(!interface_data->prototype);
DCHECK(!interface_data->interface_object);
DCHECK(JS_IsGlobalObject(global_object));
JS::RootedObject parent_prototype(
context, MozjsGlobalInterfaceParent::GetPrototype(context, global_object));
static_assert(
std::is_base_of<GlobalInterfaceParent, Window>::value,
"Expected Window to have C++ parent class "
"GlobalInterfaceParent, because that is its WebIDL parent.");
DCHECK(parent_prototype);
interface_data->prototype = JS_NewObjectWithGivenProto(
context, &prototype_class_definition, parent_prototype
);
JS::RootedObject rooted_prototype(context, interface_data->prototype);
bool success = JS_DefineProperties(
context,
rooted_prototype,
prototype_properties);
DCHECK(success);
success = JS_DefineFunctions(
context, rooted_prototype, prototype_functions);
DCHECK(success);
JS::RootedObject function_prototype(
context, JS_GetFunctionPrototype(context, global_object));
DCHECK(function_prototype);
const char name[] =
"Window";
JSFunction* function = js::NewFunctionWithReserved(
context,
DummyConstructor,
0,
JSFUN_CONSTRUCTOR,
name);
interface_data->interface_object = JS_GetFunctionObject(function);
// Add the InterfaceObject.name property.
JS::RootedObject rooted_interface_object(
context, interface_data->interface_object);
JS::RootedValue name_value(context);
js::SetPrototype(context, rooted_interface_object, function_prototype);
name_value.setString(JS_NewStringCopyZ(context, name));
success = JS_DefineProperty(
context, rooted_interface_object, "name", name_value, JSPROP_READONLY,
NULL, NULL);
DCHECK(success);
// Define interface object properties (including constants).
success = JS_DefineProperties(context, rooted_interface_object,
interface_object_properties);
DCHECK(success);
// Define interface object functions (static).
success = JS_DefineFunctions(context, rooted_interface_object,
interface_object_functions);
DCHECK(success);
// Set the Prototype.constructor and Constructor.prototype properties.
DCHECK(interface_data->interface_object);
DCHECK(interface_data->prototype);
success = JS_LinkConstructorAndPrototype(
context,
rooted_interface_object,
rooted_prototype);
DCHECK(success);
}
inline InterfaceData* GetInterfaceData(JSContext* context) {
const int kInterfaceUniqueId = 54;
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
// By convention, the |MozjsGlobalEnvironment| that we are associated with
// will hold our |InterfaceData| at index |kInterfaceUniqueId|, as we asked
// for it to be there in the first place, and could not have conflicted with
// any other interface.
return global_environment->GetInterfaceData(kInterfaceUniqueId);
}
} // namespace
JSObject* MozjsWindow::CreateProxy(
JSContext* context, const scoped_refptr<Wrappable>& wrappable) {
InterfaceData* interface_data = GetInterfaceData(context);
JS::RootedObject global_object(
context, JS_NewGlobalObject(context,
&instance_class_definition, NULL,
JS::FireOnNewGlobalHook,
JS::CompartmentOptions().setTrace(WrapperPrivate::Trace)));
DCHECK(global_object);
// Initialize standard JS constructors prototypes and top-level functions such
// as Object, isNan, etc.
JSAutoCompartment auto_compartment(context, global_object);
bool success = JS_InitStandardClasses(context, global_object);
DCHECK(success);
JS::RootedObject prototype(
context, MozjsWindow::GetPrototype(context, global_object));
DCHECK(prototype);
JS_SetPrototype(context, global_object, prototype);
JS_SetImmutablePrototype(context, global_object, &success);
DCHECK(success);
// Add own properties.
success = JS_DefineProperties(context, global_object, own_properties);
DCHECK(success);
JS::RootedObject proxy(context,
ProxyHandler::NewProxy(
context, proxy_handler.Pointer(), global_object, prototype));
WrapperPrivate::AddPrivateData(context, proxy, wrappable);
// Set the global object proxy pointer, so we can access the standard classes
// such as the base Object prototype when looking up our prototype.
MozjsGlobalEnvironment* global_environment =
static_cast<MozjsGlobalEnvironment*>(JS_GetContextPrivate(context));
global_environment->SetGlobalObjectProxyAndWrapper(proxy, wrappable);
return proxy;
}
// static
const JSClass* MozjsWindow::PrototypeClass(
JSContext* context) {
DCHECK(MozjsGlobalEnvironment::GetFromContext(context));
JS::RootedObject global_object(
context,
MozjsGlobalEnvironment::GetFromContext(context)->global_object());
DCHECK(global_object);
JS::RootedObject prototype(context, GetPrototype(context, global_object));
const JSClass* proto_class = JS_GetClass(prototype);
return proto_class;
}
// static
JSObject* MozjsWindow::GetPrototype(
JSContext* context, JS::HandleObject global_object) {
DCHECK(JS_IsGlobalObject(global_object));
InterfaceData* interface_data = GetInterfaceData(context);
if (!interface_data->prototype) {
// Create new prototype that has all the props and methods
InitializePrototypeAndInterfaceObject(
interface_data, context, global_object);
}
DCHECK(interface_data->prototype);
return interface_data->prototype;
}
// static
JSObject* MozjsWindow::GetInterfaceObject(
JSContext* context, JS::HandleObject global_object) {
DCHECK(JS_IsGlobalObject(global_object));
InterfaceData* interface_data = GetInterfaceData(context);
if (!interface_data->interface_object) {
InitializePrototypeAndInterfaceObject(
interface_data, context, global_object);
}
DCHECK(interface_data->interface_object);
return interface_data->interface_object;
}
namespace {
} // namespace
} // namespace testing
} // namespace bindings
} // namespace cobalt
namespace cobalt {
namespace script {
namespace mozjs {
template <typename GlobalInterface>
void MozjsGlobalEnvironment::CreateGlobalObject(
const scoped_refptr<GlobalInterface>& global_interface,
EnvironmentSettings* environment_settings) {
JSAutoRequest auto_request(context_);
MozjsWindow::CreateProxy(context_, global_interface);
DCHECK(!environment_settings_);
DCHECK(environment_settings);
environment_settings_ = environment_settings;
EvaluateAutomatics();
wrapper_factory_->RegisterWrappableType(
AnonymousIndexedGetterInterface::AnonymousIndexedGetterInterfaceWrappableType(),
base::Bind(MozjsAnonymousIndexedGetterInterface::CreateProxy),
base::Bind(MozjsAnonymousIndexedGetterInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
AnonymousNamedGetterInterface::AnonymousNamedGetterInterfaceWrappableType(),
base::Bind(MozjsAnonymousNamedGetterInterface::CreateProxy),
base::Bind(MozjsAnonymousNamedGetterInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
AnonymousNamedIndexedGetterInterface::AnonymousNamedIndexedGetterInterfaceWrappableType(),
base::Bind(MozjsAnonymousNamedIndexedGetterInterface::CreateProxy),
base::Bind(MozjsAnonymousNamedIndexedGetterInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ArbitraryInterface::ArbitraryInterfaceWrappableType(),
base::Bind(MozjsArbitraryInterface::CreateProxy),
base::Bind(MozjsArbitraryInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
BaseInterface::BaseInterfaceWrappableType(),
base::Bind(MozjsBaseInterface::CreateProxy),
base::Bind(MozjsBaseInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
BooleanTypeTestInterface::BooleanTypeTestInterfaceWrappableType(),
base::Bind(MozjsBooleanTypeTestInterface::CreateProxy),
base::Bind(MozjsBooleanTypeTestInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
CallbackFunctionInterface::CallbackFunctionInterfaceWrappableType(),
base::Bind(MozjsCallbackFunctionInterface::CreateProxy),
base::Bind(MozjsCallbackFunctionInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
CallbackInterfaceInterface::CallbackInterfaceInterfaceWrappableType(),
base::Bind(MozjsCallbackInterfaceInterface::CreateProxy),
base::Bind(MozjsCallbackInterfaceInterface::PrototypeClass));
#if defined(ENABLE_CONDITIONAL_INTERFACE)
wrapper_factory_->RegisterWrappableType(
ConditionalInterface::ConditionalInterfaceWrappableType(),
base::Bind(MozjsConditionalInterface::CreateProxy),
base::Bind(MozjsConditionalInterface::PrototypeClass));
#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
wrapper_factory_->RegisterWrappableType(
ConstantsInterface::ConstantsInterfaceWrappableType(),
base::Bind(MozjsConstantsInterface::CreateProxy),
base::Bind(MozjsConstantsInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ConstructorInterface::ConstructorInterfaceWrappableType(),
base::Bind(MozjsConstructorInterface::CreateProxy),
base::Bind(MozjsConstructorInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ConstructorWithArgumentsInterface::ConstructorWithArgumentsInterfaceWrappableType(),
base::Bind(MozjsConstructorWithArgumentsInterface::CreateProxy),
base::Bind(MozjsConstructorWithArgumentsInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ConvertSimpleObjectInterface::ConvertSimpleObjectInterfaceWrappableType(),
base::Bind(MozjsConvertSimpleObjectInterface::CreateProxy),
base::Bind(MozjsConvertSimpleObjectInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
DOMStringTestInterface::DOMStringTestInterfaceWrappableType(),
base::Bind(MozjsDOMStringTestInterface::CreateProxy),
base::Bind(MozjsDOMStringTestInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
DerivedGetterSetterInterface::DerivedGetterSetterInterfaceWrappableType(),
base::Bind(MozjsDerivedGetterSetterInterface::CreateProxy),
base::Bind(MozjsDerivedGetterSetterInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
DerivedInterface::DerivedInterfaceWrappableType(),
base::Bind(MozjsDerivedInterface::CreateProxy),
base::Bind(MozjsDerivedInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
DictionaryInterface::DictionaryInterfaceWrappableType(),
base::Bind(MozjsDictionaryInterface::CreateProxy),
base::Bind(MozjsDictionaryInterface::PrototypeClass));
#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
wrapper_factory_->RegisterWrappableType(
DisabledInterface::DisabledInterfaceWrappableType(),
base::Bind(MozjsDisabledInterface::CreateProxy),
base::Bind(MozjsDisabledInterface::PrototypeClass));
#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
wrapper_factory_->RegisterWrappableType(
EnumerationInterface::EnumerationInterfaceWrappableType(),
base::Bind(MozjsEnumerationInterface::CreateProxy),
base::Bind(MozjsEnumerationInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ExceptionObjectInterface::ExceptionObjectInterfaceWrappableType(),
base::Bind(MozjsExceptionObjectInterface::CreateProxy),
base::Bind(MozjsExceptionObjectInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ExceptionsInterface::ExceptionsInterfaceWrappableType(),
base::Bind(MozjsExceptionsInterface::CreateProxy),
base::Bind(MozjsExceptionsInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ExtendedIDLAttributesInterface::ExtendedIDLAttributesInterfaceWrappableType(),
base::Bind(MozjsExtendedIDLAttributesInterface::CreateProxy),
base::Bind(MozjsExtendedIDLAttributesInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
GarbageCollectionTestInterface::GarbageCollectionTestInterfaceWrappableType(),
base::Bind(MozjsGarbageCollectionTestInterface::CreateProxy),
base::Bind(MozjsGarbageCollectionTestInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
GlobalInterfaceParent::GlobalInterfaceParentWrappableType(),
base::Bind(MozjsGlobalInterfaceParent::CreateProxy),
base::Bind(MozjsGlobalInterfaceParent::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ImplementedInterface::ImplementedInterfaceWrappableType(),
base::Bind(MozjsImplementedInterface::CreateProxy),
base::Bind(MozjsImplementedInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
IndexedGetterInterface::IndexedGetterInterfaceWrappableType(),
base::Bind(MozjsIndexedGetterInterface::CreateProxy),
base::Bind(MozjsIndexedGetterInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
InterfaceWithAny::InterfaceWithAnyWrappableType(),
base::Bind(MozjsInterfaceWithAny::CreateProxy),
base::Bind(MozjsInterfaceWithAny::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
InterfaceWithAnyDictionary::InterfaceWithAnyDictionaryWrappableType(),
base::Bind(MozjsInterfaceWithAnyDictionary::CreateProxy),
base::Bind(MozjsInterfaceWithAnyDictionary::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
InterfaceWithDate::InterfaceWithDateWrappableType(),
base::Bind(MozjsInterfaceWithDate::CreateProxy),
base::Bind(MozjsInterfaceWithDate::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
InterfaceWithUnsupportedProperties::InterfaceWithUnsupportedPropertiesWrappableType(),
base::Bind(MozjsInterfaceWithUnsupportedProperties::CreateProxy),
base::Bind(MozjsInterfaceWithUnsupportedProperties::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
NamedConstructorInterface::NamedConstructorInterfaceWrappableType(),
base::Bind(MozjsNamedConstructorInterface::CreateProxy),
base::Bind(MozjsNamedConstructorInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
NamedGetterInterface::NamedGetterInterfaceWrappableType(),
base::Bind(MozjsNamedGetterInterface::CreateProxy),
base::Bind(MozjsNamedGetterInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
NamedIndexedGetterInterface::NamedIndexedGetterInterfaceWrappableType(),
base::Bind(MozjsNamedIndexedGetterInterface::CreateProxy),
base::Bind(MozjsNamedIndexedGetterInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
NestedPutForwardsInterface::NestedPutForwardsInterfaceWrappableType(),
base::Bind(MozjsNestedPutForwardsInterface::CreateProxy),
base::Bind(MozjsNestedPutForwardsInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
NoConstructorInterface::NoConstructorInterfaceWrappableType(),
base::Bind(MozjsNoConstructorInterface::CreateProxy),
base::Bind(MozjsNoConstructorInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
NoInterfaceObjectInterface::NoInterfaceObjectInterfaceWrappableType(),
base::Bind(MozjsNoInterfaceObjectInterface::CreateProxy),
base::Bind(MozjsNoInterfaceObjectInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
NullableTypesTestInterface::NullableTypesTestInterfaceWrappableType(),
base::Bind(MozjsNullableTypesTestInterface::CreateProxy),
base::Bind(MozjsNullableTypesTestInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
NumericTypesTestInterface::NumericTypesTestInterfaceWrappableType(),
base::Bind(MozjsNumericTypesTestInterface::CreateProxy),
base::Bind(MozjsNumericTypesTestInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
ObjectTypeBindingsInterface::ObjectTypeBindingsInterfaceWrappableType(),
base::Bind(MozjsObjectTypeBindingsInterface::CreateProxy),
base::Bind(MozjsObjectTypeBindingsInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
OperationsTestInterface::OperationsTestInterfaceWrappableType(),
base::Bind(MozjsOperationsTestInterface::CreateProxy),
base::Bind(MozjsOperationsTestInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
PromiseInterface::PromiseInterfaceWrappableType(),
base::Bind(MozjsPromiseInterface::CreateProxy),
base::Bind(MozjsPromiseInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
PutForwardsInterface::PutForwardsInterfaceWrappableType(),
base::Bind(MozjsPutForwardsInterface::CreateProxy),
base::Bind(MozjsPutForwardsInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
SequenceUser::SequenceUserWrappableType(),
base::Bind(MozjsSequenceUser::CreateProxy),
base::Bind(MozjsSequenceUser::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
StaticPropertiesInterface::StaticPropertiesInterfaceWrappableType(),
base::Bind(MozjsStaticPropertiesInterface::CreateProxy),
base::Bind(MozjsStaticPropertiesInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
StringifierAnonymousOperationInterface::StringifierAnonymousOperationInterfaceWrappableType(),
base::Bind(MozjsStringifierAnonymousOperationInterface::CreateProxy),
base::Bind(MozjsStringifierAnonymousOperationInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
StringifierAttributeInterface::StringifierAttributeInterfaceWrappableType(),
base::Bind(MozjsStringifierAttributeInterface::CreateProxy),
base::Bind(MozjsStringifierAttributeInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
StringifierOperationInterface::StringifierOperationInterfaceWrappableType(),
base::Bind(MozjsStringifierOperationInterface::CreateProxy),
base::Bind(MozjsStringifierOperationInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
TargetInterface::TargetInterfaceWrappableType(),
base::Bind(MozjsTargetInterface::CreateProxy),
base::Bind(MozjsTargetInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
UnionTypesInterface::UnionTypesInterfaceWrappableType(),
base::Bind(MozjsUnionTypesInterface::CreateProxy),
base::Bind(MozjsUnionTypesInterface::PrototypeClass));
wrapper_factory_->RegisterWrappableType(
Window::WindowWrappableType(),
base::Bind(DummyFunctor),
base::Bind(MozjsWindow::PrototypeClass));
}
} // namespace mozjs
template<>
void GlobalEnvironment::CreateGlobalObject<Window>(
const scoped_refptr<Window>& global_interface,
EnvironmentSettings* environment_settings) {
base::polymorphic_downcast<MozjsGlobalEnvironment*>(this)->CreateGlobalObject(
global_interface, environment_settings);
}
} // namespace script
} // namespace cobalt