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.
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
8 #include "V8TestInterfaceCheckSecurity.h"
10 #include "bindings/core/v8/BindingSecurity.h"
11 #include "bindings/core/v8/ExceptionState.h"
12 #include "bindings/core/v8/V8DOMConfiguration.h"
13 #include "bindings/core/v8/V8HiddenValue.h"
14 #include "bindings/core/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"
24 const WrapperTypeInfo V8TestInterfaceCheckSecurity::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceCheckSecurity::domTemplate, V8TestInterfaceCheckSecurity::refObject, V8TestInterfaceCheckSecurity::derefObject, V8TestInterfaceCheckSecurity::trace, 0, 0, 0, V8TestInterfaceCheckSecurity::installConditionallyEnabledMethods, V8TestInterfaceCheckSecurity::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObject };
26 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceCheckSecurity.h.
27 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
28 // bindings/core/v8/ScriptWrappable.h.
29 const WrapperTypeInfo& TestInterfaceCheckSecurity::s_wrapperTypeInfo = V8TestInterfaceCheckSecurity::wrapperTypeInfo;
31 namespace TestInterfaceCheckSecurityV8Internal {
33 static void longAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
35 v8::Handle<v8::Object> holder = info.Holder();
36 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
37 v8SetReturnValueInt(info, impl->longAttribute());
40 static void longAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
42 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
43 TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetter(info);
44 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
47 static void doNotCheckSecurityLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
49 v8::Handle<v8::Object> holder = info.Holder();
50 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
51 v8SetReturnValueInt(info, impl->doNotCheckSecurityLongAttribute());
54 static void doNotCheckSecurityLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
56 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
57 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeGetter(info);
58 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
61 static void doNotCheckSecurityLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
63 v8::Handle<v8::Object> holder = info.Holder();
64 ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecurityLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate());
65 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
66 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState);
67 impl->setDoNotCheckSecurityLongAttribute(cppValue);
70 static void doNotCheckSecurityLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
72 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
73 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeSetter(v8Value, info);
74 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
77 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
79 v8::Handle<v8::Object> holder = info.Holder();
80 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
81 v8SetReturnValueInt(info, impl->doNotCheckSecurityReadonlyLongAttribute());
84 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
86 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
87 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadonlyLongAttributeAttributeGetter(info);
88 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
91 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
93 v8::Handle<v8::Object> holder = info.Holder();
94 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
95 v8SetReturnValueInt(info, impl->doNotCheckSecurityOnSetterLongAttribute());
98 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
100 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
101 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeGetter(info);
102 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
105 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
107 v8::Handle<v8::Object> holder = info.Holder();
108 ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecurityOnSetterLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate());
109 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
110 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState), exceptionState);
111 impl->setDoNotCheckSecurityOnSetterLongAttribute(cppValue);
114 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
116 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
117 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8Value, info);
118 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
121 static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
123 v8::Handle<v8::Object> holder = info.Holder();
124 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
125 v8SetReturnValueInt(info, impl->doNotCheckSecurityReplaceableReadonlyLongAttribute());
128 static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
130 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
131 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(info);
132 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
135 static void TestInterfaceCheckSecurityForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
137 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder());
138 v8::String::Utf8Value attributeName(name);
139 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate());
140 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
141 exceptionState.throwIfNeeded();
144 if (info.This()->IsObject())
145 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
148 static void TestInterfaceCheckSecurityForceSetAttributeOnThisCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
150 TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityForceSetAttributeOnThis(name, v8Value, info);
153 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
155 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(host);
156 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
159 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
161 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(host);
162 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
165 static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
167 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethod", "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate());
168 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder());
169 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
170 exceptionState.throwIfNeeded();
176 static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
178 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
179 TestInterfaceCheckSecurityV8Internal::voidMethodMethod(info);
180 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
183 static void doNotCheckSecurityVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
185 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder());
186 impl->doNotCheckSecurityVoidMethod();
189 static void doNotCheckSecurityVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
191 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
192 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethod(info);
193 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
196 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
198 static int domTemplateKey; // This address is used for a key to look up the dom template.
199 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
200 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
202 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
203 if (holder.IsEmpty()) {
204 // This is only reachable via |object.__proto__.func|, in which case it
205 // has already passed the same origin security check
206 v8SetReturnValue(info, privateTemplate->GetFunction());
209 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
210 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) {
211 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
212 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
213 v8SetReturnValue(info, sharedTemplate->GetFunction());
217 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityVoidMethod"));
218 if (!hiddenValue.IsEmpty()) {
219 v8SetReturnValue(info, hiddenValue);
223 v8SetReturnValue(info, privateTemplate->GetFunction());
226 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
228 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
229 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetter(info);
230 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
233 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
235 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder());
236 impl->doNotCheckSecurityDoNotCheckSignatureVoidMethod();
239 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
241 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
242 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(info);
243 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
246 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
248 static int domTemplateKey; // This address is used for a key to look up the dom template.
249 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
250 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0);
252 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
253 if (holder.IsEmpty()) {
254 // This is only reachable via |object.__proto__.func|, in which case it
255 // has already passed the same origin security check
256 v8SetReturnValue(info, privateTemplate->GetFunction());
259 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
260 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) {
261 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
262 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0);
263 v8SetReturnValue(info, sharedTemplate->GetFunction());
267 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityDoNotCheckSignatureVoidMethod"));
268 if (!hiddenValue.IsEmpty()) {
269 v8SetReturnValue(info, hiddenValue);
273 v8SetReturnValue(info, privateTemplate->GetFunction());
276 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
278 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
279 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetter(info);
280 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
283 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
285 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder());
286 impl->doNotCheckSecurityPerWorldBindingsVoidMethod();
289 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
291 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
292 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethod(info);
293 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
296 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
298 static int domTemplateKey; // This address is used for a key to look up the dom template.
299 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
300 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
302 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
303 if (holder.IsEmpty()) {
304 // This is only reachable via |object.__proto__.func|, in which case it
305 // has already passed the same origin security check
306 v8SetReturnValue(info, privateTemplate->GetFunction());
309 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
310 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) {
311 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
312 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
313 v8SetReturnValue(info, sharedTemplate->GetFunction());
317 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityPerWorldBindingsVoidMethod"));
318 if (!hiddenValue.IsEmpty()) {
319 v8SetReturnValue(info, hiddenValue);
323 v8SetReturnValue(info, privateTemplate->GetFunction());
326 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
328 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
329 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(info);
330 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
333 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
335 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder());
336 impl->doNotCheckSecurityPerWorldBindingsVoidMethod();
339 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
341 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
342 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(info);
343 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
346 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterForMainWorld(const v8::PropertyCallbackInfo<v8::Value>& info)
348 static int domTemplateKey; // This address is used for a key to look up the dom template.
349 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
350 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
352 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
353 if (holder.IsEmpty()) {
354 // This is only reachable via |object.__proto__.func|, in which case it
355 // has already passed the same origin security check
356 v8SetReturnValue(info, privateTemplate->GetFunction());
359 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
360 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) {
361 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
362 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
363 v8SetReturnValue(info, sharedTemplate->GetFunction());
367 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityPerWorldBindingsVoidMethod"));
368 if (!hiddenValue.IsEmpty()) {
369 v8SetReturnValue(info, hiddenValue);
373 v8SetReturnValue(info, privateTemplate->GetFunction());
376 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallbackForMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
378 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
379 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterForMainWorld(info);
380 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
383 static void doNotCheckSecurityUnforgeableVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
385 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info.Holder());
386 impl->doNotCheckSecurityUnforgeableVoidMethod();
389 static void doNotCheckSecurityUnforgeableVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
391 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
392 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethod(info);
393 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
396 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
398 static int domTemplateKey; // This address is used for a key to look up the dom template.
399 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
400 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
402 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
403 if (holder.IsEmpty()) {
404 // This is only reachable via |object.__proto__.func|, in which case it
405 // has already passed the same origin security check
406 v8SetReturnValue(info, privateTemplate->GetFunction());
409 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
410 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), DoNotReportSecurityError)) {
411 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
412 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
413 v8SetReturnValue(info, sharedTemplate->GetFunction());
417 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityUnforgeableVoidMethod"));
418 if (!hiddenValue.IsEmpty()) {
419 v8SetReturnValue(info, hiddenValue);
423 v8SetReturnValue(info, privateTemplate->GetFunction());
426 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
428 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
429 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(info);
430 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
433 static void TestInterfaceCheckSecurityOriginSafeMethodSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
435 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
436 if (holder.IsEmpty())
438 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(holder);
439 v8::String::Utf8Value attributeName(name);
440 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate());
441 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
442 exceptionState.throwIfNeeded();
446 V8HiddenValue::setHiddenValue(info.GetIsolate(), v8::Handle<v8::Object>::Cast(info.This()), name, v8Value);
449 static void TestInterfaceCheckSecurityOriginSafeMethodSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
451 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
452 TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetter(name, v8Value, info);
453 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
456 } // namespace TestInterfaceCheckSecurityV8Internal
458 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceCheckSecurityAttributes[] = {
459 {"longAttribute", TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
460 {"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},
461 {"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},
462 {"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},
463 {"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},
466 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceCheckSecurityMethods[] = {
467 {"voidMethod", TestInterfaceCheckSecurityV8Internal::voidMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
470 static void installV8TestInterfaceCheckSecurityTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
472 functionTemplate->ReadOnlyPrototype();
474 v8::Local<v8::Signature> defaultSignature;
475 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceCheckSecurity", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceCheckSecurity::internalFieldCount,
476 V8TestInterfaceCheckSecurityAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceCheckSecurityAttributes),
478 V8TestInterfaceCheckSecurityMethods, WTF_ARRAY_LENGTH(V8TestInterfaceCheckSecurityMethods),
480 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
481 ALLOW_UNUSED_LOCAL(instanceTemplate);
482 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
483 ALLOW_UNUSED_LOCAL(prototypeTemplate);
484 instanceTemplate->SetAccessCheckCallbacks(TestInterfaceCheckSecurityV8Internal::namedSecurityCheck, TestInterfaceCheckSecurityV8Internal::indexedSecurityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestInterfaceCheckSecurity::wrapperTypeInfo)));
485 static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityVoidMethodOriginSafeAttributeConfiguration = {
486 "doNotCheckSecurityVoidMethod", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance,
488 V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::ObjectTemplate>(), doNotCheckSecurityVoidMethodOriginSafeAttributeConfiguration, isolate);
489 static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeAttributeConfiguration = {
490 "doNotCheckSecurityDoNotCheckSignatureVoidMethod", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance,
492 V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::ObjectTemplate>(), doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeAttributeConfiguration, isolate);
493 static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeAttributeConfiguration = {
494 "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,
496 V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::ObjectTemplate>(), doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeAttributeConfiguration, isolate);
497 static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityUnforgeableVoidMethodOriginSafeAttributeConfiguration = {
498 "doNotCheckSecurityUnforgeableVoidMethod", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback, 0, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance,
500 V8DOMConfiguration::installAttribute(instanceTemplate, v8::Handle<v8::ObjectTemplate>(), doNotCheckSecurityUnforgeableVoidMethodOriginSafeAttributeConfiguration, isolate);
502 // Custom toString template
503 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
506 v8::Handle<v8::FunctionTemplate> V8TestInterfaceCheckSecurity::domTemplate(v8::Isolate* isolate)
508 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceCheckSecurityTemplate);
511 bool V8TestInterfaceCheckSecurity::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
513 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
516 v8::Handle<v8::Object> V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
518 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
521 TestInterfaceCheckSecurity* V8TestInterfaceCheckSecurity::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
523 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceCheckSecurity>() : 0;
526 void V8TestInterfaceCheckSecurity::refObject(ScriptWrappableBase* scriptWrappableBase)
528 scriptWrappableBase->toImpl<TestInterfaceCheckSecurity>()->ref();
531 void V8TestInterfaceCheckSecurity::derefObject(ScriptWrappableBase* scriptWrappableBase)
533 scriptWrappableBase->toImpl<TestInterfaceCheckSecurity>()->deref();
537 v8::Handle<v8::Value> toV8NoInline(TestInterfaceCheckSecurity* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
539 return toV8(impl, creationContext, isolate);