v8/test/mjsunit/regress/regress-refreeze-same-map.js
kris.selden 6681949808 [runtime] PreventExtensionsWithTransition: before adding the new
transition, check to see if we have already done this transition.

BUG=v8:6450

Review-Url: https://codereview.chromium.org/2915863004
Cr-Commit-Position: refs/heads/master@{#46129}
2017-06-22 12:19:26 +00:00

41 lines
2.1 KiB
JavaScript

// Copyright 2017 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.
// Flags: --allow-natives-syntax
// precondition
assertTrue(%HaveSameMap(Object.freeze({}), Object.freeze({})));
assertTrue(%HaveSameMap(Object.freeze({a: 1}), Object.freeze({a: 1})));
assertTrue(%HaveSameMap(Object.freeze([]), Object.freeze([])));
assertTrue(%HaveSameMap(Object.freeze([1,2]), Object.freeze([1,2])));
assertTrue(%HaveSameMap(Object.seal({}), Object.seal({})));
assertTrue(%HaveSameMap(Object.seal({a: 1}), Object.seal({a: 1})));
assertTrue(%HaveSameMap(Object.seal([]), Object.seal([])));
assertTrue(%HaveSameMap(Object.seal([1,2]), Object.seal([1,2])));
// refreezing an already frozen obj does not keep adding transitions
assertTrue(%HaveSameMap(Object.freeze({}), Object.freeze( Object.freeze({}) )));
assertTrue(%HaveSameMap(Object.freeze({a: 1}), Object.freeze( Object.freeze({a: 1}) )));
assertTrue(%HaveSameMap(Object.freeze([]), Object.freeze( Object.freeze([]) )));
assertTrue(%HaveSameMap(Object.freeze([1,2]), Object.freeze( Object.freeze([1,2]) )));
// resealing a sealed object is idempotent
assertTrue(%HaveSameMap(Object.seal({}), Object.seal( Object.seal({}) )));
assertTrue(%HaveSameMap(Object.seal({a: 1}), Object.seal( Object.seal({a: 1}) )));
assertTrue(%HaveSameMap(Object.seal([]), Object.seal( Object.seal([]) )));
assertTrue(%HaveSameMap(Object.seal([1,2]), Object.seal( Object.seal([1,2]) )));
// sealing a frozen object is idempotent
assertTrue(%HaveSameMap(Object.freeze({}), Object.seal( Object.freeze({}) )));
assertTrue(%HaveSameMap(Object.freeze({a: 1}), Object.seal( Object.freeze({a: 1}) )));
assertTrue(%HaveSameMap(Object.freeze([]), Object.seal( Object.freeze([]) )));
assertTrue(%HaveSameMap(Object.freeze([1,2]), Object.seal( Object.freeze([1,2]) )));
// freezing a sealed empty is idempotent
assertTrue(%HaveSameMap(Object.freeze(Object.seal({})), Object.seal({})));
// sealing a unextensible empty object is idempotent
assertTrue(%HaveSameMap(Object.seal(Object.preventExtensions({})), Object.preventExtensions({})));