Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: Source/bindings/tests/results/V8TestInterfaceCheckSecurity.cpp

Issue 557203002: Added core and modules to binding tests results for binding modularization. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6
7 #include "config.h"
8 #include "V8TestInterfaceCheckSecurity.h"
9
10 #include "bindings/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"
21
22 namespace blink {
23
24 const WrapperTypeInfo V8TestInterfaceCheckSecurity::wrapperTypeInfo = { gin::kEm bedderBlink, V8TestInterfaceCheckSecurity::domTemplate, V8TestInterfaceCheckSecu rity::refObject, V8TestInterfaceCheckSecurity::derefObject, V8TestInterfaceCheck Security::createPersistentHandle, 0, 0, 0, V8TestInterfaceCheckSecurity::install ConditionallyEnabledMethods, V8TestInterfaceCheckSecurity::installConditionallyE nabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInf o::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObjec t };
25
26 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfac eCheckSecurity.h.
27 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
28 // bindings/core/v8/ScriptWrappable.h.
29 const WrapperTypeInfo& TestInterfaceCheckSecurity::s_wrapperTypeInfo = V8TestInt erfaceCheckSecurity::wrapperTypeInfo;
30
31 namespace TestInterfaceCheckSecurityV8Internal {
32
33 template <typename T> void V8_USE(T) { }
34
35 static void longAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Valu e>& info)
36 {
37 v8::Handle<v8::Object> holder = info.Holder();
38 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
39 v8SetReturnValueInt(info, impl->longAttribute());
40 }
41
42 static void longAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8 ::PropertyCallbackInfo<v8::Value>& info)
43 {
44 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
45 TestInterfaceCheckSecurityV8Internal::longAttributeAttributeGetter(info);
46 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
47 }
48
49 static void doNotCheckSecurityLongAttributeAttributeGetter(const v8::PropertyCal lbackInfo<v8::Value>& info)
50 {
51 v8::Handle<v8::Object> holder = info.Holder();
52 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
53 v8SetReturnValueInt(info, impl->doNotCheckSecurityLongAttribute());
54 }
55
56 static void doNotCheckSecurityLongAttributeAttributeGetterCallback(v8::Local<v8: :String>, const v8::PropertyCallbackInfo<v8::Value>& info)
57 {
58 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
59 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttribu teGetter(info);
60 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
61 }
62
63 static void doNotCheckSecurityLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
64 {
65 v8::Handle<v8::Object> holder = info.Holder();
66 ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecu rityLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolate());
67 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
68 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState) , exceptionState);
69 impl->setDoNotCheckSecurityLongAttribute(cppValue);
70 }
71
72 static void doNotCheckSecurityLongAttributeAttributeSetterCallback(v8::Local<v8: :String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& in fo)
73 {
74 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
75 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityLongAttributeAttribu teSetter(v8Value, info);
76 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
77 }
78
79 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetter(const v8::Pro pertyCallbackInfo<v8::Value>& info)
80 {
81 v8::Handle<v8::Object> holder = info.Holder();
82 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
83 v8SetReturnValueInt(info, impl->doNotCheckSecurityReadonlyLongAttribute());
84 }
85
86 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback(v8::L ocal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
87 {
88 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
89 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReadonlyLongAttribut eAttributeGetter(info);
90 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
91 }
92
93 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetter(const v8::Pro pertyCallbackInfo<v8::Value>& info)
94 {
95 v8::Handle<v8::Object> holder = info.Holder();
96 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
97 v8SetReturnValueInt(info, impl->doNotCheckSecurityOnSetterLongAttribute());
98 }
99
100 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback(v8::L ocal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
101 {
102 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
103 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttribut eAttributeGetter(info);
104 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
105 }
106
107 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8::Local<v8: :Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
108 {
109 v8::Handle<v8::Object> holder = info.Holder();
110 ExceptionState exceptionState(ExceptionState::SetterContext, "doNotCheckSecu rityOnSetterLongAttribute", "TestInterfaceCheckSecurity", holder, info.GetIsolat e());
111 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
112 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState) , exceptionState);
113 impl->setDoNotCheckSecurityOnSetterLongAttribute(cppValue);
114 }
115
116 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback(v8::L ocal<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v oid>& info)
117 {
118 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
119 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttribut eAttributeSetter(v8Value, info);
120 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
121 }
122
123 static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetter(co nst v8::PropertyCallbackInfo<v8::Value>& info)
124 {
125 v8::Handle<v8::Object> holder = info.Holder();
126 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
127 v8SetReturnValueInt(info, impl->doNotCheckSecurityReplaceableReadonlyLongAtt ribute());
128 }
129
130 static void doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGetterCal lback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
131 {
132 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
133 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityReplaceableReadonlyL ongAttributeAttributeGetter(info);
134 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
135 }
136
137 static void TestInterfaceCheckSecurityForceSetAttributeOnThis(v8::Local<v8::Stri ng> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& in fo)
138 {
139 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info .Holder());
140 v8::String::Utf8Value attributeName(name);
141 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate());
142 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) {
143 exceptionState.throwIfNeeded();
144 return;
145 }
146 if (info.This()->IsObject())
147 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
148 }
149
150 static void TestInterfaceCheckSecurityForceSetAttributeOnThisCallback(v8::Local< v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v oid>& info)
151 {
152 TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityForceSetAttr ibuteOnThis(name, v8Value, info);
153 }
154
155 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>)
156 {
157 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(host );
158 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
159 }
160
161 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>)
162 {
163 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(host );
164 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
165 }
166
167 static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
168 {
169 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethod" , "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate());
170 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info .Holder());
171 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) {
172 exceptionState.throwIfNeeded();
173 return;
174 }
175 impl->voidMethod();
176 }
177
178 static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
179 {
180 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
181 TestInterfaceCheckSecurityV8Internal::voidMethodMethod(info);
182 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
183 }
184
185 static void doNotCheckSecurityVoidMethodMethod(const v8::FunctionCallbackInfo<v8 ::Value>& info)
186 {
187 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info .Holder());
188 impl->doNotCheckSecurityVoidMethod();
189 }
190
191 static void doNotCheckSecurityVoidMethodMethodCallback(const v8::FunctionCallbac kInfo<v8::Value>& info)
192 {
193 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
194 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMethod(inf o);
195 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
196 }
197
198 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetter(const v8::Propert yCallbackInfo<v8::Value>& info)
199 {
200 static int domTemplateKey; // This address is used for a key to look up the dom template.
201 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
202 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodMeth odCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterface CheckSecurity::domTemplate(info.GetIsolate())), 0);
203
204 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceIn PrototypeChain(info.This(), info.GetIsolate());
205 if (holder.IsEmpty()) {
206 // This is only reachable via |object.__proto__.func|, in which case it
207 // has already passed the same origin security check
208 v8SetReturnValue(info, privateTemplate->GetFunction());
209 return;
210 }
211 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
212 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) {
213 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
214 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMeth odMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInt erfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
215 v8SetReturnValue(info, sharedTemplate->GetFunction());
216 return;
217 }
218
219 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityVoidMethod "));
220 if (!hiddenValue.IsEmpty()) {
221 v8SetReturnValue(info, hiddenValue);
222 return;
223 }
224
225 v8SetReturnValue(info, privateTemplate->GetFunction());
226 }
227
228 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback(v8::Local <v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
229 {
230 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
231 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityVoidMethodOriginSafe MethodGetter(info);
232 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
233 }
234
235 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethod(const v8::Func tionCallbackInfo<v8::Value>& info)
236 {
237 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info .Holder());
238 impl->doNotCheckSecurityDoNotCheckSignatureVoidMethod();
239 }
240
241 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
242 {
243 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
244 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureV oidMethodMethod(info);
245 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
246 }
247
248 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGette r(const v8::PropertyCallbackInfo<v8::Value>& info)
249 {
250 static int domTemplateKey; // This address is used for a key to look up the dom template.
251 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
252 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSign atureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0);
253
254 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceIn PrototypeChain(info.This(), info.GetIsolate());
255 if (holder.IsEmpty()) {
256 // This is only reachable via |object.__proto__.func|, in which case it
257 // has already passed the same origin security check
258 v8SetReturnValue(info, privateTemplate->GetFunction());
259 return;
260 }
261 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
262 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) {
263 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
264 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotChe ckSignatureVoidMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0);
265 v8SetReturnValue(info, sharedTemplate->GetFunction());
266 return;
267 }
268
269 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityDoNotCheck SignatureVoidMethod"));
270 if (!hiddenValue.IsEmpty()) {
271 v8SetReturnValue(info, hiddenValue);
272 return;
273 }
274
275 v8SetReturnValue(info, privateTemplate->GetFunction());
276 }
277
278 static void doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethodGette rCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info )
279 {
280 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
281 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityDoNotCheckSignatureV oidMethodOriginSafeMethodGetter(info);
282 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
283 }
284
285 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethod(const v8::Functio nCallbackInfo<v8::Value>& info)
286 {
287 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info .Holder());
288 impl->doNotCheckSecurityPerWorldBindingsVoidMethod();
289 }
290
291 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback(const v8: :FunctionCallbackInfo<v8::Value>& info)
292 {
293 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
294 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoid MethodMethod(info);
295 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
296 }
297
298 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(c onst v8::PropertyCallbackInfo<v8::Value>& info)
299 {
300 static int domTemplateKey; // This address is used for a key to look up the dom template.
301 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
302 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindin gsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
303
304 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceIn PrototypeChain(info.This(), info.GetIsolate());
305 if (holder.IsEmpty()) {
306 // This is only reachable via |object.__proto__.func|, in which case it
307 // has already passed the same origin security check
308 v8SetReturnValue(info, privateTemplate->GetFunction());
309 return;
310 }
311 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
312 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) {
313 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
314 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorld BindingsVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsol ate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
315 v8SetReturnValue(info, sharedTemplate->GetFunction());
316 return;
317 }
318
319 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityPerWorldBi ndingsVoidMethod"));
320 if (!hiddenValue.IsEmpty()) {
321 v8SetReturnValue(info, hiddenValue);
322 return;
323 }
324
325 v8SetReturnValue(info, privateTemplate->GetFunction());
326 }
327
328 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCa llback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
329 {
330 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
331 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoid MethodOriginSafeMethodGetter(info);
332 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
333 }
334
335 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
336 {
337 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info .Holder());
338 impl->doNotCheckSecurityPerWorldBindingsVoidMethod();
339 }
340
341 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWor ld(const v8::FunctionCallbackInfo<v8::Value>& info)
342 {
343 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
344 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoid MethodMethodForMainWorld(info);
345 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
346 }
347
348 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterFo rMainWorld(const v8::PropertyCallbackInfo<v8::Value>& info)
349 {
350 static int domTemplateKey; // This address is used for a key to look up the dom template.
351 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
352 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindin gsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(info.G etIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
353
354 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceIn PrototypeChain(info.This(), info.GetIsolate());
355 if (holder.IsEmpty()) {
356 // This is only reachable via |object.__proto__.func|, in which case it
357 // has already passed the same origin security check
358 v8SetReturnValue(info, privateTemplate->GetFunction());
359 return;
360 }
361 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
362 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) {
363 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
364 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorld BindingsVoidMethodMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New( info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())) , 0);
365 v8SetReturnValue(info, sharedTemplate->GetFunction());
366 return;
367 }
368
369 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityPerWorldBi ndingsVoidMethod"));
370 if (!hiddenValue.IsEmpty()) {
371 v8SetReturnValue(info, hiddenValue);
372 return;
373 }
374
375 v8SetReturnValue(info, privateTemplate->GetFunction());
376 }
377
378 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCa llbackForMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Val ue>& info)
379 {
380 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
381 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityPerWorldBindingsVoid MethodOriginSafeMethodGetterForMainWorld(info);
382 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
383 }
384
385 static void doNotCheckSecurityUnforgeableVoidMethodMethod(const v8::FunctionCall backInfo<v8::Value>& info)
386 {
387 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(info .Holder());
388 impl->doNotCheckSecurityUnforgeableVoidMethod();
389 }
390
391 static void doNotCheckSecurityUnforgeableVoidMethodMethodCallback(const v8::Func tionCallbackInfo<v8::Value>& info)
392 {
393 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
394 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMetho dMethod(info);
395 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
396 }
397
398 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
399 {
400 static int domTemplateKey; // This address is used for a key to look up the dom template.
401 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
402 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoi dMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8Te stInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
403
404 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceIn PrototypeChain(info.This(), info.GetIsolate());
405 if (holder.IsEmpty()) {
406 // This is only reachable via |object.__proto__.func|, in which case it
407 // has already passed the same origin security check
408 v8SetReturnValue(info, privateTemplate->GetFunction());
409 return;
410 }
411 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
412 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) {
413 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
414 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgea bleVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate() , V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0);
415 v8SetReturnValue(info, sharedTemplate->GetFunction());
416 return;
417 }
418
419 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(info.GetIsolate(), "doNotCheckSecurityUnforgeabl eVoidMethod"));
420 if (!hiddenValue.IsEmpty()) {
421 v8SetReturnValue(info, hiddenValue);
422 return;
423 }
424
425 v8SetReturnValue(info, privateTemplate->GetFunction());
426 }
427
428 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallbac k(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
429 {
430 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
431 TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMetho dOriginSafeMethodGetter(info);
432 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
433 }
434
435 static void TestInterfaceCheckSecurityOriginSafeMethodSetter(v8::Local<v8::Strin g> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& inf o)
436 {
437 v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceIn PrototypeChain(info.This(), info.GetIsolate());
438 if (holder.IsEmpty())
439 return;
440 TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toImpl(hold er);
441 v8::String::Utf8Value attributeName(name);
442 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), info.GetIsolate());
443 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) {
444 exceptionState.throwIfNeeded();
445 return;
446 }
447
448 V8HiddenValue::setHiddenValue(info.GetIsolate(), v8::Handle<v8::Object>::Cas t(info.This()), name, v8Value);
449 }
450
451 static void TestInterfaceCheckSecurityOriginSafeMethodSetterCallback(v8::Local<v 8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<vo id>& info)
452 {
453 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
454 TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMe thodSetter(name, v8Value, info);
455 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
456 }
457
458 } // namespace TestInterfaceCheckSecurityV8Internal
459
460 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceCheckSecu rityAttributes[] = {
461 {"longAttribute", TestInterfaceCheckSecurityV8Internal::longAttributeAttribu teGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), stati c_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts , V8DOMConfiguration::OnInstance},
462 {"doNotCheckSecurityLongAttribute", TestInterfaceCheckSecurityV8Internal::do NotCheckSecurityLongAttributeAttributeGetterCallback, TestInterfaceCheckSecurity V8Internal::doNotCheckSecurityLongAttributeAttributeSetterCallback, 0, 0, 0, sta tic_cast<v8::AccessControl>(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE), static_cast<v 8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMC onfiguration::OnInstance},
463 {"doNotCheckSecurityReadonlyLongAttribute", TestInterfaceCheckSecurityV8Inte rnal::doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback, 0, 0, 0, 0 , static_cast<v8::AccessControl>(v8::ALL_CAN_READ), static_cast<v8::PropertyAttr ibute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::O nInstance},
464 {"doNotCheckSecurityOnSetterLongAttribute", TestInterfaceCheckSecurityV8Inte rnal::doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback, TestInterf aceCheckSecurityV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSett erCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_WRITE), static_c ast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V 8DOMConfiguration::OnInstance},
465 {"doNotCheckSecurityReplaceableReadonlyLongAttribute", TestInterfaceCheckSec urityV8Internal::doNotCheckSecurityReplaceableReadonlyLongAttributeAttributeGett erCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityForc eSetAttributeOnThisCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN _READ | v8::ALL_CAN_WRITE), static_cast<v8::PropertyAttribute>(v8::None), V8DOMC onfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
466 };
467
468 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceCheckSecurit yMethods[] = {
469 {"voidMethod", TestInterfaceCheckSecurityV8Internal::voidMethodMethodCallbac k, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
470 };
471
472 static void installV8TestInterfaceCheckSecurityTemplate(v8::Handle<v8::FunctionT emplate> functionTemplate, v8::Isolate* isolate)
473 {
474 functionTemplate->ReadOnlyPrototype();
475
476 v8::Local<v8::Signature> defaultSignature;
477 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfaceCheckSecurity", v8::Local<v8::FunctionTemplate>(), V8TestInte rfaceCheckSecurity::internalFieldCount,
478 V8TestInterfaceCheckSecurityAttributes, WTF_ARRAY_LENGTH(V8TestInterface CheckSecurityAttributes),
479 0, 0,
480 V8TestInterfaceCheckSecurityMethods, WTF_ARRAY_LENGTH(V8TestInterfaceChe ckSecurityMethods),
481 isolate);
482 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla te->InstanceTemplate();
483 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl ate->PrototypeTemplate();
484 instanceTemplate->SetAccessCheckCallbacks(TestInterfaceCheckSecurityV8Intern al::namedSecurityCheck, TestInterfaceCheckSecurityV8Internal::indexedSecurityChe ck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestInterfaceChec kSecurity::wrapperTypeInfo)));
485 static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityVo idMethodOriginSafeAttributeConfiguration = {
486 "doNotCheckSecurityVoidMethod", TestInterfaceCheckSecurityV8Internal::do NotCheckSecurityVoidMethodOriginSafeMethodGetterCallback, TestInterfaceCheckSecu rityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCallback, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, static_cast<v8 ::PropertyAttribute>(v8::DontDelete), V8DOMConfiguration::ExposedToAllScripts, V 8DOMConfiguration::OnInstance,
487 };
488 V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::Objec tTemplate>(), doNotCheckSecurityVoidMethodOriginSafeAttributeConfiguration, isol ate);
489 static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityDo NotCheckSignatureVoidMethodOriginSafeAttributeConfiguration = {
490 "doNotCheckSecurityDoNotCheckSignatureVoidMethod", TestInterfaceCheckSec urityV8Internal::doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeMethod GetterCallback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurity OriginSafeMethodSetterCallback, 0, 0, &V8TestInterfaceCheckSecurity::wrapperType Info, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete), V8DO MConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance,
491 };
492 V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::Objec tTemplate>(), doNotCheckSecurityDoNotCheckSignatureVoidMethodOriginSafeAttribute Configuration, isolate);
493 static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityPe rWorldBindingsVoidMethodOriginSafeAttributeConfiguration = {
494 "doNotCheckSecurityPerWorldBindingsVoidMethod", TestInterfaceCheckSecuri tyV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter Callback, TestInterfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOrigin SafeMethodSetterCallback, TestInterfaceCheckSecurityV8Internal::doNotCheckSecuri tyPerWorldBindingsVoidMethodOriginSafeMethodGetterCallbackForMainWorld, TestInte rfaceCheckSecurityV8Internal::TestInterfaceCheckSecurityOriginSafeMethodSetterCa llbackForMainWorld, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_ READ, static_cast<v8::PropertyAttribute>(v8::DontDelete), V8DOMConfiguration::Ex posedToAllScripts, V8DOMConfiguration::OnInstance,
495 };
496 V8DOMConfiguration::installAttribute(prototypeTemplate, v8::Handle<v8::Objec tTemplate>(), doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeAttributeCon figuration, isolate);
497 static const V8DOMConfiguration::AttributeConfiguration doNotCheckSecurityUn forgeableVoidMethodOriginSafeAttributeConfiguration = {
498 "doNotCheckSecurityUnforgeableVoidMethod", TestInterfaceCheckSecurityV8I nternal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallback, 0, 0, 0, &V8TestInterfaceCheckSecurity::wrapperTypeInfo, v8::ALL_CAN_READ, stati c_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly), V8DOMConfiguration ::ExposedToAllScripts, V8DOMConfiguration::OnInstance,
499 };
500 V8DOMConfiguration::installAttribute(instanceTemplate, v8::Handle<v8::Object Template>(), doNotCheckSecurityUnforgeableVoidMethodOriginSafeAttributeConfigura tion, isolate);
501
502 // Custom toString template
503 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :from(isolate)->toStringTemplate());
504 }
505
506 v8::Handle<v8::FunctionTemplate> V8TestInterfaceCheckSecurity::domTemplate(v8::I solate* isolate)
507 {
508 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), installV8TestInterfaceCheckSecurityTemplate);
509 }
510
511 bool V8TestInterfaceCheckSecurity::hasInstance(v8::Handle<v8::Value> v8Value, v8 ::Isolate* isolate)
512 {
513 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e);
514 }
515
516 v8::Handle<v8::Object> V8TestInterfaceCheckSecurity::findInstanceInPrototypeChai n(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
517 {
518 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe rTypeInfo, v8Value);
519 }
520
521 TestInterfaceCheckSecurity* V8TestInterfaceCheckSecurity::toImplWithTypeCheck(v8 ::Isolate* isolate, v8::Handle<v8::Value> value)
522 {
523 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle <v8::Object>::Cast(value))->toImpl<TestInterfaceCheckSecurity>() : 0;
524 }
525
526
527 void V8TestInterfaceCheckSecurity::refObject(ScriptWrappableBase* internalPointe r)
528 {
529 internalPointer->toImpl<TestInterfaceCheckSecurity>()->ref();
530 }
531
532 void V8TestInterfaceCheckSecurity::derefObject(ScriptWrappableBase* internalPoin ter)
533 {
534 internalPointer->toImpl<TestInterfaceCheckSecurity>()->deref();
535 }
536
537 WrapperPersistentNode* V8TestInterfaceCheckSecurity::createPersistentHandle(Scri ptWrappableBase* internalPointer)
538 {
539 ASSERT_NOT_REACHED();
540 return 0;
541 }
542
543 template<>
544 v8::Handle<v8::Value> toV8NoInline(TestInterfaceCheckSecurity* impl, v8::Handle< v8::Object> creationContext, v8::Isolate* isolate)
545 {
546 return toV8(impl, creationContext, isolate);
547 }
548
549 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698