diff --git a/ecmascript/builtins/builtins.cpp b/ecmascript/builtins/builtins.cpp index 52520c026818bd567c567ea1d64937e96ff0440f..805ab89077add34123d1054f4978d3ba5b483d9f 100644 --- a/ecmascript/builtins/builtins.cpp +++ b/ecmascript/builtins/builtins.cpp @@ -395,7 +395,7 @@ void Builtins::Initialize(const JSHandle &env, JSThread *thread, bool thread_->ResetGuardians(); thread->CheckSafepointIfSuspended(); - if (vm_->GetJSOptions().IsEnableLoweringBuiltin()) { + if (vm_->GetJSOptions().IsEnableLoweringBuiltin() && !isRealm) { if (!lazyInit) { thread_->InitializeBuiltinObject(); } diff --git a/test/aottest/BUILD.gn b/test/aottest/BUILD.gn index b1e5bd23690157c28c4d001ae18907e0fbd2bc90..8f5cf095776db42d1fc7520d1c56d012c01888be 100644 --- a/test/aottest/BUILD.gn +++ b/test/aottest/BUILD.gn @@ -261,6 +261,7 @@ group("ark_aot_ts_test") { "privateproperty", "privateproperty_js", "resumegenerator", + "realm", "rodata", "setobjectwithproto", "set", diff --git a/test/aottest/realm/BUILD.gn b/test/aottest/realm/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..54072ac4534e8a59af39e4e3b38d555cbea52a79 --- /dev/null +++ b/test/aottest/realm/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2024 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_aot_test_action("realm") { + deps = [] +} diff --git a/test/aottest/realm/expect_output.txt b/test/aottest/realm/expect_output.txt new file mode 100644 index 0000000000000000000000000000000000000000..e2726c6e1d4c4b6864404a21e5ff29fcccaa04d5 --- /dev/null +++ b/test/aottest/realm/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2024 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. + +---------------test createRealm suc!---------------- \ No newline at end of file diff --git a/test/aottest/realm/realm.ts b/test/aottest/realm/realm.ts new file mode 100644 index 0000000000000000000000000000000000000000..2583ba12258b1b42212c50c4e8ae630e9942b69b --- /dev/null +++ b/test/aottest/realm/realm.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021 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:realm + * @tc.desc:test realm + * @tc.type: FUNC + * @tc.require: issueIBAJYP + */ +declare function print(arg:any):void; + +{ + let obj = globalThis["Object"]; + globalThis["Object"] = undefined; + createRealm(); + globalThis["Object"] = obj; + print("---------------test createRealm suc!----------------") +} \ No newline at end of file diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index 76a8f9e27752ec482ceff94fa0f0ef90a19a48b0..7ba306a7122fd0867ab754c405d3dab39dba6ab1 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -125,6 +125,7 @@ group("ark_js_moduletest") { "propertydetector", "protobuf", "proxy", + "realm", "regressproxy", "rangeerror", "regexpcallthrow", @@ -344,6 +345,7 @@ group("ark_asm_test") { "promise", "propertydetector", "proxy", + "realm", "rangeerror", "regexpcallthrow", "regexpflagd", @@ -527,6 +529,7 @@ group("ark_asm_single_step_test") { "promise", "propertydetector", "proxy", + "realm", "rangeerror", "regexpcallthrow", "regexpflagd", diff --git a/test/moduletest/realm/BUILD.gn b/test/moduletest/realm/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..538cadfaf89340a64b9c4b208ba5fddfaab766a2 --- /dev/null +++ b/test/moduletest/realm/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2024 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("realm") { + deps = [] +} diff --git a/test/moduletest/realm/expect_output.txt b/test/moduletest/realm/expect_output.txt new file mode 100644 index 0000000000000000000000000000000000000000..e2726c6e1d4c4b6864404a21e5ff29fcccaa04d5 --- /dev/null +++ b/test/moduletest/realm/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2024 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. + +---------------test createRealm suc!---------------- \ No newline at end of file diff --git a/test/moduletest/realm/realm.js b/test/moduletest/realm/realm.js new file mode 100644 index 0000000000000000000000000000000000000000..57aff432f1e499f5a5ae952fb0ccdc5b79cc6853 --- /dev/null +++ b/test/moduletest/realm/realm.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021 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:realm + * @tc.desc:test realm + * @tc.type: FUNC + * @tc.require: issueIBAJYP + */ + +{ + let obj = globalThis["Object"]; + globalThis["Object"] = undefined; + createRealm(); + globalThis["Object"] = obj; + print("---------------test createRealm suc!----------------") +} \ No newline at end of file