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

Side by Side Diff: Source/bindings/tests/results/V8TestActiveDOMObject.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 "V8TestActiveDOMObject.h"
35
36 #include "RuntimeEnabledFeatures.h"
37 #include "V8Node.h"
38 #include "bindings/v8/BindingSecurity.h"
39 #include "bindings/v8/ExceptionMessages.h"
40 #include "bindings/v8/ExceptionState.h"
41 #include "bindings/v8/ScriptController.h"
42 #include "bindings/v8/V8Binding.h"
43 #include "bindings/v8/V8DOMActivityLogger.h"
44 #include "bindings/v8/V8DOMConfiguration.h"
45 #include "bindings/v8/V8DOMWrapper.h"
46 #include "core/dom/ContextFeatures.h"
47 #include "core/dom/Document.h"
48 #include "platform/TraceEvent.h"
49 #include "wtf/UnusedParam.h"
50
51 namespace WebCore {
52
53 static void initializeScriptWrappableForInterface(TestActiveDOMObject* object)
54 {
55 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
56 ScriptWrappable::setTypeInfoInObject(object, &V8TestActiveDOMObject::wra pperTypeInfo);
57 else
58 ASSERT_NOT_REACHED();
59 }
60
61 } // namespace WebCore
62
63 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows:
64 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
65 // in the global namespace.
66 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c)
67 void webCoreInitializeScriptWrappableForInterface(WebCore::TestActiveDOMObject* object)
68 {
69 WebCore::initializeScriptWrappableForInterface(object);
70 }
71
72 namespace WebCore {
73 const WrapperTypeInfo V8TestActiveDOMObject::wrapperTypeInfo = { V8TestActiveDOM Object::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0, 0, V8TestActiveDO MObject::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype };
74
75 namespace TestActiveDOMObjectV8Internal {
76
77 template <typename T> void V8_USE(T) { }
78
79 static void excitingAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value >& info)
80 {
81 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder());
82 v8SetReturnValueInt(info, imp->excitingAttr());
83 }
84
85 static void excitingAttrAttributeGetterCallback(v8::Local<v8::String>, const v8: :PropertyCallbackInfo<v8::Value>& info)
86 {
87 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
88 TestActiveDOMObjectV8Internal::excitingAttrAttributeGetter(info);
89 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
90 }
91
92 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>)
93 {
94 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(host);
95 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
96 }
97
98 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>)
99 {
100 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(host);
101 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
102 }
103
104 static void excitingFunctionMethod(const v8::FunctionCallbackInfo<v8::Value>& in fo)
105 {
106 if (UNLIKELY(info.Length() < 1)) {
107 throwTypeError(ExceptionMessages::failedToExecute("excitingFunction", "T estActiveDOMObject", ExceptionMessages::notEnoughArguments(1, info.Length())), i nfo.GetIsolate());
108 return;
109 }
110 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder());
111 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
112 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
113 exceptionState.throwIfNeeded();
114 return;
115 }
116 V8TRYCATCH_VOID(Node*, nextChild, V8Node::hasInstance(info[0], info.GetIsola te(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::C ast(info[0])) : 0);
117 imp->excitingFunction(nextChild);
118 }
119
120 static void excitingFunctionMethodCallback(const v8::FunctionCallbackInfo<v8::Va lue>& info)
121 {
122 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
123 TestActiveDOMObjectV8Internal::excitingFunctionMethod(info);
124 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
125 }
126
127 static void postMessageMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
128 {
129 if (UNLIKELY(info.Length() < 1)) {
130 throwTypeError(ExceptionMessages::failedToExecute("postMessage", "TestAc tiveDOMObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.G etIsolate());
131 return;
132 }
133 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder());
134 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, message, info[0]);
135 imp->postMessage(message);
136 }
137
138 static void postMessageMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
139 {
140 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
141 TestActiveDOMObjectV8Internal::postMessageMethod(info);
142 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
143 }
144
145 static void postMessageAttributeGetter(const v8::PropertyCallbackInfo<v8::Value> & info)
146 {
147 // This is only for getting a unique pointer which we can pass to privateTem plate.
148 static int privateTemplateUniqueKey;
149 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
150 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
151 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, TestActiveDOMObjectV8Internal::postMes sageMethodCallback, v8Undefined(), v8::Signature::New(V8PerIsolateData::from(inf o.GetIsolate())->rawTemplate(&V8TestActiveDOMObject::wrapperTypeInfo, currentWor ldType)), 1);
152
153 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestActiveDOMObject::GetTemplate(info.GetIsolate(), currentWorldType));
154 if (holder.IsEmpty()) {
155 // can only reach here by 'object.__proto__.func', and it should passed
156 // domain security check already
157 v8SetReturnValue(info, privateTemplate->GetFunction());
158 return;
159 }
160 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder);
161 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
162 static int sharedTemplateUniqueKey;
163 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, TestActiveDOMObjectV8Internal::postM essageMethodCallback, v8Undefined(), v8::Signature::New(V8PerIsolateData::from(i nfo.GetIsolate())->rawTemplate(&V8TestActiveDOMObject::wrapperTypeInfo, currentW orldType)), 1);
164 v8SetReturnValue(info, sharedTemplate->GetFunction());
165 return;
166 }
167
168 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewSymbol("postMessage"));
169 if (!hiddenValue.IsEmpty()) {
170 v8SetReturnValue(info, hiddenValue);
171 return;
172 }
173
174 v8SetReturnValue(info, privateTemplate->GetFunction());
175 }
176
177 static void postMessageAttributeGetterCallback(v8::Local<v8::String>, const v8:: PropertyCallbackInfo<v8::Value>& info)
178 {
179 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
180 TestActiveDOMObjectV8Internal::postMessageAttributeGetter(info);
181 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
182 }
183
184 static void perWorldBindingsMethodWithDoNotCheckSecurityMethod(const v8::Functio nCallbackInfo<v8::Value>& info)
185 {
186 if (UNLIKELY(info.Length() < 1)) {
187 throwTypeError(ExceptionMessages::failedToExecute("perWorldBindingsMetho dWithDoNotCheckSecurity", "TestActiveDOMObject", ExceptionMessages::notEnoughArg uments(1, info.Length())), info.GetIsolate());
188 return;
189 }
190 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder());
191 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, url, info[0]);
192 imp->perWorldBindingsMethodWithDoNotCheckSecurity(url);
193 }
194
195 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodCallback(const v8: :FunctionCallbackInfo<v8::Value>& info)
196 {
197 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
198 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge tCurrentContext());
199 if (contextData && contextData->activityLogger()) {
200 Vector<v8::Handle<v8::Value> > loggerArgs = toNativeArguments<v8::Handle <v8::Value> >(info, 0);
201 contextData->activityLogger()->log("TestActiveDOMObject.perWorldBindings MethodWithDoNotCheckSecurity", info.Length(), loggerArgs.data(), "Method");
202 }
203 TestActiveDOMObjectV8Internal::perWorldBindingsMethodWithDoNotCheckSecurityM ethod(info);
204 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
205 }
206
207 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetter(const v8 ::PropertyCallbackInfo<v8::Value>& info)
208 {
209 // This is only for getting a unique pointer which we can pass to privateTem plate.
210 static int privateTemplateUniqueKey;
211 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
212 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
213 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, TestActiveDOMObjectV8Internal::perWorl dBindingsMethodWithDoNotCheckSecurityMethodCallback, v8Undefined(), v8::Signatur e::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8TestActiveDOMOb ject::wrapperTypeInfo, currentWorldType)), 1);
214
215 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestActiveDOMObject::GetTemplate(info.GetIsolate(), currentWorldType));
216 if (holder.IsEmpty()) {
217 // can only reach here by 'object.__proto__.func', and it should passed
218 // domain security check already
219 v8SetReturnValue(info, privateTemplate->GetFunction());
220 return;
221 }
222 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder);
223 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
224 static int sharedTemplateUniqueKey;
225 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, TestActiveDOMObjectV8Internal::perWo rldBindingsMethodWithDoNotCheckSecurityMethodCallback, v8Undefined(), v8::Signat ure::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8TestActiveDOM Object::wrapperTypeInfo, currentWorldType)), 1);
226 v8SetReturnValue(info, sharedTemplate->GetFunction());
227 return;
228 }
229
230 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewSymbol("perWorldBindingsMethodWithDoNotCheckSecurity"));
231 if (!hiddenValue.IsEmpty()) {
232 v8SetReturnValue(info, hiddenValue);
233 return;
234 }
235
236 v8SetReturnValue(info, privateTemplate->GetFunction());
237 }
238
239 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterCallback( v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
240 {
241 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
242 TestActiveDOMObjectV8Internal::perWorldBindingsMethodWithDoNotCheckSecurityA ttributeGetter(info);
243 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
244 }
245
246 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
247 {
248 if (UNLIKELY(info.Length() < 1)) {
249 throwTypeError(ExceptionMessages::failedToExecute("perWorldBindingsMetho dWithDoNotCheckSecurity", "TestActiveDOMObject", ExceptionMessages::notEnoughArg uments(1, info.Length())), info.GetIsolate());
250 return;
251 }
252 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder());
253 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, url, info[0]);
254 imp->perWorldBindingsMethodWithDoNotCheckSecurity(url);
255 }
256
257 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWor ld(const v8::FunctionCallbackInfo<v8::Value>& info)
258 {
259 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
260 TestActiveDOMObjectV8Internal::perWorldBindingsMethodWithDoNotCheckSecurityM ethodForMainWorld(info);
261 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
262 }
263
264 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterForMainWo rld(const v8::PropertyCallbackInfo<v8::Value>& info)
265 {
266 // This is only for getting a unique pointer which we can pass to privateTem plate.
267 static int privateTemplateUniqueKey;
268 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
269 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
270 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, TestActiveDOMObjectV8Internal::perWorl dBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWorld, v8Undefined(), v8::Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8Tes tActiveDOMObject::wrapperTypeInfo, currentWorldType)), 1);
271
272 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestActiveDOMObject::GetTemplate(info.GetIsolate(), currentWorldType));
273 if (holder.IsEmpty()) {
274 // can only reach here by 'object.__proto__.func', and it should passed
275 // domain security check already
276 v8SetReturnValue(info, privateTemplate->GetFunction());
277 return;
278 }
279 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder);
280 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
281 static int sharedTemplateUniqueKey;
282 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, TestActiveDOMObjectV8Internal::perWo rldBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWorld, v8Undefined() , v8::Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8T estActiveDOMObject::wrapperTypeInfo, currentWorldType)), 1);
283 v8SetReturnValue(info, sharedTemplate->GetFunction());
284 return;
285 }
286
287 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewSymbol("perWorldBindingsMethodWithDoNotCheckSecurity"));
288 if (!hiddenValue.IsEmpty()) {
289 v8SetReturnValue(info, hiddenValue);
290 return;
291 }
292
293 v8SetReturnValue(info, privateTemplate->GetFunction());
294 }
295
296 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterCallbackF orMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& in fo)
297 {
298 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
299 TestActiveDOMObjectV8Internal::perWorldBindingsMethodWithDoNotCheckSecurityA ttributeGetterForMainWorld(info);
300 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
301 }
302
303 static void TestActiveDOMObjectDomainSafeFunctionSetter(v8::Local<v8::String> na me, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
304 {
305 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8 TestActiveDOMObject::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()) ));
306 if (holder.IsEmpty())
307 return;
308 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder);
309 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
310 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
311 exceptionState.throwIfNeeded();
312 return;
313 }
314
315 info.This()->SetHiddenValue(name, jsValue);
316 }
317
318 } // namespace TestActiveDOMObjectV8Internal
319
320 static const V8DOMConfiguration::AttributeConfiguration V8TestActiveDOMObjectAtt ributes[] = {
321 {"excitingAttr", TestActiveDOMObjectV8Internal::excitingAttrAttributeGetterC allback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8 ::PropertyAttribute>(v8::None), 0 /* on instance */},
322 };
323
324 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestActiveDOMObjectTemplate(v 8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperW orldType currentWorldType)
325 {
326 functionTemplate->ReadOnlyPrototype();
327
328 v8::Local<v8::Signature> defaultSignature;
329 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestActiveDOMObject", v8::Local<v8::FunctionTemplate>(), V8TestActiveDOMOb ject::internalFieldCount,
330 V8TestActiveDOMObjectAttributes, WTF_ARRAY_LENGTH(V8TestActiveDOMObjectA ttributes),
331 0, 0,
332 0, 0,
333 isolate, currentWorldType);
334 UNUSED_PARAM(defaultSignature);
335 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate();
336 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate();
337 UNUSED_PARAM(instanceTemplate);
338 UNUSED_PARAM(prototypeTemplate);
339 instanceTemplate->SetAccessCheckCallbacks(TestActiveDOMObjectV8Internal::nam edSecurityCheck, TestActiveDOMObjectV8Internal::indexedSecurityCheck, v8::Extern al::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestActiveDOMObject::wrapperTyp eInfo)));
340
341 // Custom Signature 'excitingFunction'
342 const int excitingFunctionArgc = 1;
343 v8::Handle<v8::FunctionTemplate> excitingFunctionArgv[excitingFunctionArgc] = { V8PerIsolateData::from(isolate)->rawTemplate(&V8Node::wrapperTypeInfo, curre ntWorldType) };
344 v8::Handle<v8::Signature> excitingFunctionSignature = v8::Signature::New(fun ctionTemplate, excitingFunctionArgc, excitingFunctionArgv);
345 prototypeTemplate->Set(v8::String::NewSymbol("excitingFunction"), v8::Functi onTemplate::New(TestActiveDOMObjectV8Internal::excitingFunctionMethodCallback, v 8Undefined(), excitingFunctionSignature, 1));
346
347 // Function 'postMessage' (Extended Attributes: 'DoNotCheckSecurity')
348 prototypeTemplate->SetAccessor(v8::String::NewSymbol("postMessage"), TestAct iveDOMObjectV8Internal::postMessageAttributeGetterCallback, TestActiveDOMObjectV 8Internal::TestActiveDOMObjectDomainSafeFunctionSetter, v8Undefined(), v8::ALL_C AN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
349
350 // Function 'perWorldBindingsMethodWithDoNotCheckSecurity' (Extended Attribu tes: 'DoNotCheckSecurity PerWorldBindings ActivityLogging')
351 if (currentWorldType == MainWorld) {
352 prototypeTemplate->SetAccessor(v8::String::NewSymbol("perWorldBindingsMe thodWithDoNotCheckSecurity"), TestActiveDOMObjectV8Internal::perWorldBindingsMet hodWithDoNotCheckSecurityAttributeGetterCallbackForMainWorld, TestActiveDOMObjec tV8Internal::TestActiveDOMObjectDomainSafeFunctionSetter, v8Undefined(), v8::ALL _CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
353 } else {
354 prototypeTemplate->SetAccessor(v8::String::NewSymbol("perWorldBindingsMe thodWithDoNotCheckSecurity"), TestActiveDOMObjectV8Internal::perWorldBindingsMet hodWithDoNotCheckSecurityAttributeGetterCallback, TestActiveDOMObjectV8Internal: :TestActiveDOMObjectDomainSafeFunctionSetter, v8Undefined(), v8::ALL_CAN_READ, s tatic_cast<v8::PropertyAttribute>(v8::DontDelete));
355 }
356
357 // Custom toString template
358 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c urrent()->toStringTemplate());
359 return functionTemplate;
360 }
361
362 v8::Handle<v8::FunctionTemplate> V8TestActiveDOMObject::GetTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
363 {
364 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
365 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
366 if (result != data->templateMap(currentWorldType).end())
367 return result->value.newLocal(isolate);
368
369 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
370 v8::EscapableHandleScope handleScope(isolate);
371 v8::Local<v8::FunctionTemplate> templ =
372 ConfigureV8TestActiveDOMObjectTemplate(data->rawTemplate(&wrapperTypeInf o, currentWorldType), isolate, currentWorldType);
373 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
374 return handleScope.Escape(templ);
375 }
376
377 bool V8TestActiveDOMObject::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isola te* isolate, WrapperWorldType currentWorldType)
378 {
379 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType);
380 }
381
382 bool V8TestActiveDOMObject::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate)
383 {
384 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
385 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld)
386 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld);
387 }
388
389 v8::Handle<v8::Object> V8TestActiveDOMObject::createWrapper(PassRefPtr<TestActiv eDOMObject> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
390 {
391 ASSERT(impl);
392 ASSERT(!DOMDataStore::containsWrapper<V8TestActiveDOMObject>(impl.get(), iso late));
393 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
394 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
395 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
396 // the same object de-ref functions, though, so use that as the basis of the check.
397 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
398 }
399
400 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
401 if (UNLIKELY(wrapper.IsEmpty()))
402 return wrapper;
403
404 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
405 V8DOMWrapper::associateObjectWithWrapper<V8TestActiveDOMObject>(impl, &wrapp erTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
406 return wrapper;
407 }
408
409 void V8TestActiveDOMObject::derefObject(void* object)
410 {
411 fromInternalPointer(object)->deref();
412 }
413
414 template<>
415 v8::Handle<v8::Value> toV8NoInline(TestActiveDOMObject* impl, v8::Handle<v8::Obj ect> creationContext, v8::Isolate* isolate)
416 {
417 return toV8(impl, creationContext, isolate);
418 }
419
420 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestActiveDOMObject.h ('k') | Source/bindings/tests/results/V8TestActiveDOMObjectInterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698