| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c598877 commit 29ba98a
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,6 +97,7 @@ Darshan Sen <raisinten@gmail.com> | |||
| 97 | 97 | David Carlier <devnexen@gmail.com> | |
| 98 | 98 | David Manouchehri <david@davidmanouchehri.com> | |
| 99 | 99 | David Sanders <dsanders11@ucsbalum.com> | |
| 100 | + Debadree Chatterjee <debadree333@gmail.com> | ||
| 100 | 101 | Deepak Mohan <hop2deep@gmail.com> | |
| 101 | 102 | Deon Dior <diaoyuanjie@gmail.com> | |
| 102 | 103 | Derek Tu <derek.t@rioslab.org> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,7 +182,8 @@ ExceptionStatus KeyAccumulator::AddKeys(Handle<JSObject> array_like, | |||
| 182 | 182 | MaybeHandle<FixedArray> FilterProxyKeys(KeyAccumulator* accumulator, | |
| 183 | 183 | Handle<JSProxy> owner, | |
| 184 | 184 | Handle<FixedArray> keys, | |
| 185 | - PropertyFilter filter) { | ||
| 185 | + PropertyFilter filter, | ||
| 186 | + bool skip_indices) { | ||
| 186 | 187 | if (filter == ALL_PROPERTIES) { | |
| 187 | 188 | // Nothing to do. | |
| 188 | 189 | return keys; | |
@@ -192,6 +193,10 @@ MaybeHandle<FixedArray> FilterProxyKeys(KeyAccumulator* accumulator, | |||
| 192 | 193 | for (int i = 0; i < keys->length(); ++i) { | |
| 193 | 194 | Handle<Name> key(Name::cast(keys->get(i)), isolate); | |
| 194 | 195 | if (key->FilterKey(filter)) continue; // Skip this key. | |
| 196 | + if (skip_indices) { | ||
| 197 | + uint32_t index; | ||
| 198 | + if (key->AsArrayIndex(&index)) continue; // Skip this key. | ||
| 199 | + } | ||
| 195 | 200 | if (filter & ONLY_ENUMERABLE) { | |
| 196 | 201 | PropertyDescriptor desc; | |
| 197 | 202 | Maybe<bool> found = | |
@@ -218,7 +223,8 @@ Maybe<bool> KeyAccumulator::AddKeysFromJSProxy(Handle<JSProxy> proxy, | |||
| 218 | 223 | // Postpone the enumerable check for for-in to the ForInFilter step. | |
| 219 | 224 | if (!is_for_in_) { | |
| 220 | 225 | ASSIGN_RETURN_ON_EXCEPTION_VALUE( | |
| 221 | - isolate_, keys, FilterProxyKeys(this, proxy, keys, filter_), | ||
| 226 | + isolate_, keys, | ||
| 227 | + FilterProxyKeys(this, proxy, keys, filter_, skip_indices_), | ||
| 222 | 228 | Nothing<bool>()); | |
| 223 | 229 | } | |
| 224 | 230 | // https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14636,6 +14636,110 @@ THREADED_TEST(ProxyGetPropertyNames) { | |||
| 14636 | 14636 | CheckIsSymbolAt(isolate, properties, 4, "symbol"); | |
| 14637 | 14637 | } | |
| 14638 | 14638 | ||
| 14639 | + THREADED_TEST(ProxyGetPropertyNamesWithOwnKeysTrap) { | ||
| 14640 | + LocalContext context; | ||
| 14641 | + v8::Isolate* isolate = context->GetIsolate(); | ||
| 14642 | + v8::HandleScope scope(isolate); | ||
| 14643 | + v8::Local<v8::Value> result = CompileRun( | ||
| 14644 | + "var target = {0: 0, 1: 1, a: 2, b: 3};" | ||
| 14645 | + "target[2**32] = '4294967296';" | ||
| 14646 | + "target[2**32-1] = '4294967295';" | ||
| 14647 | + "target[2**32-2] = '4294967294';" | ||
| 14648 | + "target[Symbol('symbol')] = true;" | ||
| 14649 | + "target.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};" | ||
| 14650 | + "var result = new Proxy(target, { ownKeys: (t) => Reflect.ownKeys(t) });" | ||
| 14651 | + "result;"); | ||
| 14652 | + v8::Local<v8::Object> object = result.As<v8::Object>(); | ||
| 14653 | + v8::PropertyFilter default_filter = | ||
| 14654 | + static_cast<v8::PropertyFilter>(v8::ONLY_ENUMERABLE | v8::SKIP_SYMBOLS); | ||
| 14655 | + v8::PropertyFilter include_symbols_filter = v8::ONLY_ENUMERABLE; | ||
| 14656 | + | ||
| 14657 | + v8::Local<v8::Array> properties = | ||
| 14658 | + object->GetPropertyNames(context.local()).ToLocalChecked(); | ||
| 14659 | + const char* expected_properties1[] = {"0", "1", "4294967294", "a", | ||
| 14660 | + "b", "4294967296", "4294967295", "2", | ||
| 14661 | + "3", "c", "d"}; | ||
| 14662 | + CheckStringArray(isolate, properties, 11, expected_properties1); | ||
| 14663 | + | ||
| 14664 | + properties = | ||
| 14665 | + object | ||
| 14666 | + ->GetPropertyNames(context.local(), | ||
| 14667 | + v8::KeyCollectionMode::kIncludePrototypes, | ||
| 14668 | + default_filter, v8::IndexFilter::kIncludeIndices) | ||
| 14669 | + .ToLocalChecked(); | ||
| 14670 | + CheckStringArray(isolate, properties, 11, expected_properties1); | ||
| 14671 | + | ||
| 14672 | + properties = object | ||
| 14673 | + ->GetPropertyNames(context.local(), | ||
| 14674 | + v8::KeyCollectionMode::kIncludePrototypes, | ||
| 14675 | + include_symbols_filter, | ||
| 14676 | + v8::IndexFilter::kIncludeIndices) | ||
| 14677 | + .ToLocalChecked(); | ||
| 14678 | + const char* expected_properties1_1[] = { | ||
| 14679 | + "0", "1", "4294967294", "a", "b", "4294967296", | ||
| 14680 | + "4294967295", nullptr, "2", "3", "c", "d"}; | ||
| 14681 | + CheckStringArray(isolate, properties, 12, expected_properties1_1); | ||
| 14682 | + CheckIsSymbolAt(isolate, properties, 7, "symbol"); | ||
| 14683 | + | ||
| 14684 | + properties = | ||
| 14685 | + object | ||
| 14686 | + ->GetPropertyNames(context.local(), | ||
| 14687 | + v8::KeyCollectionMode::kIncludePrototypes, | ||
| 14688 | + default_filter, v8::IndexFilter::kSkipIndices) | ||
| 14689 | + .ToLocalChecked(); | ||
| 14690 | + const char* expected_properties2[] = {"a", "b", "4294967296", | ||
| 14691 | + "4294967295", "c", "d"}; | ||
| 14692 | + CheckStringArray(isolate, properties, 6, expected_properties2); | ||
| 14693 | + | ||
| 14694 | + properties = object | ||
| 14695 | + ->GetPropertyNames(context.local(), | ||
| 14696 | + v8::KeyCollectionMode::kIncludePrototypes, | ||
| 14697 | + include_symbols_filter, | ||
| 14698 | + v8::IndexFilter::kSkipIndices) | ||
| 14699 | + .ToLocalChecked(); | ||
| 14700 | + const char* expected_properties2_1[] = { | ||
| 14701 | + "a", "b", "4294967296", "4294967295", nullptr, "c", "d"}; | ||
| 14702 | + CheckStringArray(isolate, properties, 7, expected_properties2_1); | ||
| 14703 | + CheckIsSymbolAt(isolate, properties, 4, "symbol"); | ||
| 14704 | + | ||
| 14705 | + properties = | ||
| 14706 | + object | ||
| 14707 | + ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, | ||
| 14708 | + default_filter, v8::IndexFilter::kIncludeIndices) | ||
| 14709 | + .ToLocalChecked(); | ||
| 14710 | + const char* expected_properties3[] = {"0", "1", "4294967294", "a", | ||
| 14711 | + "b", "4294967296", "4294967295"}; | ||
| 14712 | + CheckStringArray(isolate, properties, 7, expected_properties3); | ||
| 14713 | + | ||
| 14714 | + properties = object | ||
| 14715 | + ->GetPropertyNames( | ||
| 14716 | + context.local(), v8::KeyCollectionMode::kOwnOnly, | ||
| 14717 | + include_symbols_filter, v8::IndexFilter::kIncludeIndices) | ||
| 14718 | + .ToLocalChecked(); | ||
| 14719 | + const char* expected_properties3_1[] = { | ||
| 14720 | + "0", "1", "4294967294", "a", "b", "4294967296", "4294967295", nullptr}; | ||
| 14721 | + CheckStringArray(isolate, properties, 8, expected_properties3_1); | ||
| 14722 | + CheckIsSymbolAt(isolate, properties, 7, "symbol"); | ||
| 14723 | + | ||
| 14724 | + properties = | ||
| 14725 | + object | ||
| 14726 | + ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, | ||
| 14727 | + default_filter, v8::IndexFilter::kSkipIndices) | ||
| 14728 | + .ToLocalChecked(); | ||
| 14729 | + const char* expected_properties4[] = {"a", "b", "4294967296", "4294967295"}; | ||
| 14730 | + CheckStringArray(isolate, properties, 4, expected_properties4); | ||
| 14731 | + | ||
| 14732 | + properties = object | ||
| 14733 | + ->GetPropertyNames( | ||
| 14734 | + context.local(), v8::KeyCollectionMode::kOwnOnly, | ||
| 14735 | + include_symbols_filter, v8::IndexFilter::kSkipIndices) | ||
| 14736 | + .ToLocalChecked(); | ||
| 14737 | + const char* expected_properties4_1[] = {"a", "b", "4294967296", "4294967295", | ||
| 14738 | + nullptr}; | ||
| 14739 | + CheckStringArray(isolate, properties, 5, expected_properties4_1); | ||
| 14740 | + CheckIsSymbolAt(isolate, properties, 4, "symbol"); | ||
| 14741 | + } | ||
| 14742 | + | ||
| 14639 | 14743 | THREADED_TEST(AccessChecksReenabledCorrectly) { | |
| 14640 | 14744 | LocalContext context; | |
| 14641 | 14745 | v8::Isolate* isolate = context->GetIsolate(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments