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

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

Issue 101403002: IDL compiler: Consolidate test IDL files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More Created 7 years 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 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
32
33 #include "config.h"
34 #include "V8TestCheckSecurityInterface.h"
35
36 #include "RuntimeEnabledFeatures.h"
37 #include "bindings/v8/BindingSecurity.h"
38 #include "bindings/v8/ExceptionMessages.h"
39 #include "bindings/v8/ExceptionState.h"
40 #include "bindings/v8/ScriptController.h"
41 #include "bindings/v8/V8Binding.h"
42 #include "bindings/v8/V8DOMConfiguration.h"
43 #include "bindings/v8/V8DOMWrapper.h"
44 #include "core/dom/ContextFeatures.h"
45 #include "core/dom/Document.h"
46 #include "platform/TraceEvent.h"
47 #include "wtf/UnusedParam.h"
48
49 namespace WebCore {
50
51 static void initializeScriptWrappableForInterface(TestCheckSecurityInterface* ob ject)
52 {
53 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
54 ScriptWrappable::setTypeInfoInObject(object, &V8TestCheckSecurityInterfa ce::wrapperTypeInfo);
55 else
56 ASSERT_NOT_REACHED();
57 }
58
59 } // namespace WebCore
60
61 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows:
62 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
63 // in the global namespace.
64 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c)
65 void webCoreInitializeScriptWrappableForInterface(WebCore::TestCheckSecurityInte rface* object)
66 {
67 WebCore::initializeScriptWrappableForInterface(object);
68 }
69
70 namespace WebCore {
71 const WrapperTypeInfo V8TestCheckSecurityInterface::wrapperTypeInfo = { gin::kEm bedderBlink, V8TestCheckSecurityInterface::GetTemplate, V8TestCheckSecurityInter face::derefObject, 0, 0, 0, V8TestCheckSecurityInterface::installPerContextEnabl edMethods, 0, WrapperTypeObjectPrototype };
72
73 namespace TestCheckSecurityInterfaceV8Internal {
74
75 template <typename T> void V8_USE(T) { }
76
77 static void longAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Valu e>& info)
78 {
79 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
80 v8SetReturnValueInt(info, imp->longAttribute());
81 }
82
83 static void longAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8 ::PropertyCallbackInfo<v8::Value>& info)
84 {
85 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
86 TestCheckSecurityInterfaceV8Internal::longAttributeAttributeGetter(info);
87 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
88 }
89
90 static void doNotCheckSecurityLongAttributeAttributeGetter(const v8::PropertyCal lbackInfo<v8::Value>& info)
91 {
92 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
93 v8SetReturnValueInt(info, imp->doNotCheckSecurityLongAttribute());
94 }
95
96 static void doNotCheckSecurityLongAttributeAttributeGetterCallback(v8::Local<v8: :String>, const v8::PropertyCallbackInfo<v8::Value>& info)
97 {
98 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
99 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityLongAttributeAttribu teGetter(info);
100 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
101 }
102
103 static void doNotCheckSecurityLongAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
104 {
105 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
106 V8TRYCATCH_VOID(int, cppValue, toInt32(jsValue));
107 imp->setDoNotCheckSecurityLongAttribute(cppValue);
108 }
109
110 static void doNotCheckSecurityLongAttributeAttributeSetterCallback(v8::Local<v8: :String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& in fo)
111 {
112 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
113 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityLongAttributeAttribu teSetter(jsValue, info);
114 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
115 }
116
117 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetter(const v8::Pro pertyCallbackInfo<v8::Value>& info)
118 {
119 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
120 v8SetReturnValueInt(info, imp->doNotCheckSecurityReadonlyLongAttribute());
121 }
122
123 static void doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback(v8::L ocal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
124 {
125 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
126 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityReadonlyLongAttribut eAttributeGetter(info);
127 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
128 }
129
130 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetter(const v8::Pro pertyCallbackInfo<v8::Value>& info)
131 {
132 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
133 v8SetReturnValueInt(info, imp->doNotCheckSecurityOnSetterLongAttribute());
134 }
135
136 static void doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback(v8::L ocal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
137 {
138 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
139 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityOnSetterLongAttribut eAttributeGetter(info);
140 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
141 }
142
143 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetter(v8::Local<v8: :Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
144 {
145 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
146 V8TRYCATCH_VOID(int, cppValue, toInt32(jsValue));
147 imp->setDoNotCheckSecurityOnSetterLongAttribute(cppValue);
148 }
149
150 static void doNotCheckSecurityOnSetterLongAttributeAttributeSetterCallback(v8::L ocal<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v oid>& info)
151 {
152 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
153 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityOnSetterLongAttribut eAttributeSetter(jsValue, info);
154 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
155 }
156
157 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>)
158 {
159 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(ho st);
160 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
161 }
162
163 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>)
164 {
165 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(ho st);
166 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
167 }
168
169 static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
170 {
171 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
172 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
173 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
174 exceptionState.throwIfNeeded();
175 return;
176 }
177 imp->voidMethod();
178 }
179
180 static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
181 {
182 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
183 TestCheckSecurityInterfaceV8Internal::voidMethodMethod(info);
184 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
185 }
186
187 static void doNotCheckSecurityVoidMethodMethod(const v8::FunctionCallbackInfo<v8 ::Value>& info)
188 {
189 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
190 imp->doNotCheckSecurityVoidMethod();
191 }
192
193 static void doNotCheckSecurityVoidMethodMethodCallback(const v8::FunctionCallbac kInfo<v8::Value>& info)
194 {
195 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
196 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityVoidMethodMethod(inf o);
197 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
198 }
199
200 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetter(const v8::Propert yCallbackInfo<v8::Value>& info)
201 {
202 // This is only for getting a unique pointer which we can pass to privateTem plate.
203 static int privateTemplateUniqueKey;
204 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
205 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
206 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal:: doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(in fo.GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8TestC heckSecurityInterface::wrapperTypeInfo, currentWorldType)), 0);
207
208 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), currentWorldType));
209 if (holder.IsEmpty()) {
210 // This is only reachable via |object.__proto__.func|, in which case it
211 // has already passed the same origin security check
212 v8SetReturnValue(info, privateTemplate->GetFunction());
213 return;
214 }
215 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol der);
216 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
217 static int sharedTemplateUniqueKey;
218 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal ::doNotCheckSecurityVoidMethodMethodCallback, v8Undefined(), v8::Signature::New( info.GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8Tes tCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 0);
219 v8SetReturnValue(info, sharedTemplate->GetFunction());
220 return;
221 }
222
223 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewFromUtf8(info.GetIsolate(), "doNotCheckSecurityVoidMethod", v8::String::kInter nalizedString));
224 if (!hiddenValue.IsEmpty()) {
225 v8SetReturnValue(info, hiddenValue);
226 return;
227 }
228
229 v8SetReturnValue(info, privateTemplate->GetFunction());
230 }
231
232 static void doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback(v8::Local <v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
233 {
234 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
235 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityVoidMethodOriginSafe MethodGetter(info);
236 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
237 }
238
239 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethod(const v8::Functio nCallbackInfo<v8::Value>& info)
240 {
241 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
242 imp->doNotCheckSecurityPerWorldBindingsVoidMethod();
243 }
244
245 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback(const v8: :FunctionCallbackInfo<v8::Value>& info)
246 {
247 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
248 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityPerWorldBindingsVoid MethodMethod(info);
249 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
250 }
251
252 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetter(c onst v8::PropertyCallbackInfo<v8::Value>& info)
253 {
254 // This is only for getting a unique pointer which we can pass to privateTem plate.
255 static int privateTemplateUniqueKey;
256 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
257 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
258 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal:: doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8::S ignature::New(info.GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawT emplate(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 0);
259
260 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), currentWorldType));
261 if (holder.IsEmpty()) {
262 // This is only reachable via |object.__proto__.func|, in which case it
263 // has already passed the same origin security check
264 v8SetReturnValue(info, privateTemplate->GetFunction());
265 return;
266 }
267 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol der);
268 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
269 static int sharedTemplateUniqueKey;
270 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal ::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallback, v8Undefined(), v8: :Signature::New(info.GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->ra wTemplate(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 0) ;
271 v8SetReturnValue(info, sharedTemplate->GetFunction());
272 return;
273 }
274
275 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewFromUtf8(info.GetIsolate(), "doNotCheckSecurityPerWorldBindingsVoidMethod", v8 ::String::kInternalizedString));
276 if (!hiddenValue.IsEmpty()) {
277 v8SetReturnValue(info, hiddenValue);
278 return;
279 }
280
281 v8SetReturnValue(info, privateTemplate->GetFunction());
282 }
283
284 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCa llback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
285 {
286 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
287 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityPerWorldBindingsVoid MethodOriginSafeMethodGetter(info);
288 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
289 }
290
291 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
292 {
293 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
294 imp->doNotCheckSecurityPerWorldBindingsVoidMethod();
295 }
296
297 static void doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWor ld(const v8::FunctionCallbackInfo<v8::Value>& info)
298 {
299 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
300 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityPerWorldBindingsVoid MethodMethodForMainWorld(info);
301 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
302 }
303
304 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterFo rMainWorld(const v8::PropertyCallbackInfo<v8::Value>& info)
305 {
306 // This is only for getting a unique pointer which we can pass to privateTem plate.
307 static int privateTemplateUniqueKey;
308 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
309 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
310 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal:: doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Undefi ned(), v8::Signature::New(info.GetIsolate(), V8PerIsolateData::from(info.GetIsol ate())->rawTemplate(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorld Type)), 0);
311
312 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), currentWorldType));
313 if (holder.IsEmpty()) {
314 // This is only reachable via |object.__proto__.func|, in which case it
315 // has already passed the same origin security check
316 v8SetReturnValue(info, privateTemplate->GetFunction());
317 return;
318 }
319 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol der);
320 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
321 static int sharedTemplateUniqueKey;
322 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal ::doNotCheckSecurityPerWorldBindingsVoidMethodMethodCallbackForMainWorld, v8Unde fined(), v8::Signature::New(info.GetIsolate(), V8PerIsolateData::from(info.GetIs olate())->rawTemplate(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWor ldType)), 0);
323 v8SetReturnValue(info, sharedTemplate->GetFunction());
324 return;
325 }
326
327 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewFromUtf8(info.GetIsolate(), "doNotCheckSecurityPerWorldBindingsVoidMethod", v8 ::String::kInternalizedString));
328 if (!hiddenValue.IsEmpty()) {
329 v8SetReturnValue(info, hiddenValue);
330 return;
331 }
332
333 v8SetReturnValue(info, privateTemplate->GetFunction());
334 }
335
336 static void doNotCheckSecurityPerWorldBindingsVoidMethodOriginSafeMethodGetterCa llbackForMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Val ue>& info)
337 {
338 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
339 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityPerWorldBindingsVoid MethodOriginSafeMethodGetterForMainWorld(info);
340 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
341 }
342
343 static void doNotCheckSecurityReadOnlyVoidMethodMethod(const v8::FunctionCallbac kInfo<v8::Value>& info)
344 {
345 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
346 imp->doNotCheckSecurityReadOnlyVoidMethod();
347 }
348
349 static void doNotCheckSecurityReadOnlyVoidMethodMethodCallback(const v8::Functio nCallbackInfo<v8::Value>& info)
350 {
351 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
352 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityReadOnlyVoidMethodMe thod(info);
353 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
354 }
355
356 static void doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetter(const v8: :PropertyCallbackInfo<v8::Value>& info)
357 {
358 // This is only for getting a unique pointer which we can pass to privateTem plate.
359 static int privateTemplateUniqueKey;
360 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
361 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
362 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal:: doNotCheckSecurityReadOnlyVoidMethodMethodCallback, v8Undefined(), v8::Signature ::New(info.GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawTemplate( &V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 0);
363
364 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), currentWorldType));
365 if (holder.IsEmpty()) {
366 // This is only reachable via |object.__proto__.func|, in which case it
367 // has already passed the same origin security check
368 v8SetReturnValue(info, privateTemplate->GetFunction());
369 return;
370 }
371 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol der);
372 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
373 static int sharedTemplateUniqueKey;
374 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal ::doNotCheckSecurityReadOnlyVoidMethodMethodCallback, v8Undefined(), v8::Signatu re::New(info.GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawTemplat e(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 0);
375 v8SetReturnValue(info, sharedTemplate->GetFunction());
376 return;
377 }
378
379 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewFromUtf8(info.GetIsolate(), "doNotCheckSecurityReadOnlyVoidMethod", v8::String ::kInternalizedString));
380 if (!hiddenValue.IsEmpty()) {
381 v8SetReturnValue(info, hiddenValue);
382 return;
383 }
384
385 v8SetReturnValue(info, privateTemplate->GetFunction());
386 }
387
388 static void doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetterCallback(v 8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
389 {
390 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
391 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityReadOnlyVoidMethodOr iginSafeMethodGetter(info);
392 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
393 }
394
395 static void doNotCheckSecurityUnforgeableVoidMethodMethod(const v8::FunctionCall backInfo<v8::Value>& info)
396 {
397 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf o.Holder());
398 imp->doNotCheckSecurityUnforgeableVoidMethod();
399 }
400
401 static void doNotCheckSecurityUnforgeableVoidMethodMethodCallback(const v8::Func tionCallbackInfo<v8::Value>& info)
402 {
403 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
404 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityUnforgeableVoidMetho dMethod(info);
405 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
406 }
407
408 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
409 {
410 // This is only for getting a unique pointer which we can pass to privateTem plate.
411 static int privateTemplateUniqueKey;
412 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
413 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
414 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal:: doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signat ure::New(info.GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawTempla te(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 0);
415
416 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), currentWorldType));
417 if (holder.IsEmpty()) {
418 // This is only reachable via |object.__proto__.func|, in which case it
419 // has already passed the same origin security check
420 v8SetReturnValue(info, privateTemplate->GetFunction());
421 return;
422 }
423 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol der);
424 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
425 static int sharedTemplateUniqueKey;
426 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal ::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Sign ature::New(info.GetIsolate(), V8PerIsolateData::from(info.GetIsolate())->rawTemp late(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 0);
427 v8SetReturnValue(info, sharedTemplate->GetFunction());
428 return;
429 }
430
431 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewFromUtf8(info.GetIsolate(), "doNotCheckSecurityUnforgeableVoidMethod", v8::Str ing::kInternalizedString));
432 if (!hiddenValue.IsEmpty()) {
433 v8SetReturnValue(info, hiddenValue);
434 return;
435 }
436
437 v8SetReturnValue(info, privateTemplate->GetFunction());
438 }
439
440 static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetterCallbac k(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
441 {
442 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
443 TestCheckSecurityInterfaceV8Internal::doNotCheckSecurityUnforgeableVoidMetho dOriginSafeMethodGetter(info);
444 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
445 }
446
447 static void TestCheckSecurityInterfaceOriginSafeMethodSetter(v8::Local<v8::Strin g> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& inf o)
448 {
449 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), worldType(info.GetIso late())));
450 if (holder.IsEmpty())
451 return;
452 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol der);
453 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
454 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
455 exceptionState.throwIfNeeded();
456 return;
457 }
458
459 info.This()->SetHiddenValue(name, jsValue);
460 }
461
462 static void TestCheckSecurityInterfaceOriginSafeMethodSetterCallback(v8::Local<v 8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<vo id>& info)
463 {
464 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
465 TestCheckSecurityInterfaceV8Internal::TestCheckSecurityInterfaceOriginSafeMe thodSetter(name, jsValue, info);
466 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
467 }
468
469 } // namespace TestCheckSecurityInterfaceV8Internal
470
471 static const V8DOMConfiguration::AttributeConfiguration V8TestCheckSecurityInter faceAttributes[] = {
472 {"longAttribute", TestCheckSecurityInterfaceV8Internal::longAttributeAttribu teGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), stati c_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
473 {"doNotCheckSecurityLongAttribute", TestCheckSecurityInterfaceV8Internal::do NotCheckSecurityLongAttributeAttributeGetterCallback, TestCheckSecurityInterface 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), 0 /* on instance */},
474 {"doNotCheckSecurityReadonlyLongAttribute", TestCheckSecurityInterfaceV8Inte rnal::doNotCheckSecurityReadonlyLongAttributeAttributeGetterCallback, 0, 0, 0, 0 , static_cast<v8::AccessControl>(v8::ALL_CAN_READ), static_cast<v8::PropertyAttr ibute>(v8::None), 0 /* on instance */},
475 {"doNotCheckSecurityOnSetterLongAttribute", TestCheckSecurityInterfaceV8Inte rnal::doNotCheckSecurityOnSetterLongAttributeAttributeGetterCallback, TestCheckS ecurityInterfaceV8Internal::doNotCheckSecurityOnSetterLongAttributeAttributeSett erCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::ALL_CAN_WRITE), static_c ast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
476 };
477
478 static const V8DOMConfiguration::MethodConfiguration V8TestCheckSecurityInterfac eMethods[] = {
479 {"voidMethod", TestCheckSecurityInterfaceV8Internal::voidMethodMethodCallbac k, 0, 0},
480 };
481
482 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestCheckSecurityInterfaceTem plate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, W rapperWorldType currentWorldType)
483 {
484 functionTemplate->ReadOnlyPrototype();
485
486 v8::Local<v8::Signature> defaultSignature;
487 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestCheckSecurityInterface", v8::Local<v8::FunctionTemplate>(), V8TestChec kSecurityInterface::internalFieldCount,
488 V8TestCheckSecurityInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestCheckSecu rityInterfaceAttributes),
489 0, 0,
490 V8TestCheckSecurityInterfaceMethods, WTF_ARRAY_LENGTH(V8TestCheckSecurit yInterfaceMethods),
491 isolate, currentWorldType);
492 UNUSED_PARAM(defaultSignature);
493 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate();
494 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate();
495 UNUSED_PARAM(instanceTemplate);
496 UNUSED_PARAM(prototypeTemplate);
497 instanceTemplate->SetAccessCheckCallbacks(TestCheckSecurityInterfaceV8Intern al::namedSecurityCheck, TestCheckSecurityInterfaceV8Internal::indexedSecurityChe ck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestCheckSecurity Interface::wrapperTypeInfo)));
498 prototypeTemplate->SetAccessor(v8::String::NewFromUtf8(isolate, "doNotCheckS ecurityVoidMethod", v8::String::kInternalizedString), TestCheckSecurityInterface V8Internal::doNotCheckSecurityVoidMethodOriginSafeMethodGetterCallback, TestChec kSecurityInterfaceV8Internal::TestCheckSecurityInterfaceOriginSafeMethodSetterCa llback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8:: DontDelete));
499 if (currentWorldType == MainWorld) {
500 prototypeTemplate->SetAccessor(v8::String::NewFromUtf8(isolate, "doNotCh eckSecurityPerWorldBindingsVoidMethod", v8::String::kInternalizedString), TestCh eckSecurityInterfaceV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOrig inSafeMethodGetterCallbackForMainWorld, TestCheckSecurityInterfaceV8Internal::Te stCheckSecurityInterfaceOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_C AN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
501 } else {
502 prototypeTemplate->SetAccessor(v8::String::NewFromUtf8(isolate, "doNotCh eckSecurityPerWorldBindingsVoidMethod", v8::String::kInternalizedString), TestCh eckSecurityInterfaceV8Internal::doNotCheckSecurityPerWorldBindingsVoidMethodOrig inSafeMethodGetterCallback, TestCheckSecurityInterfaceV8Internal::TestCheckSecur ityInterfaceOriginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, sta tic_cast<v8::PropertyAttribute>(v8::DontDelete));
503 }
504 prototypeTemplate->SetAccessor(v8::String::NewFromUtf8(isolate, "doNotCheckS ecurityReadOnlyVoidMethod", v8::String::kInternalizedString), TestCheckSecurityI nterfaceV8Internal::doNotCheckSecurityReadOnlyVoidMethodOriginSafeMethodGetterCa llback, 0, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v 8::DontDelete | v8::ReadOnly));
505 instanceTemplate->SetAccessor(v8::String::NewFromUtf8(isolate, "doNotCheckSe curityUnforgeableVoidMethod", v8::String::kInternalizedString), TestCheckSecurit yInterfaceV8Internal::doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGet terCallback, TestCheckSecurityInterfaceV8Internal::TestCheckSecurityInterfaceOri ginSafeMethodSetterCallback, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::Pr opertyAttribute>(v8::DontDelete));
506
507 // Custom toString template
508 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate());
509 return functionTemplate;
510 }
511
512 v8::Handle<v8::FunctionTemplate> V8TestCheckSecurityInterface::GetTemplate(v8::I solate* isolate, WrapperWorldType currentWorldType)
513 {
514 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
515 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
516 if (result != data->templateMap(currentWorldType).end())
517 return result->value.newLocal(isolate);
518
519 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
520 v8::EscapableHandleScope handleScope(isolate);
521 v8::Local<v8::FunctionTemplate> templ =
522 ConfigureV8TestCheckSecurityInterfaceTemplate(data->rawTemplate(&wrapper TypeInfo, currentWorldType), isolate, currentWorldType);
523 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
524 return handleScope.Escape(templ);
525 }
526
527 bool V8TestCheckSecurityInterface::hasInstance(v8::Handle<v8::Value> jsValue, v8 ::Isolate* isolate, WrapperWorldType currentWorldType)
528 {
529 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType);
530 }
531
532 bool V8TestCheckSecurityInterface::hasInstanceInAnyWorld(v8::Handle<v8::Value> j sValue, v8::Isolate* isolate)
533 {
534 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
535 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld)
536 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld);
537 }
538
539 v8::Handle<v8::Object> V8TestCheckSecurityInterface::createWrapper(PassRefPtr<Te stCheckSecurityInterface> impl, v8::Handle<v8::Object> creationContext, v8::Isol ate* isolate)
540 {
541 ASSERT(impl);
542 ASSERT(!DOMDataStore::containsWrapper<V8TestCheckSecurityInterface>(impl.get (), isolate));
543 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
544 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
545 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
546 // the same object de-ref functions, though, so use that as the basis of the check.
547 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
548 }
549
550 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
551 if (UNLIKELY(wrapper.IsEmpty()))
552 return wrapper;
553
554 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
555 V8DOMWrapper::associateObjectWithWrapper<V8TestCheckSecurityInterface>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
556 return wrapper;
557 }
558
559 void V8TestCheckSecurityInterface::derefObject(void* object)
560 {
561 fromInternalPointer(object)->deref();
562 }
563
564 template<>
565 v8::Handle<v8::Value> toV8NoInline(TestCheckSecurityInterface* impl, v8::Handle< v8::Object> creationContext, v8::Isolate* isolate)
566 {
567 return toV8(impl, creationContext, isolate);
568 }
569
570 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698