mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
修改JSTypedArray::FastGetPropertyByIndex当IsDetachedBuffer时不抛出异常
Change-Id: I9df9ed0b847903087114af574f9f91c242fa0980 Signed-off-by: yanpeng <yanpeng51@huawei.com>
This commit is contained in:
parent
dc116a611d
commit
254e8e87e3
@ -650,9 +650,8 @@ JSTaggedValue JSTypedArray::FastGetPropertyByIndex(JSThread *thread, const JSTag
|
||||
// Let buffer be the value of O’s [[ViewedArrayBuffer]] internal slot.
|
||||
JSTypedArray *typedarrayObj = JSTypedArray::Cast(typedarray.GetTaggedObject());
|
||||
JSTaggedValue buffer = typedarrayObj->GetViewedArrayBufferOrByteArray();
|
||||
// If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
if (BuiltinsArrayBuffer::IsDetachedBuffer(buffer)) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Is Detached Buffer", JSTaggedValue::Exception());
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
|
@ -149,6 +149,7 @@ group("ark_js_moduletest") {
|
||||
"regexp",
|
||||
"deregistermodule",
|
||||
"getpropertybyic",
|
||||
"regressbufferdetach",
|
||||
"regressdate",
|
||||
"objectfreeze",
|
||||
]
|
||||
|
18
test/moduletest/regressbufferdetach/BUILD.gn
Executable file
18
test/moduletest/regressbufferdetach/BUILD.gn
Executable 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("regressbufferdetach") {
|
||||
deps = []
|
||||
}
|
14
test/moduletest/regressbufferdetach/expect_output.txt
Executable file
14
test/moduletest/regressbufferdetach/expect_output.txt
Executable 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.
|
||||
|
||||
6
|
24
test/moduletest/regressbufferdetach/regressbufferdetach.js
Executable file
24
test/moduletest/regressbufferdetach/regressbufferdetach.js
Executable file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
delete Float64Array.prototype.__proto__[Symbol.iterator];
|
||||
let a = new Float64Array(9);
|
||||
Object.defineProperty(a, "length", {
|
||||
get: function () {
|
||||
ArkTools.arrayBufferDetach(a.buffer);
|
||||
return 6;
|
||||
}
|
||||
});
|
||||
|
||||
print(Float64Array.from(a).length);
|
Loading…
Reference in New Issue
Block a user