array.map没有爬取原型链上的数据

Signed-off-by: hwx1163501 <hanjing35@huawei.com>
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8I5ZZ
This commit is contained in:
hwx1163501 2023-11-21 12:38:41 +08:00
parent 90f8fd42e4
commit e85ea344a5
5 changed files with 71 additions and 1 deletions

View File

@ -761,7 +761,12 @@ JSTaggedValue JSStableArray::Map(JSHandle<JSObject> newArrayHandle, JSHandle<JSO
while (k < len) {
// Elements of thisObjHandle may change.
array.Update(thisObjHandle->GetElements());
kValue.Update(array->Get(k));
JSTaggedValue value = array->Get(k);
if (value.IsHole() && JSTaggedValue::HasProperty(thread, thisObjVal, k)) {
value = JSArray::FastGetPropertyByValue(thread, thisObjVal, k).GetTaggedValue();
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
}
kValue.Update(value);
if (!kValue.GetTaggedValue().IsHole()) {
key.Update(JSTaggedValue(k));
EcmaRuntimeCallInfo *info =

View File

@ -25,6 +25,7 @@ group("ark_js_moduletest") {
"arrayfindlastindex",
"arrayforeach",
"arrayjoin",
"arraymap",
"arraypop",
"arraytoreversed",
"arraytospliced",
@ -179,6 +180,7 @@ group("ark_asm_test") {
"arrayfindindex",
"arrayforeach",
"arrayjoin",
"arraymap",
"arraypop",
"arraysort",
"arrayprotochange",
@ -309,6 +311,7 @@ group("ark_asm_single_step_test") {
"arrayfindlastindex",
"arrayforeach",
"arrayjoin",
"arraymap",
"arraypop",
"arrayprotochange",
"arrayshift",

View 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("arraymap") {
deps = []
}

View File

@ -0,0 +1,29 @@
/*
* 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:async
* @tc.desc:test async function
* @tc.type: FUNC
* @tc.require: issueI5NO8G issueI8FBM3
*/
var array = [,];
function map() {
return array.map(x => x + 1);
}
array.__proto__.push(5);
var narr = map();
print(JSON.stringify(Object.getOwnPropertyDescriptor(narr, 0)));
print(narr[0], 6);

View File

@ -0,0 +1,15 @@
# 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.
{"value":6,"writable":true,"enumerable":true,"configurable":true}
6 6