mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
Fix GetOwnPropertyKeys Bug
Fix the case when obj is not JSObject in GetOwnPropertyKeys. Issue: #I6EX3R Signed-off-by: lichenshuai <lichenshuai@huawei.com> Change-Id: I2ba0ece77280ece2e7c773c10f30c4dc3a42f8c9
This commit is contained in:
parent
5b8a9821e2
commit
4eae26af2b
@ -375,7 +375,9 @@ JSTaggedValue RuntimeStubs::RuntimeCopyDataProperties(JSThread *thread, const JS
|
||||
const JSHandle<JSTaggedValue> &src)
|
||||
{
|
||||
if (!src->IsNull() && !src->IsUndefined()) {
|
||||
JSHandle<TaggedArray> keys = JSTaggedValue::GetOwnPropertyKeys(thread, src);
|
||||
// 2. Let from be ! ToObject(source).
|
||||
JSHandle<JSTaggedValue> from(JSTaggedValue::ToObject(thread, src));
|
||||
JSHandle<TaggedArray> keys = JSTaggedValue::GetOwnPropertyKeys(thread, from);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
|
||||
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
|
||||
@ -383,7 +385,7 @@ JSTaggedValue RuntimeStubs::RuntimeCopyDataProperties(JSThread *thread, const JS
|
||||
for (uint32_t i = 0; i < keysLen; i++) {
|
||||
PropertyDescriptor desc(thread);
|
||||
key.Update(keys->Get(i));
|
||||
bool success = JSTaggedValue::GetOwnProperty(thread, src, key, desc);
|
||||
bool success = JSTaggedValue::GetOwnProperty(thread, from, key, desc);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
|
||||
if (success && desc.IsEnumerable()) {
|
||||
|
@ -29,6 +29,7 @@ group("ark_js_moduletest") {
|
||||
"compareobjecthclass:compareobjecthclassAction",
|
||||
"concurrent:concurrentAction",
|
||||
"container:containerAction",
|
||||
"dataproperty:datapropertyAction",
|
||||
"datecase:datecaseAction",
|
||||
"dateparse:dateparseAction",
|
||||
"dynamicimport:dynamicimportAction",
|
||||
@ -104,6 +105,7 @@ group("ark_asm_test") {
|
||||
"compareobjecthclass:compareobjecthclassAsmAction",
|
||||
"concurrent:concurrentAsmAction",
|
||||
"container:containerAsmAction",
|
||||
"dataproperty:datapropertyAsmAction",
|
||||
"dateparse:dateparseAsmAction",
|
||||
"dynamicimport:dynamicimportAction",
|
||||
"dyninstruction:dyninstructionAsmAction",
|
||||
@ -169,6 +171,7 @@ group("ark_asm_single_step_test") {
|
||||
"compareobjecthclass:compareobjecthclassAsmSingleStepAction",
|
||||
"concurrent:concurrentAsmSingleStepAction",
|
||||
"container:containerAsmSingleStepAction",
|
||||
"dataproperty:datapropertyAsmSingleStepAction",
|
||||
"dynamicimport:dynamicimportAction",
|
||||
"dyninstruction:dyninstructionAsmSingleStepAction",
|
||||
"ecmastringtable:ecmastringtableAsmSingleStepAction",
|
||||
|
18
test/moduletest/dataproperty/BUILD.gn
Normal file
18
test/moduletest/dataproperty/BUILD.gn
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_moduletest_action("dataproperty") {
|
||||
deps = []
|
||||
}
|
26
test/moduletest/dataproperty/dataproperty.js
Normal file
26
test/moduletest/dataproperty/dataproperty.js
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @tc.name:dataproperty
|
||||
* @tc.desc:test dataproperty
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5NO8G
|
||||
*/
|
||||
|
||||
// CopyDataProperties
|
||||
var s = "abc";
|
||||
var t = {...s};
|
||||
print(t[1]);
|
14
test/moduletest/dataproperty/expect_output.txt
Normal file
14
test/moduletest/dataproperty/expect_output.txt
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
b
|
Loading…
Reference in New Issue
Block a user