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 from the Jinja2 template
6 // third_party/blink/renderer/bindings/templates/interface.cc.tmpl
7 // by the script code_generator_v8.py.
8 // DO NOT MODIFY!
9
10 // clang-format off
11 #include "third_party/blink/renderer/bindings/tests/results/core/v8_test_interface_2.h"
12
13 #include <algorithm>
14
15 #include "base/memory/scoped_refptr.h"
16 #include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
17 #include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
18 #include "third_party/blink/renderer/bindings/core/v8/script_value.h"
19 #include "third_party/blink/renderer/bindings/core/v8/v8_dom_configuration.h"
20 #include "third_party/blink/renderer/bindings/core/v8/v8_for_each_iterator_callback.h"
21 #include "third_party/blink/renderer/bindings/core/v8/v8_iterator.h"
22 #include "third_party/blink/renderer/bindings/core/v8/v8_test_interface_empty.h"
23 #include "third_party/blink/renderer/core/execution_context/execution_context.h"
24 #include "third_party/blink/renderer/core/frame/local_dom_window.h"
25 #include "third_party/blink/renderer/platform/bindings/exception_messages.h"
26 #include "third_party/blink/renderer/platform/bindings/exception_state.h"
27 #include "third_party/blink/renderer/platform/bindings/runtime_call_stats.h"
28 #include "third_party/blink/renderer/platform/bindings/script_state.h"
29 #include "third_party/blink/renderer/platform/bindings/v8_object_constructor.h"
30 #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
31 #include "third_party/blink/renderer/platform/scheduler/public/cooperative_scheduling_manager.h"
32 #include "third_party/blink/renderer/platform/wtf/get_ptr.h"
33
34 namespace blink {
35
36 // Suppress warning: global constructors, because struct WrapperTypeInfo is trivial
37 // and does not depend on another global objects.
38 #if defined(COMPONENT_BUILD) && defined(WIN32) && defined(__clang__)
39 #pragma clang diagnostic push
40 #pragma clang diagnostic ignored "-Wglobal-constructors"
41 #endif
42 WrapperTypeInfo v8_test_interface_2_wrapper_type_info = {
43 gin::kEmbedderBlink,
44 V8TestInterface2::DomTemplate,
45 nullptr,
46 "TestInterface2",
47 nullptr,
48 WrapperTypeInfo::kWrapperTypeObjectPrototype,
49 WrapperTypeInfo::kObjectClassId,
50 WrapperTypeInfo::kInheritFromActiveScriptWrappable,
51 };
52 #if defined(COMPONENT_BUILD) && defined(WIN32) && defined(__clang__)
53 #pragma clang diagnostic pop
54 #endif
55
56 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterface2.h.
57 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
58 // platform/bindings/ScriptWrappable.h.
59 const WrapperTypeInfo& TestInterface2::wrapper_type_info_ = v8_test_interface_2_wrapper_type_info;
60
61 // [ActiveScriptWrappable]
62 static_assert(
63 std::is_base_of<ActiveScriptWrappableBase, TestInterface2>::value,
64 "TestInterface2 does not inherit from ActiveScriptWrappable<>, but specifying "
65 "[ActiveScriptWrappable] extended attribute in the IDL file. "
66 "Be consistent.");
67 static_assert(
68 !std::is_same<decltype(&TestInterface2::HasPendingActivity),
69 decltype(&ScriptWrappable::HasPendingActivity)>::value,
70 "TestInterface2 is not overriding hasPendingActivity(), but is specifying "
71 "[ActiveScriptWrappable] extended attribute in the IDL file. "
72 "Be consistent.");
73
74 namespace test_interface_2_v8_internal {
75
SizeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value> & info)76 static void SizeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
77 v8::Local<v8::Object> holder = info.Holder();
78
79 TestInterface2* impl = V8TestInterface2::ToImpl(holder);
80
81 V8SetReturnValueUnsigned(info, impl->size());
82 }
83
ItemMethod(const v8::FunctionCallbackInfo<v8::Value> & info)84 static void ItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
85 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "item");
86
87 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
88
89 if (UNLIKELY(info.Length() < 1)) {
90 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
91 return;
92 }
93
94 uint32_t index;
95 index = NativeValueTraits<IDLUnsignedLong>::NativeValue(info.GetIsolate(), info[0], exception_state);
96 if (exception_state.HadException())
97 return;
98
99 TestInterfaceEmpty* result = impl->item(index, exception_state);
100 if (exception_state.HadException()) {
101 return;
102 }
103 V8SetReturnValue(info, result);
104 }
105
SetItemMethod(const v8::FunctionCallbackInfo<v8::Value> & info)106 static void SetItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
107 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "setItem");
108
109 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
110
111 if (UNLIKELY(info.Length() < 2)) {
112 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(2, info.Length()));
113 return;
114 }
115
116 uint32_t index;
117 TestInterfaceEmpty* value;
118 index = NativeValueTraits<IDLUnsignedLong>::NativeValue(info.GetIsolate(), info[0], exception_state);
119 if (exception_state.HadException())
120 return;
121
122 value = V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), info[1]);
123 if (!value) {
124 exception_state.ThrowTypeError(ExceptionMessages::ArgumentNotOfType(1, "TestInterfaceEmpty"));
125 return;
126 }
127
128 TestInterfaceEmpty* result = impl->setItem(index, value, exception_state);
129 if (exception_state.HadException()) {
130 return;
131 }
132 V8SetReturnValue(info, result);
133 }
134
DeleteItemMethod(const v8::FunctionCallbackInfo<v8::Value> & info)135 static void DeleteItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
136 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "deleteItem");
137
138 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
139
140 if (UNLIKELY(info.Length() < 1)) {
141 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
142 return;
143 }
144
145 uint32_t index;
146 index = NativeValueTraits<IDLUnsignedLong>::NativeValue(info.GetIsolate(), info[0], exception_state);
147 if (exception_state.HadException())
148 return;
149
150 bool result = impl->deleteItem(index, exception_state);
151 if (exception_state.HadException()) {
152 return;
153 }
154 V8SetReturnValueBool(info, result);
155 }
156
NamedItemMethod(const v8::FunctionCallbackInfo<v8::Value> & info)157 static void NamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
158 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "namedItem");
159
160 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
161
162 if (UNLIKELY(info.Length() < 1)) {
163 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
164 return;
165 }
166
167 V8StringResource<> name;
168 name = info[0];
169 if (!name.Prepare())
170 return;
171
172 TestInterfaceEmpty* result = impl->namedItem(name, exception_state);
173 if (exception_state.HadException()) {
174 return;
175 }
176 V8SetReturnValue(info, result);
177 }
178
SetNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value> & info)179 static void SetNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
180 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "setNamedItem");
181
182 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
183
184 if (UNLIKELY(info.Length() < 2)) {
185 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(2, info.Length()));
186 return;
187 }
188
189 V8StringResource<> name;
190 TestInterfaceEmpty* value;
191 name = info[0];
192 if (!name.Prepare())
193 return;
194
195 value = V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), info[1]);
196 if (!value && !IsUndefinedOrNull(info[1])) {
197 exception_state.ThrowTypeError(ExceptionMessages::ArgumentNotOfType(1, "TestInterfaceEmpty"));
198 return;
199 }
200
201 TestInterfaceEmpty* result = impl->setNamedItem(name, value, exception_state);
202 if (exception_state.HadException()) {
203 return;
204 }
205 V8SetReturnValue(info, result);
206 }
207
DeleteNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value> & info)208 static void DeleteNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
209 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "deleteNamedItem");
210
211 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
212
213 if (UNLIKELY(info.Length() < 1)) {
214 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
215 return;
216 }
217
218 V8StringResource<> name;
219 name = info[0];
220 if (!name.Prepare())
221 return;
222
223 bool result = impl->deleteNamedItem(name, exception_state);
224 if (exception_state.HadException()) {
225 return;
226 }
227 V8SetReturnValueBool(info, result);
228 }
229
StringifierMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)230 static void StringifierMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
231 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
232
233 V8SetReturnValueString(info, impl->stringifierMethod(), info.GetIsolate());
234 }
235
KeysMethod(const v8::FunctionCallbackInfo<v8::Value> & info)236 static void KeysMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
237 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "keys");
238
239 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
240
241 ScriptState* script_state = ScriptState::ForRelevantRealm(info);
242
243 Iterator* result = impl->keysForBinding(script_state, exception_state);
244 if (exception_state.HadException()) {
245 return;
246 }
247 V8SetReturnValue(info, result);
248 }
249
EntriesMethod(const v8::FunctionCallbackInfo<v8::Value> & info)250 static void EntriesMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
251 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "entries");
252
253 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
254
255 ScriptState* script_state = ScriptState::ForRelevantRealm(info);
256
257 Iterator* result = impl->entriesForBinding(script_state, exception_state);
258 if (exception_state.HadException()) {
259 return;
260 }
261 V8SetReturnValue(info, result);
262 }
263
ForEachMethod(const v8::FunctionCallbackInfo<v8::Value> & info)264 static void ForEachMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
265 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "forEach");
266
267 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
268
269 ScriptState* script_state = ScriptState::ForRelevantRealm(info);
270
271 if (UNLIKELY(info.Length() < 1)) {
272 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
273 return;
274 }
275
276 V8ForEachIteratorCallback* callback;
277 ScriptValue this_arg;
278 if (info[0]->IsFunction()) {
279 callback = V8ForEachIteratorCallback::Create(info[0].As<v8::Function>());
280 } else {
281 exception_state.ThrowTypeError("The callback provided as parameter 1 is not a function.");
282 return;
283 }
284
285 this_arg = ScriptValue(info.GetIsolate(), info[1]);
286
287 impl->forEachForBinding(script_state, ScriptValue(info.GetIsolate(), info.Holder()), callback, this_arg, exception_state);
288 if (exception_state.HadException()) {
289 return;
290 }
291 }
292
HasMethod(const v8::FunctionCallbackInfo<v8::Value> & info)293 static void HasMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
294 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "has");
295
296 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
297
298 ScriptState* script_state = ScriptState::ForRelevantRealm(info);
299
300 if (UNLIKELY(info.Length() < 1)) {
301 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
302 return;
303 }
304
305 TestInterfaceEmpty* value;
306 value = V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), info[0]);
307 if (!value) {
308 exception_state.ThrowTypeError(ExceptionMessages::ArgumentNotOfType(0, "TestInterfaceEmpty"));
309 return;
310 }
311
312 bool result = impl->hasForBinding(script_state, value, exception_state);
313 if (exception_state.HadException()) {
314 return;
315 }
316 V8SetReturnValueBool(info, result);
317 }
318
ToStringMethod(const v8::FunctionCallbackInfo<v8::Value> & info)319 static void ToStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
320 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
321
322 V8SetReturnValueString(info, impl->stringifierMethod(), info.GetIsolate());
323 }
324
IteratorMethod(const v8::FunctionCallbackInfo<v8::Value> & info)325 static void IteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
326 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "iterator");
327
328 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
329
330 ScriptState* script_state = ScriptState::ForRelevantRealm(info);
331
332 Iterator* result = impl->GetIterator(script_state, exception_state);
333 if (exception_state.HadException()) {
334 return;
335 }
336 V8SetReturnValue(info, result);
337 }
338
Constructor(const v8::FunctionCallbackInfo<v8::Value> & info)339 static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
340 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_ConstructorCallback");
341
342 TestInterface2* impl = TestInterface2::Create();
343 v8::Local<v8::Object> wrapper = info.Holder();
344 wrapper = impl->AssociateWithWrapper(info.GetIsolate(), V8TestInterface2::GetWrapperTypeInfo(), wrapper);
345 V8SetReturnValue(info, wrapper);
346 }
347
ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value> & info)348 CORE_EXPORT void ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
349 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_Constructor");
350
351 if (!info.IsConstructCall()) {
352 V8ThrowException::ThrowTypeError(
353 info.GetIsolate(),
354 ExceptionMessages::ConstructorNotCallableAsFunction("TestInterface2"));
355 return;
356 }
357
358 if (ConstructorMode::Current(info.GetIsolate()) == ConstructorMode::kWrapExistingObject) {
359 V8SetReturnValue(info, info.Holder());
360 return;
361 }
362
363 test_interface_2_v8_internal::Constructor(info);
364 }
365
NamedPropertyGetter(const AtomicString & name,const v8::PropertyCallbackInfo<v8::Value> & info)366 static void NamedPropertyGetter(const AtomicString& name,
367 const v8::PropertyCallbackInfo<v8::Value>& info) {
368 const std::string& name_in_utf8 = name.Utf8();
369 ExceptionState exception_state(
370 info.GetIsolate(),
371 ExceptionState::kGetterContext,
372 "TestInterface2",
373 name_in_utf8.c_str());
374
375 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
376 TestInterfaceEmpty* result = impl->namedItem(name, exception_state);
377 if (!result)
378 return;
379 V8SetReturnValueFast(info, result, impl);
380 }
381
NamedPropertySetter(const AtomicString & name,v8::Local<v8::Value> v8_value,const v8::PropertyCallbackInfo<v8::Value> & info)382 static void NamedPropertySetter(
383 const AtomicString& name,
384 v8::Local<v8::Value> v8_value,
385 const v8::PropertyCallbackInfo<v8::Value>& info) {
386 const std::string& name_in_utf8 = name.Utf8();
387 ExceptionState exception_state(
388 info.GetIsolate(),
389 ExceptionState::kSetterContext,
390 "TestInterface2",
391 name_in_utf8.c_str());
392
393 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
394 TestInterfaceEmpty* property_value{ V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), v8_value) };
395 if (!property_value && !IsUndefinedOrNull(v8_value)) {
396 exception_state.ThrowTypeError("The provided value is not of type 'TestInterfaceEmpty'.");
397 return;
398 }
399
400 NamedPropertySetterResult result = impl->setNamedItem(name, property_value, exception_state);
401 if (exception_state.HadException())
402 return;
403 if (result == NamedPropertySetterResult::kDidNotIntercept)
404 return;
405 V8SetReturnValue(info, v8_value);
406 }
407
NamedPropertyDeleter(const AtomicString & name,const v8::PropertyCallbackInfo<v8::Boolean> & info)408 static void NamedPropertyDeleter(
409 const AtomicString& name, const v8::PropertyCallbackInfo<v8::Boolean>& info) {
410 const std::string& name_in_utf8 = name.Utf8();
411 ExceptionState exception_state(
412 info.GetIsolate(),
413 ExceptionState::kDeletionContext,
414 "TestInterface2",
415 name_in_utf8.c_str());
416
417 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
418
419 NamedPropertyDeleterResult result = impl->deleteNamedItem(name, exception_state);
420 if (exception_state.HadException())
421 return;
422 if (result == NamedPropertyDeleterResult::kDidNotIntercept)
423 return;
424 V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted);
425 }
426
NamedPropertyQuery(const AtomicString & name,const v8::PropertyCallbackInfo<v8::Integer> & info)427 static void NamedPropertyQuery(
428 const AtomicString& name, const v8::PropertyCallbackInfo<v8::Integer>& info) {
429 const std::string& name_in_utf8 = name.Utf8();
430 ExceptionState exception_state(
431 info.GetIsolate(),
432 ExceptionState::kGetterContext,
433 "TestInterface2",
434 name_in_utf8.c_str());
435
436 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
437
438 bool result = impl->NamedPropertyQuery(name, exception_state);
439 if (!result)
440 return;
441 // https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
442 // 2.7. If |O| implements an interface with a named property setter, then set
443 // desc.[[Writable]] to true, otherwise set it to false.
444 // 2.8. If |O| implements an interface with the
445 // [LegacyUnenumerableNamedProperties] extended attribute, then set
446 // desc.[[Enumerable]] to false, otherwise set it to true.
447 V8SetReturnValueInt(info, v8::None);
448 }
449
NamedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array> & info)450 static void NamedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
451 ExceptionState exception_state(
452 info.GetIsolate(),
453 ExceptionState::kEnumerationContext,
454 "TestInterface2");
455
456 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
457
458 Vector<String> names;
459 impl->NamedPropertyEnumerator(names, exception_state);
460 if (exception_state.HadException())
461 return;
462 V8SetReturnValue(info, ToV8(names, info.Holder(), info.GetIsolate()).As<v8::Array>());
463 }
464
IndexedPropertyGetter(uint32_t index,const v8::PropertyCallbackInfo<v8::Value> & info)465 static void IndexedPropertyGetter(
466 uint32_t index,
467 const v8::PropertyCallbackInfo<v8::Value>& info) {
468 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kIndexedGetterContext, "TestInterface2");
469
470 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
471
472 // We assume that all the implementations support length() method, although
473 // the spec doesn't require that length() must exist. It's okay that
474 // the interface does not have length attribute as long as the
475 // implementation supports length() member function.
476 if (index >= impl->length())
477 return; // Returns undefined due to out-of-range.
478
479 TestInterfaceEmpty* result = impl->item(index, exception_state);
480 V8SetReturnValueFast(info, result, impl);
481 }
482
IndexedPropertyDescriptor(uint32_t index,const v8::PropertyCallbackInfo<v8::Value> & info)483 static void IndexedPropertyDescriptor(
484 uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
485 // https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
486 // Steps 1.1 to 1.2.4 are covered here: we rely on indexedPropertyGetter() to
487 // call the getter function and check that |index| is a valid property index,
488 // in which case it will have set info.GetReturnValue() to something other
489 // than undefined.
490 V8TestInterface2::IndexedPropertyGetterCallback(index, info);
491 v8::Local<v8::Value> getter_value = info.GetReturnValue().Get();
492 if (!getter_value->IsUndefined()) {
493 // 1.2.5. Let |desc| be a newly created Property Descriptor with no fields.
494 // 1.2.6. Set desc.[[Value]] to the result of converting value to an
495 // ECMAScript value.
496 // 1.2.7. If O implements an interface with an indexed property setter,
497 // then set desc.[[Writable]] to true, otherwise set it to false.
498 v8::PropertyDescriptor desc(getter_value, true);
499 // 1.2.8. Set desc.[[Enumerable]] and desc.[[Configurable]] to true.
500 desc.set_enumerable(true);
501 desc.set_configurable(true);
502 // 1.2.9. Return |desc|.
503 V8SetReturnValue(info, desc);
504 }
505 }
506
IndexedPropertySetter(uint32_t index,v8::Local<v8::Value> v8_value,const v8::PropertyCallbackInfo<v8::Value> & info)507 static void IndexedPropertySetter(
508 uint32_t index,
509 v8::Local<v8::Value> v8_value,
510 const v8::PropertyCallbackInfo<v8::Value>& info) {
511 ExceptionState exception_state(
512 info.GetIsolate(),
513 ExceptionState::kIndexedSetterContext,
514 "TestInterface2");
515
516 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
517 TestInterfaceEmpty* property_value{ V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), v8_value) };
518 if (!property_value) {
519 exception_state.ThrowTypeError("The provided value is not of type 'TestInterfaceEmpty'.");
520 return;
521 }
522
523 IndexedPropertySetterResult result = impl->setItem(index, property_value, exception_state);
524 if (exception_state.HadException())
525 return;
526 if (result == IndexedPropertySetterResult::kDidNotIntercept)
527 return;
528 V8SetReturnValue(info, v8_value);
529 }
530
IndexedPropertyDeleter(uint32_t index,const v8::PropertyCallbackInfo<v8::Boolean> & info)531 static void IndexedPropertyDeleter(
532 uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) {
533 ExceptionState exception_state(
534 info.GetIsolate(),
535 ExceptionState::kIndexedDeletionContext,
536 "TestInterface2");
537
538 TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder());
539
540 NamedPropertyDeleterResult result = impl->deleteItem(index, exception_state);
541 if (exception_state.HadException())
542 return;
543 if (result == NamedPropertyDeleterResult::kDidNotIntercept)
544 return;
545 V8SetReturnValue(info, result == NamedPropertyDeleterResult::kDeleted);
546 }
547
548 } // namespace test_interface_2_v8_internal
549
SizeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value> & info)550 void V8TestInterface2::SizeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
551 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_size_Getter");
552
553 test_interface_2_v8_internal::SizeAttributeGetter(info);
554 }
555
ItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)556 void V8TestInterface2::ItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
557 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.item");
558 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_item");
559
560 test_interface_2_v8_internal::ItemMethod(info);
561 }
562
SetItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)563 void V8TestInterface2::SetItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
564 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.setItem");
565 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_setItem");
566
567 test_interface_2_v8_internal::SetItemMethod(info);
568 }
569
DeleteItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)570 void V8TestInterface2::DeleteItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
571 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.deleteItem");
572 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_deleteItem");
573
574 test_interface_2_v8_internal::DeleteItemMethod(info);
575 }
576
NamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)577 void V8TestInterface2::NamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
578 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.namedItem");
579 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_namedItem");
580
581 test_interface_2_v8_internal::NamedItemMethod(info);
582 }
583
SetNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)584 void V8TestInterface2::SetNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
585 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.setNamedItem");
586 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_setNamedItem");
587
588 test_interface_2_v8_internal::SetNamedItemMethod(info);
589 }
590
DeleteNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)591 void V8TestInterface2::DeleteNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
592 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.deleteNamedItem");
593 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_deleteNamedItem");
594
595 test_interface_2_v8_internal::DeleteNamedItemMethod(info);
596 }
597
StringifierMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)598 void V8TestInterface2::StringifierMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
599 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.stringifierMethod");
600 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_stringifierMethod");
601
602 test_interface_2_v8_internal::StringifierMethodMethod(info);
603 }
604
KeysMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)605 void V8TestInterface2::KeysMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
606 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.keys");
607 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_keys");
608
609 test_interface_2_v8_internal::KeysMethod(info);
610 }
611
EntriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)612 void V8TestInterface2::EntriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
613 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.entries");
614 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_entries");
615
616 test_interface_2_v8_internal::EntriesMethod(info);
617 }
618
ForEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)619 void V8TestInterface2::ForEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
620 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.forEach");
621 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_forEach");
622
623 test_interface_2_v8_internal::ForEachMethod(info);
624 }
625
HasMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)626 void V8TestInterface2::HasMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
627 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.has");
628 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_has");
629
630 test_interface_2_v8_internal::HasMethod(info);
631 }
632
ToStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)633 void V8TestInterface2::ToStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
634 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.toString");
635 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_toString");
636
637 test_interface_2_v8_internal::ToStringMethod(info);
638 }
639
IteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)640 void V8TestInterface2::IteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
641 BLINK_BINDINGS_TRACE_EVENT("TestInterface2.iterator");
642 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_iterator");
643
644 test_interface_2_v8_internal::IteratorMethod(info);
645 }
646
NamedPropertyGetterCallback(v8::Local<v8::Name> name,const v8::PropertyCallbackInfo<v8::Value> & info)647 void V8TestInterface2::NamedPropertyGetterCallback(
648 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
649 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_NamedPropertyGetter");
650
651 if (!name->IsString())
652 return;
653 const AtomicString& property_name = ToCoreAtomicString(name.As<v8::String>());
654
655 test_interface_2_v8_internal::NamedPropertyGetter(property_name, info);
656 }
657
NamedPropertySetterCallback(v8::Local<v8::Name> name,v8::Local<v8::Value> v8_value,const v8::PropertyCallbackInfo<v8::Value> & info)658 void V8TestInterface2::NamedPropertySetterCallback(
659 v8::Local<v8::Name> name,
660 v8::Local<v8::Value> v8_value,
661 const v8::PropertyCallbackInfo<v8::Value>& info) {
662 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_NamedPropertySetter");
663
664 if (!name->IsString())
665 return;
666 const AtomicString& property_name = ToCoreAtomicString(name.As<v8::String>());
667
668 test_interface_2_v8_internal::NamedPropertySetter(property_name, v8_value, info);
669 }
670
NamedPropertyDeleterCallback(v8::Local<v8::Name> name,const v8::PropertyCallbackInfo<v8::Boolean> & info)671 void V8TestInterface2::NamedPropertyDeleterCallback(
672 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) {
673 if (!name->IsString())
674 return;
675 const AtomicString& property_name = ToCoreAtomicString(name.As<v8::String>());
676
677 test_interface_2_v8_internal::NamedPropertyDeleter(property_name, info);
678 }
679
NamedPropertyQueryCallback(v8::Local<v8::Name> name,const v8::PropertyCallbackInfo<v8::Integer> & info)680 void V8TestInterface2::NamedPropertyQueryCallback(
681 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) {
682 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_NamedPropertyQuery");
683
684 if (!name->IsString())
685 return;
686 const AtomicString& property_name = ToCoreAtomicString(name.As<v8::String>());
687
688 test_interface_2_v8_internal::NamedPropertyQuery(property_name, info);
689 }
690
NamedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array> & info)691 void V8TestInterface2::NamedPropertyEnumeratorCallback(
692 const v8::PropertyCallbackInfo<v8::Array>& info) {
693 test_interface_2_v8_internal::NamedPropertyEnumerator(info);
694 }
695
IndexedPropertyGetterCallback(uint32_t index,const v8::PropertyCallbackInfo<v8::Value> & info)696 void V8TestInterface2::IndexedPropertyGetterCallback(
697 uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
698 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_IndexedPropertyGetter");
699
700 test_interface_2_v8_internal::IndexedPropertyGetter(index, info);
701 }
702
IndexedPropertyDescriptorCallback(uint32_t index,const v8::PropertyCallbackInfo<v8::Value> & info)703 void V8TestInterface2::IndexedPropertyDescriptorCallback(
704 uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) {
705 test_interface_2_v8_internal::IndexedPropertyDescriptor(index, info);
706 }
707
IndexedPropertySetterCallback(uint32_t index,v8::Local<v8::Value> v8_value,const v8::PropertyCallbackInfo<v8::Value> & info)708 void V8TestInterface2::IndexedPropertySetterCallback(
709 uint32_t index,
710 v8::Local<v8::Value> v8_value,
711 const v8::PropertyCallbackInfo<v8::Value>& info) {
712 test_interface_2_v8_internal::IndexedPropertySetter(index, v8_value, info);
713 }
714
IndexedPropertyDeleterCallback(uint32_t index,const v8::PropertyCallbackInfo<v8::Boolean> & info)715 void V8TestInterface2::IndexedPropertyDeleterCallback(
716 uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) {
717 test_interface_2_v8_internal::IndexedPropertyDeleter(index, info);
718 }
719
IndexedPropertyDefinerCallback(uint32_t index,const v8::PropertyDescriptor & desc,const v8::PropertyCallbackInfo<v8::Value> & info)720 void V8TestInterface2::IndexedPropertyDefinerCallback(
721 uint32_t index,
722 const v8::PropertyDescriptor& desc,
723 const v8::PropertyCallbackInfo<v8::Value>& info) {
724 // https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty
725 // 3.9.3. [[DefineOwnProperty]]
726 // step 1.1. If the result of calling IsDataDescriptor(Desc) is false, then
727 // return false.
728 if (desc.has_get() || desc.has_set()) {
729 V8SetReturnValue(info, v8::Null(info.GetIsolate()));
730 if (info.ShouldThrowOnError()) {
731 ExceptionState exception_state(info.GetIsolate(),
732 ExceptionState::kIndexedSetterContext,
733 "TestInterface2");
734 exception_state.ThrowTypeError("Accessor properties are not allowed.");
735 }
736 return;
737 }
738
739 // Return nothing and fall back to indexedPropertySetterCallback.
740 }
741
742 static constexpr V8DOMConfiguration::MethodConfiguration kV8TestInterface2Methods[] = {
743 {"item", V8TestInterface2::ItemMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
744 {"setItem", V8TestInterface2::SetItemMethodCallback, 2, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
745 {"deleteItem", V8TestInterface2::DeleteItemMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
746 {"namedItem", V8TestInterface2::NamedItemMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
747 {"setNamedItem", V8TestInterface2::SetNamedItemMethodCallback, 2, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
748 {"deleteNamedItem", V8TestInterface2::DeleteNamedItemMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
749 {"stringifierMethod", V8TestInterface2::StringifierMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
750 {"keys", V8TestInterface2::KeysMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
751 {"entries", V8TestInterface2::EntriesMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
752 {"forEach", V8TestInterface2::ForEachMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
753 {"has", V8TestInterface2::HasMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
754 {"toString", V8TestInterface2::ToStringMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
755 };
756
InstallV8TestInterface2Template(v8::Isolate * isolate,const DOMWrapperWorld & world,v8::Local<v8::FunctionTemplate> interface_template)757 void V8TestInterface2::InstallV8TestInterface2Template(
758 v8::Isolate* isolate,
759 const DOMWrapperWorld& world,
760 v8::Local<v8::FunctionTemplate> interface_template) {
761 // Initialize the interface object's template.
762 V8DOMConfiguration::InitializeDOMInterfaceTemplate(isolate, interface_template, V8TestInterface2::GetWrapperTypeInfo()->interface_name, v8::Local<v8::FunctionTemplate>(), V8TestInterface2::kInternalFieldCount);
763 interface_template->SetCallHandler(test_interface_2_v8_internal::ConstructorCallback);
764 interface_template->SetLength(0);
765
766 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
767 ALLOW_UNUSED_LOCAL(signature);
768 v8::Local<v8::ObjectTemplate> instance_template = interface_template->InstanceTemplate();
769 ALLOW_UNUSED_LOCAL(instance_template);
770 v8::Local<v8::ObjectTemplate> prototype_template = interface_template->PrototypeTemplate();
771 ALLOW_UNUSED_LOCAL(prototype_template);
772
773 // Register IDL constants, attributes and operations.
774 static_assert(1 == TestInterface2::kConstValue1, "the value of TestInterface2_kConstValue1 does not match with implementation");
775 static constexpr V8DOMConfiguration::AccessorConfiguration
776 kAccessorConfigurations[] = {
777 { "size", V8TestInterface2::SizeAttributeGetterCallback, nullptr, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::DontEnum | v8::ReadOnly), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
778 };
779 V8DOMConfiguration::InstallAccessors(
780 isolate, world, instance_template, prototype_template, interface_template,
781 signature, kAccessorConfigurations,
782 base::size(kAccessorConfigurations));
783 V8DOMConfiguration::InstallMethods(
784 isolate, world, instance_template, prototype_template, interface_template,
785 signature, kV8TestInterface2Methods, base::size(kV8TestInterface2Methods));
786
787 // Indexed properties
788 v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig(
789 V8TestInterface2::IndexedPropertyGetterCallback,
790 V8TestInterface2::IndexedPropertySetterCallback,
791 V8TestInterface2::IndexedPropertyDescriptorCallback,
792 V8TestInterface2::IndexedPropertyDeleterCallback,
793 IndexedPropertyEnumerator<TestInterface2>,
794 V8TestInterface2::IndexedPropertyDefinerCallback,
795 v8::Local<v8::Value>(),
796 v8::PropertyHandlerFlags::kNone);
797 instance_template->SetHandler(indexedPropertyHandlerConfig);
798 // Named properties
799 v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig(V8TestInterface2::NamedPropertyGetterCallback, V8TestInterface2::NamedPropertySetterCallback, V8TestInterface2::NamedPropertyQueryCallback, V8TestInterface2::NamedPropertyDeleterCallback, V8TestInterface2::NamedPropertyEnumeratorCallback, v8::Local<v8::Value>(), static_cast<v8::PropertyHandlerFlags>(int(v8::PropertyHandlerFlags::kOnlyInterceptStrings) | int(v8::PropertyHandlerFlags::kNonMasking)));
800 instance_template->SetHandler(namedPropertyHandlerConfig);
801
802 // Iterator (@@iterator)
803 static const V8DOMConfiguration::SymbolKeyedMethodConfiguration
804 kSymbolKeyedIteratorConfiguration = {
805 v8::Symbol::GetIterator,
806 "values",
807 V8TestInterface2::IteratorMethodCallback,
808 0,
809 v8::DontEnum,
810 V8DOMConfiguration::kOnPrototype,
811 V8DOMConfiguration::kCheckHolder,
812 V8DOMConfiguration::kDoNotCheckAccess,
813 V8DOMConfiguration::kHasSideEffect
814 };
815 V8DOMConfiguration::InstallMethod(
816 isolate, world, prototype_template, signature,
817 kSymbolKeyedIteratorConfiguration);
818
819 // Custom signature
820 }
821
InstallRuntimeEnabledFeaturesOnTemplate(v8::Isolate * isolate,const DOMWrapperWorld & world,v8::Local<v8::FunctionTemplate> interface_template)822 void V8TestInterface2::InstallRuntimeEnabledFeaturesOnTemplate(
823 v8::Isolate* isolate,
824 const DOMWrapperWorld& world,
825 v8::Local<v8::FunctionTemplate> interface_template) {
826 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
827 ALLOW_UNUSED_LOCAL(signature);
828 v8::Local<v8::ObjectTemplate> instance_template = interface_template->InstanceTemplate();
829 ALLOW_UNUSED_LOCAL(instance_template);
830 v8::Local<v8::ObjectTemplate> prototype_template = interface_template->PrototypeTemplate();
831 ALLOW_UNUSED_LOCAL(prototype_template);
832
833 // Register IDL constants, attributes and operations.
834 if (RuntimeEnabledFeatures::RuntimeFeatureEnabled()) {
835 static constexpr V8DOMConfiguration::ConstantConfiguration kConfigurations[] = {
836 {"CONST_VALUE_1", V8DOMConfiguration::kConstantTypeUnsignedShort, static_cast<int>(1)},
837 };
838 V8DOMConfiguration::InstallConstants(
839 isolate, interface_template, prototype_template,
840 kConfigurations, base::size(kConfigurations));
841 }
842
843 // Custom signature
844 }
845
DomTemplate(v8::Isolate * isolate,const DOMWrapperWorld & world)846 v8::Local<v8::FunctionTemplate> V8TestInterface2::DomTemplate(
847 v8::Isolate* isolate, const DOMWrapperWorld& world) {
848 return V8DOMConfiguration::DomClassTemplate(
849 isolate, world, const_cast<WrapperTypeInfo*>(V8TestInterface2::GetWrapperTypeInfo()),
850 V8TestInterface2::install_v8_test_interface_2_template_function_);
851 }
852
HasInstance(v8::Local<v8::Value> v8_value,v8::Isolate * isolate)853 bool V8TestInterface2::HasInstance(v8::Local<v8::Value> v8_value, v8::Isolate* isolate) {
854 return V8PerIsolateData::From(isolate)->HasInstance(V8TestInterface2::GetWrapperTypeInfo(), v8_value);
855 }
856
FindInstanceInPrototypeChain(v8::Local<v8::Value> v8_value,v8::Isolate * isolate)857 v8::Local<v8::Object> V8TestInterface2::FindInstanceInPrototypeChain(
858 v8::Local<v8::Value> v8_value, v8::Isolate* isolate) {
859 return V8PerIsolateData::From(isolate)->FindInstanceInPrototypeChain(
860 V8TestInterface2::GetWrapperTypeInfo(), v8_value);
861 }
862
ToImplWithTypeCheck(v8::Isolate * isolate,v8::Local<v8::Value> value)863 TestInterface2* V8TestInterface2::ToImplWithTypeCheck(
864 v8::Isolate* isolate, v8::Local<v8::Value> value) {
865 return HasInstance(value, isolate) ? ToImpl(v8::Local<v8::Object>::Cast(value)) : nullptr;
866 }
867
868 InstallRuntimeEnabledFeaturesOnTemplateFunction
869 V8TestInterface2::install_runtime_enabled_features_on_template_function_ =
870 &V8TestInterface2::InstallRuntimeEnabledFeaturesOnTemplate;
871
872 InstallTemplateFunction
873 V8TestInterface2::install_v8_test_interface_2_template_function_ =
874 &V8TestInterface2::InstallV8TestInterface2Template;
875
UpdateWrapperTypeInfo(InstallTemplateFunction install_template_function,InstallRuntimeEnabledFeaturesFunction install_runtime_enabled_features_function,InstallRuntimeEnabledFeaturesOnTemplateFunction install_runtime_enabled_features_on_template_function,InstallConditionalFeaturesFunction install_conditional_features_function)876 void V8TestInterface2::UpdateWrapperTypeInfo(
877 InstallTemplateFunction install_template_function,
878 InstallRuntimeEnabledFeaturesFunction install_runtime_enabled_features_function,
879 InstallRuntimeEnabledFeaturesOnTemplateFunction install_runtime_enabled_features_on_template_function,
880 InstallConditionalFeaturesFunction install_conditional_features_function) {
881 V8TestInterface2::install_v8_test_interface_2_template_function_ =
882 install_template_function;
883
884 CHECK(install_runtime_enabled_features_on_template_function);
885 V8TestInterface2::install_runtime_enabled_features_on_template_function_ =
886 install_runtime_enabled_features_on_template_function;
887
888 if (install_conditional_features_function) {
889 V8TestInterface2::GetWrapperTypeInfo()->install_conditional_features_function =
890 install_conditional_features_function;
891 }
892 }
893
894 } // namespace blink
895