107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// found in the LICENSE file. 407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#include "config.h" 8a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "V8TestInterfaceCheckSecurity.h" 951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 10197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/BindingSecurity.h" 11197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/ExceptionState.h" 12197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8DOMConfiguration.h" 13197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8HiddenValue.h" 14197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8ObjectConstructor.h" 1551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#include "core/dom/ContextFeatures.h" 1651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#include "core/dom/Document.h" 1776c265b59aa821ccbf8c75ab2bb0d036e97d2956Torne (Richard Coles)#include "platform/RuntimeEnabledFeatures.h" 1851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#include "platform/TraceEvent.h" 1909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "wtf/GetPtr.h" 2009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "wtf/RefPtr.h" 2151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 22c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 2351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 247242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucciconst WrapperTypeInfo V8TestInterfaceCheckSecurity::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceCheckSecurity::domTemplate, V8TestInterfaceCheckSecurity::refObject, V8TestInterfaceCheckSecurity::derefObject, V8TestInterfaceCheckSecurity::createPersistentHandle, 0, 0, 0, V8TestInterfaceCheckSecurity::installConditionallyEnabledMethods, V8TestInterfaceCheckSecurity::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObject }; 2551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 267242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceCheckSecurity.h. 277242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci// For details, see the comment of DEFINE_WRAPPERTYPEINFO in 287242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci// bindings/core/v8/ScriptWrappable.h. 297242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucciconst WrapperTypeInfo& TestInterfaceCheckSecurity::s_wrapperTypeInfo = V8TestInterfaceCheckSecurity::wrapperTypeInfo; 3051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 31a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)namespace TestInterfaceCheckSecurityV8Internal { 3251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 3351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)template <typename T> void V8_USE(T) { } 3451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 3551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void longAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 3651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 3707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch v8::Handle<v8::Object> holder = info.Holder(); 387242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 3943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) v8SetReturnValueInt(info, impl->longAttribute()); 4051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 4151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 4251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void longAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 4351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 44197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 45a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetter(info); 46197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 4751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 4851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 4951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 5051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 5107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch v8::Handle<v8::Object> holder = info.Holder(); 527242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 5343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) v8SetReturnValueInt(info, impl->doNotCheckSecurityLongAttribute()); 5451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 5551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 5651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 5751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 58197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 59a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeGetter(info); 60197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 6151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 6251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 6307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void doNotCheckSecurityLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 6451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 6507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch v8::Handle<v8::Object> holder = info.Holder(); 6607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecurityLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate()); 677242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 686f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 6943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) impl->setDoNotCheckSecurityLongAttribute(cppValue); 7051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 7151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 7207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void doNotCheckSecurityLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 7351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 74197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 7507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeSetter(v8Value, info); 76197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 7751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 7851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 7951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 8051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 8107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch v8::Handle<v8::Object> holder = info.Holder(); 827242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 8343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) v8SetReturnValueInt(info, impl->doNotCheckSecurityReadonlyLongAttribute()); 8451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 8551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 8651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 8751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 88197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 89a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadonlyLongAttributeAttributeGetter(info); 90197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 9151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 9251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 9351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityOnSetterLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 9451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 9507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch v8::Handle<v8::Object> holder = info.Holder(); 967242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 9743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) v8SetReturnValueInt(info, impl->doNotCheckSecurityOnSetterLongAttribute()); 9851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 9951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 10051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 10151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 102197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 103a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeGetter(info); 104197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 10551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 10651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 10707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 10851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 10907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch v8::Handle<v8::Object> holder = info.Holder(); 11007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecurityOnSetterLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate()); 1117242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 1126f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState); 11343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) impl->setDoNotCheckSecurityOnSetterLongAttribute(cppValue); 11451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 11551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 11607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 11751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 118197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 11907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8Value, info); 120197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 12109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 12209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 12309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 12409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 12507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch v8::Handle<v8::Object> holder = info.Holder(); 1267242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 12743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) v8SetReturnValueInt(info, impl->doNotCheckSecurityReplaceableReadonlyLongAttribute()); 12809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 12909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 13009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 13109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 132197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 13309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(info); 134197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 13509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 13609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 137197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstatic void TestInterfaceCheckSecurityForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 13809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 1397242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder()); 14009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) v8::String::Utf8Value attributeName(name); 141197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate()); 142197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) { 14309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) exceptionState.throwIfNeeded(); 14409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return; 14509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 14610f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch if (info.This()->IsObject()) 14710f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); 14809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 14909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 150197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstatic void TestInterfaceCheckSecurityForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 15109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 152197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityForceSetAttributeOnThis(name, v8Value, info); 15351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 15451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 15551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>) 15651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 1577242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(host); 15843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError); 15951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 16051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 16151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>) 16251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 1637242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(host); 16443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError); 16551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 16651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 16751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 16851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 169a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethod", "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate()); 1707242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder()); 17143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) { 17251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) exceptionState.throwIfNeeded(); 17351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 17451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 17543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) impl->voidMethod(); 17651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 17751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 17851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 17951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 180197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 181a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::voidMethodMethod(info); 182197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 18351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 18451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 18551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 18651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 1877242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder()); 18843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) impl->doNotCheckSecurityVoidMethod(); 18951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 19051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 19151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 19251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 193197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 194a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethod(info); 195197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 19651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 19751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 19851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 19951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 200d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int domTemplateKey; // This address is used for a key to look up the dom template. 201197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 202197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); 20351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 204197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate()); 20551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (holder.IsEmpty()) { 20651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // This is only reachable via |object.__proto__.func|, in which case it 20751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // has already passed the same origin security check 20851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 20951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 21051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 2117242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 212197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) { 213d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int sharedTemplateKey; // This address is used for a key to look up the dom template. 214197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); 21551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, sharedTemplate->GetFunction()); 21651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 21751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 21851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 219197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityVoidMethod")); 22051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (!hiddenValue.IsEmpty()) { 22151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, hiddenValue); 22251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 22351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 22451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 22551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 22651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 22751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 22851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 22951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 230197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 231a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetter(info); 232197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 23309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 23409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 23509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 23609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 2377242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder()); 23843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) impl->doNotCheckSecurityDoNotCheckSignatureVoidMethod(); 23909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 24009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 24109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 24209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 243197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 24409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(info); 245197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 24609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 24709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 24809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 24909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 250d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int domTemplateKey; // This address is used for a key to look up the dom template. 251197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 252d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0); 25309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 254197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate()); 25509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (holder.IsEmpty()) { 25609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // This is only reachable via |object.__proto__.func|, in which case it 25709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // has already passed the same origin security check 25809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 25909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return; 26009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 2617242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 262197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) { 263d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int sharedTemplateKey; // This address is used for a key to look up the dom template. 264d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0); 26509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) v8SetReturnValue(info, sharedTemplate->GetFunction()); 26609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return; 26709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 26809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 269197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityDoNotCheckSignatureVoidMethod")); 27009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (!hiddenValue.IsEmpty()) { 27109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) v8SetReturnValue(info, hiddenValue); 27209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return; 27309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) } 27409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 27509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 27609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)} 27709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 27809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 27909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){ 280197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 28109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetter(info); 282197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 28351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 28451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 28551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityPerWorldBindingsVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 28651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 2877242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder()); 28843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) impl->doNotCheckSecurityPerWorldBindingsVoidMethod(); 28951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 29051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 29151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 29251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 293197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 294a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethod(info); 295197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 29651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 29751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 29851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 29951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 300d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int domTemplateKey; // This address is used for a key to look up the dom template. 301197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 302197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); 30351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 304197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate()); 30551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (holder.IsEmpty()) { 30651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // This is only reachable via |object.__proto__.func|, in which case it 30751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // has already passed the same origin security check 30851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 30951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 31051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 3117242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 312197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) { 313d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int sharedTemplateKey; // This address is used for a key to look up the dom template. 314197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); 31551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, sharedTemplate->GetFunction()); 31651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 31751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 31851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 319197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityPerWorldBindingsVoidMethod")); 32051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (!hiddenValue.IsEmpty()) { 32151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, hiddenValue); 32251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 32351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 32451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 32551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 32651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 32751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 32851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 32951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 330197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 331a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(info); 332197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 33351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 33451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 33551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) 33651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 3377242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder()); 33843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) impl->doNotCheckSecurityPerWorldBindingsVoidMethod(); 33951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 34051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 34151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info) 34251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 343197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 344a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(info); 345197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 34651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 34751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 34851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterForMainWorld(const v8::PropertyCallbackInfo<v8::Value>& info) 34951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 350d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int domTemplateKey; // This address is used for a key to look up the dom template. 351197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 352197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); 35351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 354197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate()); 35551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (holder.IsEmpty()) { 35651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // This is only reachable via |object.__proto__.func|, in which case it 35751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // has already passed the same origin security check 35851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 35951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 36051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 3617242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 362197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) { 363d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int sharedTemplateKey; // This address is used for a key to look up the dom template. 364197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); 36551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, sharedTemplate->GetFunction()); 36651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 36751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 36851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 369197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityPerWorldBindingsVoidMethod")); 37051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (!hiddenValue.IsEmpty()) { 37151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, hiddenValue); 37251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 37351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 37451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 37551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 37651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 37751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 37851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallbackForMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 37951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 380197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 381a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterForMainWorld(info); 382197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 38351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 38451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 38551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityUnforgeableVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 38651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 3877242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder()); 38843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) impl->doNotCheckSecurityUnforgeableVoidMethod(); 38951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 39051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 39151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityUnforgeableVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 39251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 393197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 394a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethod(info); 395197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 39651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 39751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 39851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 39951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 400d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int domTemplateKey; // This address is used for a key to look up the dom template. 401197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 402197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); 40351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 404197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate()); 40551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (holder.IsEmpty()) { 40651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // This is only reachable via |object.__proto__.func|, in which case it 40751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // has already passed the same origin security check 40851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 40951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 41051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 4117242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 412197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) { 413d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static int sharedTemplateKey; // This address is used for a key to look up the dom template. 414197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); 41551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, sharedTemplate->GetFunction()); 41651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 41751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 41851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 419197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityUnforgeableVoidMethod")); 42051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (!hiddenValue.IsEmpty()) { 42151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, hiddenValue); 42251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 42351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 42451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 42551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8SetReturnValue(info, privateTemplate->GetFunction()); 42651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 42751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 42851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 42951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 430197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 431a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(info); 432197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 43351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 43451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 43507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void TestInterfaceCheckSecurityOriginSafeMethodSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 43651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 437197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate()); 43851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) if (holder.IsEmpty()) 43951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 4407242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder); 441a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) v8::String::Utf8Value attributeName(name); 442197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate()); 443197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) { 44451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) exceptionState.throwIfNeeded(); 44551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return; 44651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) } 44751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 448197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8HiddenValue::setHiddenValue(info.GetIsolate(), v8::Handle<v8::Object>::Cast(info.This()), name, v8Value); 44951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 45051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 45107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void TestInterfaceCheckSecurityOriginSafeMethodSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 45251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 453197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 45407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetter(name, v8Value, info); 455197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 45651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 45751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 458a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)} // namespace TestInterfaceCheckSecurityV8Internal 45951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 460a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceCheckSecurityAttributes[] = { 461c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) {"longAttribute", TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 462c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) {"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), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 463c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) {"doNotCheckSecurityReadonlyLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_READ), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 464c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) {"doNotCheckSecurityOnSetterLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 465c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) {"doNotCheckSecurityReplaceableReadonlyLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityForceSetAttributeOnThisCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance}, 46651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)}; 46751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 468a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceCheckSecurityMethods[] = { 469c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) {"voidMethod", TestInterfaceCheckSecurityV8Internal::voidMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, 47051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)}; 47151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 472197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstatic void installV8TestInterfaceCheckSecurityTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) 47351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 47451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) functionTemplate->ReadOnlyPrototype(); 47551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 47651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) v8::Local<v8::Signature> defaultSignature; 477a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceCheckSecurity", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceCheckSecurity::internalFieldCount, 478a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) V8TestInterfaceCheckSecurityAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceCheckSecurityAttributes), 47951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 0, 0, 480a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) V8TestInterfaceCheckSecurityMethods, WTF_ARRAY_LENGTH(V8TestInterfaceCheckSecurityMethods), 481d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) isolate); 482f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); 483f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); 484a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) instanceTemplate->SetAccessCheckCallbacks(TestInterfaceCheckSecurityV8Internal::namedSecurityCheck, TestInterfaceCheckSecurityV8Internal::indexedSecurityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestInterfaceCheckSecurity::wrapperTypeInfo))); 485197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityVoidMethodOriginSafeAttributeConfiguration = { 486c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) "doNotCheckSecurityVoidMethod", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, 487197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch }; 488197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::ObjectTemplate>(), doNotCheckSecurityVoidMethodOriginSafeAttributeConfiguration, isolate); 489197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeAttributeConfiguration = { 490c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) "doNotCheckSecurityDoNotCheckSignatureVoidMethod", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, 491197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch }; 492197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::ObjectTemplate>(), doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeAttributeConfiguration, isolate); 493197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeAttributeConfiguration = { 494c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) "doNotCheckSecurityPerWorldBindingsVoidMethod", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallbackForMainWorld, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallbackForMainWorld, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, 495197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch }; 496197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::ObjectTemplate>(), doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeAttributeConfiguration, isolate); 497197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityUnforgeableVoidMethodOriginSafeAttributeConfiguration = { 498c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) "doNotCheckSecurityUnforgeableVoidMethod", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback, 0, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, 499197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch }; 500197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch V8DOMConfiguration::installAttribute(instanceTemplate, v8::Handle<v8::ObjectTemplate>(), doNotCheckSecurityUnforgeableVoidMethodOriginSafeAttributeConfiguration, isolate); 50151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 50251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // Custom toString template 503a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); 50451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 50551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 506d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)v8::Handle<v8::FunctionTemplate> V8TestInterfaceCheckSecurity::domTemplate(v8::Isolate* isolate) 50751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 508197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceCheckSecurityTemplate); 50951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 51051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 51107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochbool V8TestInterfaceCheckSecurity::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 51251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 51307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); 514d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 515d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 51607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochv8::Handle<v8::Object> V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 517d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 51807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); 519d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 520d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 5217242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano TucciTestInterfaceCheckSecurity* V8TestInterfaceCheckSecurity::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) 522d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 5237242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceCheckSecurity>() : 0; 52451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 52551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 5267242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 5277242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccivoid V8TestInterfaceCheckSecurity::refObject(ScriptWrappableBase* internalPointer) 5285d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles){ 5297242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci internalPointer->toImpl<TestInterfaceCheckSecurity>()->ref(); 5305d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)} 5315d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) 5327242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccivoid V8TestInterfaceCheckSecurity::derefObject(ScriptWrappableBase* internalPointer) 53351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 5347242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci internalPointer->toImpl<TestInterfaceCheckSecurity>()->deref(); 53551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 53651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 5377242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano TucciWrapperPersistentNode* V8TestInterfaceCheckSecurity::createPersistentHandle(ScriptWrappableBase* internalPointer) 53851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 5397242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci ASSERT_NOT_REACHED(); 5407242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci return 0; 54151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 54251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 54351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)template<> 544a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)v8::Handle<v8::Value> toV8NoInline(TestInterfaceCheckSecurity* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 54551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles){ 54651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) return toV8(impl, creationContext, isolate); 54751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} 54851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) 549c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 550