summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/regress/regress-crbug-1055138-2.js
blob: 33dbcf85205a6eb798ede98db166e42dcfd0187b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Object.prototype[1] = 153;

(function TestSloppyStoreToReadOnlyProperty() {
  function foo(prototype_frozen) {
    let ar = [];
    for (let i = 0; i < 3; i++) {
      ar[i] = 42;

      if (prototype_frozen) {
        if (i == 1) {
          // Attempt to overwrite read-only element should not change
          // array length.
          assertEquals(1, ar.length);
        } else {
          assertEquals(i + 1, ar.length);
        }
      }
    }
    return ar;
  }

  // Warm-up store IC.
  assertEquals([42,42,42], foo(false));
  assertEquals([42,42,42], foo(false));
  assertEquals([42,42,42], foo(false));
  assertEquals([42,42,42], foo(false));
  Object.freeze(Object.prototype);
  // Ensure IC was properly invalidated.
  assertEquals([42,153,42], foo(true));
})();