Home | History | Annotate | Download | only in results
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
      6 
      7 #include "config.h"
      8 #include "V8TestInterfaceCheckSecurity.h"
      9 
     10 #include "bindings/v8/BindingSecurity.h"
     11 #include "bindings/v8/ExceptionState.h"
     12 #include "bindings/v8/V8DOMConfiguration.h"
     13 #include "bindings/v8/V8HiddenValue.h"
     14 #include "bindings/v8/V8ObjectConstructor.h"
     15 #include "core/dom/ContextFeatures.h"
     16 #include "core/dom/Document.h"
     17 #include "platform/RuntimeEnabledFeatures.h"
     18 #include "platform/TraceEvent.h"
     19 #include "wtf/GetPtr.h"
     20 #include "wtf/RefPtr.h"
     21 
     22 namespace WebCore {
     23 
     24 static void initializeScriptWrappableForInterface(TestInterfaceCheckSecurity* object)
     25 {
     26     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
     27         ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceCheckSecurity::wrapperTypeInfo);
     28     else
     29         ASSERT_NOT_REACHED();
     30 }
     31 
     32 } // namespace WebCore
     33 
     34 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceCheckSecurity* object)
     35 {
     36     WebCore::initializeScriptWrappableForInterface(object);
     37 }
     38 
     39 namespace WebCore {
     40 const WrapperTypeInfo V8TestInterfaceCheckSecurity::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceCheckSecurity::domTemplate, V8TestInterfaceCheckSecurity::derefObject, 0, 0, 0, V8TestInterfaceCheckSecurity::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
     41 
     42 namespace TestInterfaceCheckSecurityV8Internal {
     43 
     44 template <typename T> void V8_USE(T) { }
     45 
     46 static void longAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
     47 {
     48     v8::Handle<v8::Object> holder = info.Holder();
     49     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
     50     v8SetReturnValueInt(info, impl->longAttribute());
     51 }
     52 
     53 static void longAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
     54 {
     55     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
     56     TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetter(info);
     57     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
     58 }
     59 
     60 static void doNotCheckSecurityLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
     61 {
     62     v8::Handle<v8::Object> holder = info.Holder();
     63     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
     64     v8SetReturnValueInt(info, impl->doNotCheckSecurityLongAttribute());
     65 }
     66 
     67 static void doNotCheckSecurityLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
     68 {
     69     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
     70     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeGetter(info);
     71     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
     72 }
     73 
     74 static void doNotCheckSecurityLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
     75 {
     76     v8::Handle<v8::Object> holder = info.Holder();
     77     ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecurityLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate());
     78     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
     79     TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState);
     80     impl->setDoNotCheckSecurityLongAttribute(cppValue);
     81 }
     82 
     83 static void doNotCheckSecurityLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
     84 {
     85     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
     86     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeSetter(v8Value, info);
     87     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
     88 }
     89 
     90 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
     91 {
     92     v8::Handle<v8::Object> holder = info.Holder();
     93     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
     94     v8SetReturnValueInt(info, impl->doNotCheckSecurityReadonlyLongAttribute());
     95 }
     96 
     97 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
     98 {
     99     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    100     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadonlyLongAttributeAttributeGetter(info);
    101     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    102 }
    103 
    104 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
    105 {
    106     v8::Handle<v8::Object> holder = info.Holder();
    107     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    108     v8SetReturnValueInt(info, impl->doNotCheckSecurityOnSetterLongAttribute());
    109 }
    110 
    111 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
    112 {
    113     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    114     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeGetter(info);
    115     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    116 }
    117 
    118 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
    119 {
    120     v8::Handle<v8::Object> holder = info.Holder();
    121     ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecurityOnSetterLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate());
    122     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    123     TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState);
    124     impl->setDoNotCheckSecurityOnSetterLongAttribute(cppValue);
    125 }
    126 
    127 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
    128 {
    129     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
    130     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8Value, info);
    131     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    132 }
    133 
    134 static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
    135 {
    136     v8::Handle<v8::Object> holder = info.Holder();
    137     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    138     v8SetReturnValueInt(info, impl->doNotCheckSecurityReplaceableReadonlyLongAttribute());
    139 }
    140 
    141 static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
    142 {
    143     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    144     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(info);
    145     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    146 }
    147 
    148 static void TestInterfaceCheckSecurityReplaceableAttributeSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
    149 {
    150     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
    151     v8::Isolate* isolate = info.GetIsolate();
    152     v8::String::Utf8Value attributeName(name);
    153     ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), isolate);
    154     if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), exceptionState)) {
    155         exceptionState.throwIfNeeded();
    156         return;
    157     }
    158     if (info.This()->IsObject())
    159         v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
    160 }
    161 
    162 static void TestInterfaceCheckSecurityReplaceableAttributeSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
    163 {
    164     TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityReplaceableAttributeSetter(name, v8Value, info);
    165 }
    166 
    167 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
    168 {
    169     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(host);
    170     return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
    171 }
    172 
    173 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
    174 {
    175     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(host);
    176     return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
    177 }
    178 
    179 static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
    180 {
    181     ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethod", "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate());
    182     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
    183     if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
    184         exceptionState.throwIfNeeded();
    185         return;
    186     }
    187     impl->voidMethod();
    188 }
    189 
    190 static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
    191 {
    192     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
    193     TestInterfaceCheckSecurityV8Internal::voidMethodMethod(info);
    194     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    195 }
    196 
    197 static void doNotCheckSecurityVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
    198 {
    199     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
    200     impl->doNotCheckSecurityVoidMethod();
    201 }
    202 
    203 static void doNotCheckSecurityVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
    204 {
    205     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
    206     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethod(info);
    207     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    208 }
    209 
    210 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
    211 {
    212     v8::Isolate* isolate = info.GetIsolate();
    213     static int domTemplateKey; // This address is used for a key to look up the dom template.
    214     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
    215     v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    216 
    217     v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
    218     if (holder.IsEmpty()) {
    219         // This is only reachable via |object.__proto__.func|, in which case it
    220         // has already passed the same origin security check
    221         v8SetReturnValue(info, privateTemplate->GetFunction());
    222         return;
    223     }
    224     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    225     if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
    226         static int sharedTemplateKey; // This address is used for a key to look up the dom template.
    227         v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    228         v8SetReturnValue(info, sharedTemplate->GetFunction());
    229         return;
    230     }
    231 
    232     v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityVoidMethod"));
    233     if (!hiddenValue.IsEmpty()) {
    234         v8SetReturnValue(info, hiddenValue);
    235         return;
    236     }
    237 
    238     v8SetReturnValue(info, privateTemplate->GetFunction());
    239 }
    240 
    241 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
    242 {
    243     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    244     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetter(info);
    245     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    246 }
    247 
    248 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
    249 {
    250     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
    251     impl->doNotCheckSecurityDoNotCheckSignatureVoidMethod();
    252 }
    253 
    254 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
    255 {
    256     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
    257     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(info);
    258     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    259 }
    260 
    261 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
    262 {
    263     v8::Isolate* isolate = info.GetIsolate();
    264     static int domTemplateKey; // This address is used for a key to look up the dom template.
    265     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
    266     v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0);
    267 
    268     v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
    269     if (holder.IsEmpty()) {
    270         // This is only reachable via |object.__proto__.func|, in which case it
    271         // has already passed the same origin security check
    272         v8SetReturnValue(info, privateTemplate->GetFunction());
    273         return;
    274     }
    275     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    276     if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
    277         static int sharedTemplateKey; // This address is used for a key to look up the dom template.
    278         v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0);
    279         v8SetReturnValue(info, sharedTemplate->GetFunction());
    280         return;
    281     }
    282 
    283     v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityDoNotCheckSignatureVoidMethod"));
    284     if (!hiddenValue.IsEmpty()) {
    285         v8SetReturnValue(info, hiddenValue);
    286         return;
    287     }
    288 
    289     v8SetReturnValue(info, privateTemplate->GetFunction());
    290 }
    291 
    292 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
    293 {
    294     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    295     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetter(info);
    296     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    297 }
    298 
    299 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
    300 {
    301     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
    302     impl->doNotCheckSecurityPerWorldBindingsVoidMethod();
    303 }
    304 
    305 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
    306 {
    307     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
    308     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethod(info);
    309     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    310 }
    311 
    312 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
    313 {
    314     v8::Isolate* isolate = info.GetIsolate();
    315     static int domTemplateKey; // This address is used for a key to look up the dom template.
    316     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
    317     v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    318 
    319     v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
    320     if (holder.IsEmpty()) {
    321         // This is only reachable via |object.__proto__.func|, in which case it
    322         // has already passed the same origin security check
    323         v8SetReturnValue(info, privateTemplate->GetFunction());
    324         return;
    325     }
    326     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    327     if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
    328         static int sharedTemplateKey; // This address is used for a key to look up the dom template.
    329         v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    330         v8SetReturnValue(info, sharedTemplate->GetFunction());
    331         return;
    332     }
    333 
    334     v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityPerWorldBindingsVoidMethod"));
    335     if (!hiddenValue.IsEmpty()) {
    336         v8SetReturnValue(info, hiddenValue);
    337         return;
    338     }
    339 
    340     v8SetReturnValue(info, privateTemplate->GetFunction());
    341 }
    342 
    343 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
    344 {
    345     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    346     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(info);
    347     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    348 }
    349 
    350 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
    351 {
    352     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
    353     impl->doNotCheckSecurityPerWorldBindingsVoidMethod();
    354 }
    355 
    356 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
    357 {
    358     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
    359     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(info);
    360     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    361 }
    362 
    363 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterForMainWorld(const v8::PropertyCallbackInfo<v8::Value>& info)
    364 {
    365     v8::Isolate* isolate = info.GetIsolate();
    366     static int domTemplateKey; // This address is used for a key to look up the dom template.
    367     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
    368     v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    369 
    370     v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
    371     if (holder.IsEmpty()) {
    372         // This is only reachable via |object.__proto__.func|, in which case it
    373         // has already passed the same origin security check
    374         v8SetReturnValue(info, privateTemplate->GetFunction());
    375         return;
    376     }
    377     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    378     if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
    379         static int sharedTemplateKey; // This address is used for a key to look up the dom template.
    380         v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    381         v8SetReturnValue(info, sharedTemplate->GetFunction());
    382         return;
    383     }
    384 
    385     v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityPerWorldBindingsVoidMethod"));
    386     if (!hiddenValue.IsEmpty()) {
    387         v8SetReturnValue(info, hiddenValue);
    388         return;
    389     }
    390 
    391     v8SetReturnValue(info, privateTemplate->GetFunction());
    392 }
    393 
    394 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallbackForMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
    395 {
    396     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    397     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterForMainWorld(info);
    398     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    399 }
    400 
    401 static void doNotCheckSecurityReadOnlyVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
    402 {
    403     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
    404     impl->doNotCheckSecurityReadOnlyVoidMethod();
    405 }
    406 
    407 static void doNotCheckSecurityReadOnlyVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
    408 {
    409     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
    410     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodMethod(info);
    411     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    412 }
    413 
    414 static void doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
    415 {
    416     v8::Isolate* isolate = info.GetIsolate();
    417     static int domTemplateKey; // This address is used for a key to look up the dom template.
    418     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
    419     v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    420 
    421     v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
    422     if (holder.IsEmpty()) {
    423         // This is only reachable via |object.__proto__.func|, in which case it
    424         // has already passed the same origin security check
    425         v8SetReturnValue(info, privateTemplate->GetFunction());
    426         return;
    427     }
    428     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    429     if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
    430         static int sharedTemplateKey; // This address is used for a key to look up the dom template.
    431         v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    432         v8SetReturnValue(info, sharedTemplate->GetFunction());
    433         return;
    434     }
    435 
    436     v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityReadOnlyVoidMethod"));
    437     if (!hiddenValue.IsEmpty()) {
    438         v8SetReturnValue(info, hiddenValue);
    439         return;
    440     }
    441 
    442     v8SetReturnValue(info, privateTemplate->GetFunction());
    443 }
    444 
    445 static void doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
    446 {
    447     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    448     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetter(info);
    449     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    450 }
    451 
    452 static void doNotCheckSecurityUnforgeableVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
    453 {
    454     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
    455     impl->doNotCheckSecurityUnforgeableVoidMethod();
    456 }
    457 
    458 static void doNotCheckSecurityUnforgeableVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
    459 {
    460     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
    461     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethod(info);
    462     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    463 }
    464 
    465 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
    466 {
    467     v8::Isolate* isolate = info.GetIsolate();
    468     static int domTemplateKey; // This address is used for a key to look up the dom template.
    469     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
    470     v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    471 
    472     v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
    473     if (holder.IsEmpty()) {
    474         // This is only reachable via |object.__proto__.func|, in which case it
    475         // has already passed the same origin security check
    476         v8SetReturnValue(info, privateTemplate->GetFunction());
    477         return;
    478     }
    479     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    480     if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
    481         static int sharedTemplateKey; // This address is used for a key to look up the dom template.
    482         v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(isolate, V8TestInterfaceCheckSecurity::domTemplate(isolate)), 0);
    483         v8SetReturnValue(info, sharedTemplate->GetFunction());
    484         return;
    485     }
    486 
    487     v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityUnforgeableVoidMethod"));
    488     if (!hiddenValue.IsEmpty()) {
    489         v8SetReturnValue(info, hiddenValue);
    490         return;
    491     }
    492 
    493     v8SetReturnValue(info, privateTemplate->GetFunction());
    494 }
    495 
    496 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
    497 {
    498     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    499     TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(info);
    500     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    501 }
    502 
    503 static void TestInterfaceCheckSecurityOriginSafeMethodSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
    504 {
    505     v8::Isolate* isolate = info.GetIsolate();
    506     v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
    507     if (holder.IsEmpty())
    508         return;
    509     TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
    510     v8::String::Utf8Value attributeName(name);
    511     ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), isolate);
    512     if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), exceptionState)) {
    513         exceptionState.throwIfNeeded();
    514         return;
    515     }
    516 
    517     V8HiddenValue::setHiddenValue(isolate, v8::Handle<v8::Object>::Cast(info.This()), name, v8Value);
    518 }
    519 
    520 static void TestInterfaceCheckSecurityOriginSafeMethodSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
    521 {
    522     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
    523     TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetter(name, v8Value, info);
    524     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
    525 }
    526 
    527 } // namespace TestInterfaceCheckSecurityV8Internal
    528 
    529 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceCheckSecurityAttributes[] = {
    530     {"longAttribute", TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
    531     {"doNotCheckSecurityLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
    532     {"doNotCheckSecurityReadonlyLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_READ), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
    533     {"doNotCheckSecurityOnSetterLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
    534     {"doNotCheckSecurityReplaceableReadonlyLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityReplaceableAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
    535 };
    536 
    537 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceCheckSecurityMethods[] = {
    538     {"voidMethod", TestInterfaceCheckSecurityV8Internal::voidMethodMethodCallback, 0, 0},
    539 };
    540 
    541 static void configureV8TestInterfaceCheckSecurityTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
    542 {
    543     functionTemplate->ReadOnlyPrototype();
    544 
    545     v8::Local<v8::Signature> defaultSignature;
    546     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceCheckSecurity", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceCheckSecurity::internalFieldCount,
    547         V8TestInterfaceCheckSecurityAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceCheckSecurityAttributes),
    548         0, 0,
    549         V8TestInterfaceCheckSecurityMethods, WTF_ARRAY_LENGTH(V8TestInterfaceCheckSecurityMethods),
    550         isolate);
    551     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
    552     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
    553     instanceTemplate->SetAccessCheckCallbacks(TestInterfaceCheckSecurityV8Internal::namedSecurityCheck, TestInterfaceCheckSecurityV8Internal::indexedSecurityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestInterfaceCheckSecurity::wrapperTypeInfo)));
    554     prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
    555     prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityDoNotCheckSignatureVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
    556     if (DOMWrapperWorld::current(isolate).isMainWorld()) {
    557         prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityPerWorldBindingsVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallbackForMainWorld, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
    558     } else {
    559         prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityPerWorldBindingsVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
    560     }
    561     prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityReadOnlyVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetterCallback, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly));
    562     instanceTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityUnforgeableVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
    563 
    564     // Custom toString template
    565     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
    566 }
    567 
    568 v8::Handle<v8::FunctionTemplate> V8TestInterfaceCheckSecurity::domTemplate(v8::Isolate* isolate)
    569 {
    570     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8TestInterfaceCheckSecurityTemplate);
    571 }
    572 
    573 bool V8TestInterfaceCheckSecurity::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
    574 {
    575     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
    576 }
    577 
    578 v8::Handle<v8::Object> V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
    579 {
    580     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
    581 }
    582 
    583 TestInterfaceCheckSecurity* V8TestInterfaceCheckSecurity::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
    584 {
    585     return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
    586 }
    587 
    588 v8::Handle<v8::Object> wrap(TestInterfaceCheckSecurity* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    589 {
    590     ASSERT(impl);
    591     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceCheckSecurity>(impl, isolate));
    592     return V8TestInterfaceCheckSecurity::createWrapper(impl, creationContext, isolate);
    593 }
    594 
    595 v8::Handle<v8::Object> V8TestInterfaceCheckSecurity::createWrapper(PassRefPtr<TestInterfaceCheckSecurity> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    596 {
    597     ASSERT(impl);
    598     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceCheckSecurity>(impl.get(), isolate));
    599     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
    600         const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
    601         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
    602         // the same object de-ref functions, though, so use that as the basis of the check.
    603         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
    604     }
    605 
    606     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
    607     if (UNLIKELY(wrapper.IsEmpty()))
    608         return wrapper;
    609 
    610     installPerContextEnabledProperties(wrapper, impl.get(), isolate);
    611     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceCheckSecurity>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
    612     return wrapper;
    613 }
    614 
    615 void V8TestInterfaceCheckSecurity::derefObject(void* object)
    616 {
    617     fromInternalPointer(object)->deref();
    618 }
    619 
    620 template<>
    621 v8::Handle<v8::Value> toV8NoInline(TestInterfaceCheckSecurity* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    622 {
    623     return toV8(impl, creationContext, isolate);
    624 }
    625 
    626 } // namespace WebCore
    627