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 "RuntimeEnabledFeatures.h"
11 #include "bindings/v8/BindingSecurity.h"
12 #include "bindings/v8/ExceptionState.h"
13 #include "bindings/v8/V8DOMConfiguration.h"
14 #include "bindings/v8/V8HiddenValue.h"
15 #include "bindings/v8/V8ObjectConstructor.h"
16 #include "core/dom/ContextFeatures.h"
17 #include "core/dom/Document.h"
18 #include "platform/TraceEvent.h"
19 #include "wtf/GetPtr.h"
20 #include "wtf/RefPtr.h"
24 static void initializeScriptWrappableForInterface(TestInterfaceCheckSecurity* object)
26 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfaceCheckSecurity::wrapperTypeInfo);
32 } // namespace WebCore
34 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceCheckSecurity* object)
36 WebCore::initializeScriptWrappableForInterface(object);
40 const WrapperTypeInfo V8TestInterfaceCheckSecurity::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceCheckSecurity::domTemplate, V8TestInterfaceCheckSecurity::derefObject, 0, 0, 0, V8TestInterfaceCheckSecurity::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false };
42 namespace TestInterfaceCheckSecurityV8Internal {
44 template <typename T> void V8_USE(T) { }
46 static void longAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
48 v8::Handle<v8::Object> holder = info.Holder();
49 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
50 v8SetReturnValueInt(info, impl->longAttribute());
53 static void longAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
55 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
56 TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetter(info);
57 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
60 static void doNotCheckSecurityLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
62 v8::Handle<v8::Object> holder = info.Holder();
63 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
64 v8SetReturnValueInt(info, impl->doNotCheckSecurityLongAttribute());
67 static void doNotCheckSecurityLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
69 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
70 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeGetter(info);
71 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
74 static void doNotCheckSecurityLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
76 v8::Handle<v8::Object> holder = info.Holder();
77 ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecurityLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate());
78 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
79 V8TRYCATCH_EXCEPTION_VOID(int, cppValue, toInt32(v8Value, exceptionState), exceptionState);
80 impl->setDoNotCheckSecurityLongAttribute(cppValue);
83 static void doNotCheckSecurityLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
85 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
86 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeSetter(v8Value, info);
87 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
90 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
92 v8::Handle<v8::Object> holder = info.Holder();
93 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
94 v8SetReturnValueInt(info, impl->doNotCheckSecurityReadonlyLongAttribute());
97 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
99 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
100 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadonlyLongAttributeAttributeGetter(info);
101 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
104 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
106 v8::Handle<v8::Object> holder = info.Holder();
107 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
108 v8SetReturnValueInt(info, impl->doNotCheckSecurityOnSetterLongAttribute());
111 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
113 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
114 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeGetter(info);
115 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
118 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
120 v8::Handle<v8::Object> holder = info.Holder();
121 ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecurityOnSetterLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate());
122 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
123 V8TRYCATCH_EXCEPTION_VOID(int, cppValue, toInt32(v8Value, exceptionState), exceptionState);
124 impl->setDoNotCheckSecurityOnSetterLongAttribute(cppValue);
127 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
129 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
130 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8Value, info);
131 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
134 static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
136 v8::Handle<v8::Object> holder = info.Holder();
137 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
138 v8SetReturnValueInt(info, impl->doNotCheckSecurityReplaceableReadonlyLongAttribute());
141 static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
143 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
144 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(info);
145 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
148 static void TestInterfaceCheckSecurityReplaceableAttributeSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
150 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
151 v8::Isolate* isolate = info.GetIsolate();
152 v8::String::Utf8Value attributeName(name);
153 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), isolate);
154 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), exceptionState)) {
155 exceptionState.throwIfNeeded();
158 info.This()->ForceSet(name, v8Value);
161 static void TestInterfaceCheckSecurityReplaceableAttributeSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
163 TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityReplaceableAttributeSetter(name, v8Value, info);
166 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
168 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(host);
169 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
172 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
174 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(host);
175 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
178 static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
180 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethod", "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate());
181 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
182 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
183 exceptionState.throwIfNeeded();
189 static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
191 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
192 TestInterfaceCheckSecurityV8Internal::voidMethodMethod(info);
193 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
196 static void doNotCheckSecurityVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
198 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
199 impl->doNotCheckSecurityVoidMethod();
202 static void doNotCheckSecurityVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
204 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
205 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethod(info);
206 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
209 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
211 v8::Isolate* isolate = info.GetIsolate();
212 static int domTemplateKey; // This address is used for a key to look up the dom template.
213 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
214 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
216 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
217 if (holder.IsEmpty()) {
218 // This is only reachable via |object.__proto__.func|, in which case it
219 // has already passed the same origin security check
220 v8SetReturnValue(info, privateTemplate->GetFunction());
223 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
224 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
225 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
226 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
227 v8SetReturnValue(info, sharedTemplate->GetFunction());
231 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityVoidMethod"));
232 if (!hiddenValue.IsEmpty()) {
233 v8SetReturnValue(info, hiddenValue);
237 v8SetReturnValue(info, privateTemplate->GetFunction());
240 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
242 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
243 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetter(info);
244 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
247 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
249 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
250 impl->doNotCheckSecurityDoNotCheckSignatureVoidMethod();
253 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
255 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
256 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(info);
257 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
260 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
262 v8::Isolate* isolate = info.GetIsolate();
263 static int domTemplateKey; // This address is used for a key to look up the dom template.
264 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
265 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0);
267 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
268 if (holder.IsEmpty()) {
269 // This is only reachable via |object.__proto__.func|, in which case it
270 // has already passed the same origin security check
271 v8SetReturnValue(info, privateTemplate->GetFunction());
274 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
275 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
276 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
277 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0);
278 v8SetReturnValue(info, sharedTemplate->GetFunction());
282 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityDoNotCheckSignatureVoidMethod"));
283 if (!hiddenValue.IsEmpty()) {
284 v8SetReturnValue(info, hiddenValue);
288 v8SetReturnValue(info, privateTemplate->GetFunction());
291 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
293 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
294 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetter(info);
295 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
298 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
300 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
301 impl->doNotCheckSecurityPerWorldBindingsVoidMethod();
304 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
306 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
307 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethod(info);
308 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
311 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
313 v8::Isolate* isolate = info.GetIsolate();
314 static int domTemplateKey; // This address is used for a key to look up the dom template.
315 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
316 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
318 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
319 if (holder.IsEmpty()) {
320 // This is only reachable via |object.__proto__.func|, in which case it
321 // has already passed the same origin security check
322 v8SetReturnValue(info, privateTemplate->GetFunction());
325 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
326 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
327 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
328 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
329 v8SetReturnValue(info, sharedTemplate->GetFunction());
333 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityPerWorldBindingsVoidMethod"));
334 if (!hiddenValue.IsEmpty()) {
335 v8SetReturnValue(info, hiddenValue);
339 v8SetReturnValue(info, privateTemplate->GetFunction());
342 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
344 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
345 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(info);
346 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
349 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
351 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
352 impl->doNotCheckSecurityPerWorldBindingsVoidMethod();
355 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
357 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
358 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(info);
359 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
362 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterForMainWorld(const v8::PropertyCallbackInfo<v8::Value>& info)
364 v8::Isolate* isolate = info.GetIsolate();
365 static int domTemplateKey; // This address is used for a key to look up the dom template.
366 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
367 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
369 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
370 if (holder.IsEmpty()) {
371 // This is only reachable via |object.__proto__.func|, in which case it
372 // has already passed the same origin security check
373 v8SetReturnValue(info, privateTemplate->GetFunction());
376 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
377 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
378 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
379 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
380 v8SetReturnValue(info, sharedTemplate->GetFunction());
384 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityPerWorldBindingsVoidMethod"));
385 if (!hiddenValue.IsEmpty()) {
386 v8SetReturnValue(info, hiddenValue);
390 v8SetReturnValue(info, privateTemplate->GetFunction());
393 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallbackForMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
395 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
396 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterForMainWorld(info);
397 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
400 static void doNotCheckSecurityReadOnlyVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
402 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
403 impl->doNotCheckSecurityReadOnlyVoidMethod();
406 static void doNotCheckSecurityReadOnlyVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
408 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
409 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodMethod(info);
410 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
413 static void doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
415 v8::Isolate* isolate = info.GetIsolate();
416 static int domTemplateKey; // This address is used for a key to look up the dom template.
417 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
418 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
420 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
421 if (holder.IsEmpty()) {
422 // This is only reachable via |object.__proto__.func|, in which case it
423 // has already passed the same origin security check
424 v8SetReturnValue(info, privateTemplate->GetFunction());
427 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
428 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
429 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
430 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
431 v8SetReturnValue(info, sharedTemplate->GetFunction());
435 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityReadOnlyVoidMethod"));
436 if (!hiddenValue.IsEmpty()) {
437 v8SetReturnValue(info, hiddenValue);
441 v8SetReturnValue(info, privateTemplate->GetFunction());
444 static void doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
446 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
447 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetter(info);
448 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
451 static void doNotCheckSecurityUnforgeableVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
453 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder());
454 impl->doNotCheckSecurityUnforgeableVoidMethod();
457 static void doNotCheckSecurityUnforgeableVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
459 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
460 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethod(info);
461 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
464 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
466 v8::Isolate* isolate = info.GetIsolate();
467 static int domTemplateKey; // This address is used for a key to look up the dom template.
468 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
469 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
471 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
472 if (holder.IsEmpty()) {
473 // This is only reachable via |object.__proto__.func|, in which case it
474 // has already passed the same origin security check
475 v8SetReturnValue(info, privateTemplate->GetFunction());
478 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
479 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) {
480 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
481 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
482 v8SetReturnValue(info, sharedTemplate->GetFunction());
486 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityUnforgeableVoidMethod"));
487 if (!hiddenValue.IsEmpty()) {
488 v8SetReturnValue(info, hiddenValue);
492 v8SetReturnValue(info, privateTemplate->GetFunction());
495 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
497 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
498 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(info);
499 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
502 static void TestInterfaceCheckSecurityOriginSafeMethodSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
504 v8::Isolate* isolate = info.GetIsolate();
505 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate);
506 if (holder.IsEmpty())
508 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder);
509 v8::String::Utf8Value attributeName(name);
510 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), isolate);
511 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), exceptionState)) {
512 exceptionState.throwIfNeeded();
516 V8HiddenValue::setHiddenValue(isolate, info.This(), name, v8Value);
519 static void TestInterfaceCheckSecurityOriginSafeMethodSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
521 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
522 TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetter(name, v8Value, info);
523 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
526 } // namespace TestInterfaceCheckSecurityV8Internal
528 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceCheckSecurityAttributes[] = {
529 {"longAttribute", TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
530 {"doNotCheckSecurityLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
531 {"doNotCheckSecurityReadonlyLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_READ), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
532 {"doNotCheckSecurityOnSetterLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
533 {"doNotCheckSecurityReplaceableReadonlyLongAttribute", TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityReplaceableAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
536 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceCheckSecurityMethods[] = {
537 {"voidMethod", TestInterfaceCheckSecurityV8Internal::voidMethodMethodCallback, 0, 0},
540 static void configureV8TestInterfaceCheckSecurityTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
542 functionTemplate->ReadOnlyPrototype();
544 v8::Local<v8::Signature> defaultSignature;
545 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceCheckSecurity", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceCheckSecurity::internalFieldCount,
546 V8TestInterfaceCheckSecurityAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceCheckSecurityAttributes),
548 V8TestInterfaceCheckSecurityMethods, WTF_ARRAY_LENGTH(V8TestInterfaceCheckSecurityMethods),
550 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
551 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
552 instanceTemplate->SetAccessCheckCallbacks(TestInterfaceCheckSecurityV8Internal::namedSecurityCheck, TestInterfaceCheckSecurityV8Internal::indexedSecurityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestInterfaceCheckSecurity::wrapperTypeInfo)));
553 prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
554 prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityDoNotCheckSignatureVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
555 if (DOMWrapperWorld::current(isolate)->isMainWorld()) {
556 prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityPerWorldBindingsVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallbackForMainWorld, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
558 prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityPerWorldBindingsVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
560 prototypeTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityReadOnlyVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetterCallback, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly));
561 instanceTemplate->SetAccessor(v8AtomicString(isolate, "doNotCheckSecurityUnforgeableVoidMethod"), TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
563 // Custom toString template
564 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
567 v8::Handle<v8::FunctionTemplate> V8TestInterfaceCheckSecurity::domTemplate(v8::Isolate* isolate)
569 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
570 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo));
571 if (!result.IsEmpty())
574 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
575 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
576 configureV8TestInterfaceCheckSecurityTemplate(result, isolate);
577 data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result);
581 bool V8TestInterfaceCheckSecurity::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
583 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
586 v8::Handle<v8::Object> V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
588 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
591 TestInterfaceCheckSecurity* V8TestInterfaceCheckSecurity::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
593 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
596 v8::Handle<v8::Object> V8TestInterfaceCheckSecurity::createWrapper(PassRefPtr<TestInterfaceCheckSecurity> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
599 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceCheckSecurity>(impl.get(), isolate));
600 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
601 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
602 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
603 // the same object de-ref functions, though, so use that as the basis of the check.
604 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
607 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
608 if (UNLIKELY(wrapper.IsEmpty()))
611 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
612 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceCheckSecurity>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
616 void V8TestInterfaceCheckSecurity::derefObject(void* object)
618 fromInternalPointer(object)->deref();
622 v8::Handle<v8::Value> toV8NoInline(TestInterfaceCheckSecurity* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
624 return toV8(impl, creationContext, isolate);
627 } // namespace WebCore