1591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch/* 2591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch This file is part of the Blink open source project. 3591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY! 4591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 5591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch This library is free software; you can redistribute it and/or 6591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch modify it under the terms of the GNU Library General Public 7591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch License as published by the Free Software Foundation; either 8591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch version 2 of the License, or (at your option) any later version. 9591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 10591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch This library is distributed in the hope that it will be useful, 11591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch but WITHOUT ANY WARRANTY; without even the implied warranty of 12591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch Library General Public License for more details. 14591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 15591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch You should have received a copy of the GNU Library General Public License 16591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch along with this library; see the file COPYING.LIB. If not, write to 17591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch Boston, MA 02111-1307, USA. 19591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch*/ 20591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 21591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "config.h" 22591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#if ENABLE(TEST) 23591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "V8TestExtendedEvent.h" 24591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 25591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "RuntimeEnabledFeatures.h" 26591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "V8TestEvent.h" 27f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)#include "bindings/v8/Dictionary.h" 28591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "bindings/v8/ScriptController.h" 29591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "bindings/v8/V8Binding.h" 30591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "bindings/v8/V8DOMConfiguration.h" 31591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "bindings/v8/V8DOMWrapper.h" 32f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)#include "bindings/v8/V8ObjectConstructor.h" 33591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "core/dom/ContextFeatures.h" 34591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "core/dom/Document.h" 35591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "core/page/Frame.h" 36f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)#include "core/page/PageConsole.h" 37f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)#include "core/page/UseCounter.h" 38591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "core/platform/chromium/TraceEvent.h" 39591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "wtf/UnusedParam.h" 40591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 41591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochnamespace WebCore { 42591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 43591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochstatic void initializeScriptWrappableForInterface(Event* object) 44591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{ 45591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 46591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch ScriptWrappable::setTypeInfoInObject(object, &V8TestExtendedEvent::info); 47591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch else 48591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch ASSERT_NOT_REACHED(); 49591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} 50591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 51591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} // namespace WebCore 52591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 53591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch// In ScriptWrappable::init, the use of a local function declaration has an issue on Windows: 54591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch// the local declaration does not pick up the surrounding namespace. Therefore, we provide this function 55591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch// in the global namespace. 56591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch// (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c) 57591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochvoid webCoreInitializeScriptWrappableForInterface(WebCore::Event* object) 58591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{ 59591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch WebCore::initializeScriptWrappableForInterface(object); 60591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} 61591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 62591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochnamespace WebCore { 63591b958dee2cf159d33a0b931e6231072eaf38d5Ben MurdochWrapperTypeInfo V8TestExtendedEvent::info = { V8TestExtendedEvent::GetTemplate, V8TestExtendedEvent::derefObject, 0, 0, 0, V8TestExtendedEvent::installPerContextPrototypeProperties, &V8TestEvent::info, WrapperTypeObjectPrototype }; 64591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 65591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochnamespace EventV8Internal { 66591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 67591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochtemplate <typename T> void V8_USE(T) { } 68591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 69f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)static void locationAttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 70f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles){ 71f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) Event* imp = V8TestExtendedEvent::toNative(info.Holder()); 72f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) v8SetReturnValueUnsigned(info, imp->location()); 73f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) return; 74f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)} 75f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 76f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)static void locationAttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 77f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles){ 78f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 79f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) EventV8Internal::locationAttrGetter(name, info); 80f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 81f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)} 82f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 83f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)static void keyLocationAttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 84f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles){ 85f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) Event* imp = V8TestExtendedEvent::toNative(info.Holder()); 86f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) v8SetReturnValueUnsigned(info, imp->location()); 87f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) return; 88f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)} 89f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 90f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)static void keyLocationAttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 91f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles){ 92f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 93f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) UseCounter::countDeprecation(activeDOMWindow(), UseCounter::KeyboardEventKeyLocation); 94f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) EventV8Internal::keyLocationAttrGetter(name, info); 95f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 96f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)} 97f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 98f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args) 99f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles){ 100f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) if (args.Length() < 1) { 101f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) throwNotEnoughArgumentsError(args.GetIsolate()); 102f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) return; 103f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) } 104f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 105f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); 106f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) EventInit eventInit; 107f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) if (args.Length() >= 2) { 108f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate())); 109f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) if (!fillEventInit(eventInit, options)) 110f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) return; 111f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) } 112f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 113f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) RefPtr<Event> event = Event::create(type, eventInit); 114f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) v8::Handle<v8::Object> wrapper = args.Holder(); 115f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) V8DOMWrapper::associateObjectWithWrapper<V8TestExtendedEvent>(event.release(), &V8TestExtendedEvent::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 116f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) v8SetReturnValue(args, wrapper); 117f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)} 118591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} // namespace EventV8Internal 119591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 120f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)static const V8DOMConfiguration::BatchedAttribute V8TestExtendedEventAttrs[] = { 121f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) // Attribute 'location' 122f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) {"location", EventV8Internal::locationAttrGetterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 123f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) // Attribute 'keyLocation' 124f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) {"keyLocation", EventV8Internal::keyLocationAttrGetterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 125f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)}; 126f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 127f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)bool fillEventInit(EventInit& eventInit, const Dictionary& options) 128f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles){ 129f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) if (!fillTestEventInit(eventInit, options)) 130f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) return false; 131f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 132f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) options.get("location", eventInit.location); 133f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) if (options.get("keyLocation", eventInit.location)) 134f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) UseCounter::countDeprecation(activeDOMWindow(), UseCounter::KeyboardEventKeyLocation); 135f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) return true; 136f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)} 137f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 138f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)void V8TestExtendedEvent::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& args) 139f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles){ 140f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); 141f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) if (!args.IsConstructCall()) { 142f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate()); 143f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) return; 144f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) } 145f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 146f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { 147f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) args.GetReturnValue().Set(args.Holder()); 148f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) return; 149f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) } 150f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 151f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) EventV8Internal::constructor(args); 152f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)} 153f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 154591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochstatic v8::Handle<v8::FunctionTemplate> ConfigureV8TestExtendedEventTemplate(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType) 155591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{ 156591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch desc->ReadOnlyPrototype(); 157591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 158591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch v8::Local<v8::Signature> defaultSignature; 159591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch if (!RuntimeEnabledFeatures::testEnabled()) 160591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch defaultSignature = V8DOMConfiguration::configureTemplate(desc, "", V8TestEvent::GetTemplate(isolate, currentWorldType), V8TestExtendedEvent::internalFieldCount, 0, 0, 0, 0, isolate, currentWorldType); 161591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch else 162591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestExtendedEvent", V8TestEvent::GetTemplate(isolate, currentWorldType), V8TestExtendedEvent::internalFieldCount, 163f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) V8TestExtendedEventAttrs, WTF_ARRAY_LENGTH(V8TestExtendedEventAttrs), 164591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 0, 0, isolate, currentWorldType); 165591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. 166f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) desc->SetCallHandler(V8TestExtendedEvent::constructorCallback); 167f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) desc->SetLength(1); 168591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 169591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch // Custom toString template 170591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate()); 171591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch return desc; 172591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} 173591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 174591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochv8::Handle<v8::FunctionTemplate> V8TestExtendedEvent::GetTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType) 175591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{ 176591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch V8PerIsolateData* data = V8PerIsolateData::from(isolate); 177591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&info); 178591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch if (result != data->templateMap(currentWorldType).end()) 179591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch return result->value.newLocal(isolate); 180591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 181e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 182591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch v8::HandleScope handleScope(isolate); 183591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch v8::Handle<v8::FunctionTemplate> templ = 184591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch ConfigureV8TestExtendedEventTemplate(data->rawTemplate(&info, currentWorldType), isolate, currentWorldType); 185591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::FunctionTemplate>(isolate, templ)); 186591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch return handleScope.Close(templ); 187591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} 188591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 189591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochbool V8TestExtendedEvent::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isolate, WrapperWorldType currentWorldType) 190591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{ 191591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWorldType); 192591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} 193591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 194591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochbool V8TestExtendedEvent::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate* isolate) 195591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{ 196591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) 197591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWorld) 198591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorld); 199591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} 200591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 201591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 202591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochv8::Handle<v8::Object> V8TestExtendedEvent::createWrapper(PassRefPtr<Event> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 203591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{ 204591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch ASSERT(impl.get()); 205e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch ASSERT(DOMDataStore::getWrapper<V8TestExtendedEvent>(impl.get(), isolate).IsEmpty()); 2067757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 2077757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get()); 2087757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch // Might be a XXXConstructor::info instead of an XXX::info. These will both have 2097757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch // the same object de-ref functions, though, so use that as the basis of the check. 2107757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); 2117757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch } 2127757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch 213591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 214e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, toInternalPointer(impl.get()), isolate); 215591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch if (UNLIKELY(wrapper.IsEmpty())) 216591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch return wrapper; 217591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch installPerContextProperties(wrapper, impl.get(), isolate); 218e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch V8DOMWrapper::associateObjectWithWrapper<V8TestExtendedEvent>(impl, &info, wrapper, isolate, WrapperConfiguration::Independent); 219591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch return wrapper; 220591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} 221591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochvoid V8TestExtendedEvent::derefObject(void* object) 222591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{ 223e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch fromInternalPointer(object)->deref(); 224591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} 225591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 226591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch} // namespace WebCore 227591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 228591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#endif // ENABLE(TEST) 229