• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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// test Change Object.prototype
17function test7() {
18    let obj = ArkTools.createNapiObject();
19    let obj2 = {};
20    Object.prototype.x = 1;
21    print(obj.x);
22    obj2.__proto__.y = 2;
23    print(obj.y);
24}
25test7();
26print(ArkTools.isAOTCompiled(test7))
27print(ArkTools.isAOTDeoptimized(test7))
28
29function test8() {
30    var Class = {};
31    Class = function () {
32        this.listeners = {};
33    };
34    Class.prototype = {
35        add: function () {
36        },
37    };
38    var EventBus = new Class();
39}
40test8();
41
42// test change __proto__ after transition
43function test9() {
44    let obj = ArkTools.createNapiObject();
45    obj.x = 1;
46    obj.__proto__ = {};
47    print(obj.x);
48}
49test9();
50print(ArkTools.isAOTCompiled(test9))
51print(ArkTools.isAOTDeoptimized(test9))
52
53// test transition's __proto__
54function test10() {
55    let obj = ArkTools.createNapiObject();
56    obj.x = 1;
57    print(obj.__proto__.toString());
58}
59test10();
60print(ArkTools.isAOTCompiled(test10))
61print(ArkTools.isAOTDeoptimized(test10))
62