已合并
reflectOwnkeys异常未按照期望抛出 #13522
yang-yunfei32创建于 2025年11月6日
reflectOwnkeys异常未按照期望抛出 #13522
已合并
共 5 个文件变更+64-4
| @@ -821,7 +821,7 @@ JSHandle<TaggedArray> JSProxy::OwnPropertyKeys(JSThread *thread, const JSHandle< | |||
| 821 | 821 | ||
| 822 | // 19.If extensibleTarget is true and targetNonconfigurableKeys is empty, then | 822 | // 19.If extensibleTarget is true and targetNonconfigurableKeys is empty, then |
| 823 | // a.Return trapResult. | 823 | // a.Return trapResult. |
| 824 | - if (extensibleTarget && (cfigLength == 0)) { | 824 | + if (extensibleTarget && (noCfigLength == 0)) { |
| 825 | return trapRes; | 825 | return trapRes; |
| 826 | } | 826 | } |
| 827 | 827 | ||
| @@ -487,9 +487,8 @@ HWTEST_F_L0(JSProxyTest, OwnPropertyKeys) | |||
| 487 | 487 | ||
| 488 | JSHandle<JSProxy> proxyHandle2 = JSProxy::ProxyCreate(thread, targetHandle, handlerHandle); | 488 | JSHandle<JSProxy> proxyHandle2 = JSProxy::ProxyCreate(thread, targetHandle, handlerHandle); |
| 489 | EXPECT_TRUE(*proxyHandle2 != nullptr); | 489 | EXPECT_TRUE(*proxyHandle2 != nullptr); |
| 490 | - JSHandle<TaggedArray> res2 = JSProxy::OwnPropertyKeys(thread, proxyHandle2); | 490 | + JSProxy::OwnPropertyKeys(thread, proxyHandle2); |
| 491 | - EXPECT_TRUE(res2->GetLength() == 0U || | 491 | + EXPECT_TRUE(thread->HasPendingException()); |
| 492 | - !JSTaggedValue::SameValue(thread, res2->Get(thread, 0), key.GetTaggedValue())); | ||
| 493 | } | 492 | } |
| 494 | 493 | ||
| 495 | JSTaggedValue HandlerCall([[maybe_unused]] EcmaRuntimeCallInfo *argv) | 494 | JSTaggedValue HandlerCall([[maybe_unused]] EcmaRuntimeCallInfo *argv) |
| @@ -272,6 +272,7 @@ group("ark_js_assert_moduletest") { | |||
| 272 | "typedarraywith", | 272 | "typedarraywith", |
| 273 | "typedarrayjoin", | 273 | "typedarrayjoin", |
| 274 | "watch", | 274 | "watch", |
| 275 | + "reflectownkeys", | ||
| 275 | "weakcollectionswithsymbol", | 276 | "weakcollectionswithsymbol", |
| 276 | "wrapperclassfunc", | 277 | "wrapperclassfunc", |
| 277 | "yieldstar", | 278 | "yieldstar", |
| @@ -402,6 +403,7 @@ group("ark_asm_assert_test") { | |||
| 402 | "typedarraytosorted", | 403 | "typedarraytosorted", |
| 403 | "typedarraywith", | 404 | "typedarraywith", |
| 404 | "watch", | 405 | "watch", |
| 406 | + "reflectownkeys", | ||
| 405 | "weakcollectionswithsymbol", | 407 | "weakcollectionswithsymbol", |
| 406 | "wrapperclassfunc", | 408 | "wrapperclassfunc", |
| 407 | "yieldstar", | 409 | "yieldstar", |
| @@ -0,0 +1,18 @@ | |||
| 1 | +# Copyright (c) 2021 Huawei Device Co., Ltd. | ||
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 3 | +# you may not use this file except in compliance with the License. | ||
| 4 | +# You may obtain a copy of the License at | ||
| 5 | +# | ||
| 6 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 7 | +# | ||
| 8 | +# Unless required by applicable law or agreed to in writing, software | ||
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 11 | +# See the License for the specific language governing permissions and | ||
| 12 | +# limitations under the License. | ||
| 13 | + | ||
| 14 | +import("//arkcompiler/ets_runtime/test/test_helper.gni") | ||
| 15 | + | ||
| 16 | +host_moduletest_assert_action("reflectownkeys") { | ||
| 17 | + deps = [] | ||
| 18 | +} | ||
| @@ -0,0 +1,41 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +/* | ||
| 17 | + * @tc.name:reflect | ||
| 18 | + * @tc.desc:test ownkeys | ||
| 19 | + * @tc.type: FUNC | ||
| 20 | + * @tc.require: issue11859 | ||
| 21 | + */ | ||
| 22 | +{ | ||
| 23 | + const target = {}; | ||
| 24 | + Object.defineProperty(target, 'fixed', { | ||
| 25 | + value: 1, | ||
| 26 | + configurable: false | ||
| 27 | + }); | ||
| 28 | + const handler = { | ||
| 29 | + ownKeys() { | ||
| 30 | + return []; | ||
| 31 | + } | ||
| 32 | + }; | ||
| 33 | + const proxy = new Proxy(target, handler); | ||
| 34 | + try { | ||
| 35 | + Reflect.ownKeys(proxy); | ||
| 36 | + } catch (e) { | ||
| 37 | + assert_equal(e.name, "TypeError"); | ||
| 38 | + } | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +test_end(); | ||
已检视无问题