|
1 | 1 | /* |
2 | | - * Copyright (c) 2018, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * The Universal Permissive License (UPL), Version 1.0 |
|
45 | 45 |
|
46 | 46 | void SimpleAccessorGetter(Local<Name> property, const PropertyCallbackInfo<Value>& info); |
47 | 47 | void SimpleAccessorSetter(Local<Name> property, Local<Value> value, const PropertyCallbackInfo<void>& info); |
| 48 | +void EmptyPropertyEnumeratorCallback(const PropertyCallbackInfo<Array>& info) {}; |
48 | 49 |
|
49 | 50 | #endif |
50 | 51 |
|
@@ -128,4 +129,38 @@ EXPORT_TO_JS(CheckNamedHandlerWithInternalFields) { |
128 | 129 | args.GetReturnValue().Set(expectedCount == actualCount); |
129 | 130 | } |
130 | 131 |
|
| 132 | +EXPORT_TO_JS(CreateWithEmptyIndexedEnumerator) { |
| 133 | + Isolate* isolate = args.GetIsolate(); |
| 134 | + Local<ObjectTemplate> objectTemplate = ObjectTemplate::New(isolate); |
| 135 | + IndexedPropertyHandlerConfiguration handler( |
| 136 | + nullptr, // getter |
| 137 | + nullptr, // setter |
| 138 | + nullptr, // query |
| 139 | + nullptr, // deleter |
| 140 | + EmptyPropertyEnumeratorCallback // enumerator |
| 141 | + ); |
| 142 | + objectTemplate->SetHandler(handler); |
| 143 | + |
| 144 | + Local<Context> context = isolate->GetCurrentContext(); |
| 145 | + Local<Object> instance = objectTemplate->NewInstance(context).ToLocalChecked(); |
| 146 | + args.GetReturnValue().Set(instance); |
| 147 | +} |
| 148 | + |
| 149 | +EXPORT_TO_JS(CreateWithEmptyNamedEnumerator) { |
| 150 | + Isolate* isolate = args.GetIsolate(); |
| 151 | + Local<ObjectTemplate> objectTemplate = ObjectTemplate::New(isolate); |
| 152 | + NamedPropertyHandlerConfiguration handler( |
| 153 | + nullptr, // getter |
| 154 | + nullptr, // setter |
| 155 | + nullptr, // query |
| 156 | + nullptr, // deleter |
| 157 | + EmptyPropertyEnumeratorCallback // enumerator |
| 158 | + ); |
| 159 | + objectTemplate->SetHandler(handler); |
| 160 | + |
| 161 | + Local<Context> context = isolate->GetCurrentContext(); |
| 162 | + Local<Object> instance = objectTemplate->NewInstance(context).ToLocalChecked(); |
| 163 | + args.GetReturnValue().Set(instance); |
| 164 | +} |
| 165 | + |
131 | 166 | #undef SUITE |
0 commit comments