• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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/*
17 * @tc.name:storeicbyname
18 * @tc.desc:test storeicbyname
19 * @tc.type: FUNC
20 * @tc.require: issueI7UTOA
21 */
22
23const arr = [];
24for (let i = 0; i < 200; i++) {
25
26}
27for (let i = 0; i < 100; i++) {
28    arr.length = 1025;
29}
30
31for (let i = 0; i < 100; i++) {
32    const v77 = {};
33    v77.__proto__ = null;
34}
35
36let bad_proto = {
37    get __proto__(){
38
39    }
40}
41let obj = {};
42obj.__proto__ = bad_proto;
43
44let obj1 = {};
45Object.defineProperty(obj1, 'foo', {
46    set: function(value) {
47        Object.defineProperty(this, 'bar', {
48            get: function() {
49                return this._bar;
50            },
51            set: function(value) {
52                this._bar = value;
53            },
54        });
55    }
56});
57
58obj.foo = 'some value';
59for (let i = 0; i < 20; i++) {
60    obj.bar = 'new value';
61}
62
63{
64    let o = {};
65    o["a"] = String.prototype;
66    for (let i = 0; i < 2; i++) {
67        let o1;
68        if (o1) {
69            o["a"]= o1;
70        } else {
71            o1 = o["a"];
72        }
73        for (let j = 0; j < 50; j++) {
74            let o2 = new Object(-63);
75            if (o2) {
76                o["a"] = o2;
77            } else {
78                o2 = o["a"];
79            }
80            let o3 = o1.valueOf();
81            if (o3) {
82                o["a"] = o3;
83            } else {
84                o3 = o["a"];
85            }
86            // o3 is Number when i = 0 and o3 is Int when i = 1
87            try {
88                o3.x = "telu";
89            } catch(e) {}
90        }
91    }
92}
93
94(function test1() {
95    let warmUpObj, testObj, Foo;
96    function SetUp() {
97        Foo = function () {}
98        Foo.prototype.a = 0;
99        warmUpObj = new Foo();
100        testObj = new Foo();
101    }
102    SetUp();
103
104    function test(o) {
105        for (let i  = 0;i < 1000; i++){}
106        o.a = 10;
107    }
108    test(warmUpObj);
109    Object.defineProperty(Foo.prototype, "a", {writable: false});
110    try {
111        test(testObj);
112        assert_unreachable();
113    } catch(e) {
114        print("cannot adjust");
115    }
116    let passed = testObj.a == Foo.prototype.a;
117    assert_equal(passed, true);
118})();
119
120test_end();