| Index: test/mjsunit/strong/object-freeze-property.js
|
| diff --git a/test/mjsunit/strong/object-freeze-property.js b/test/mjsunit/strong/object-freeze-property.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..12a0170e6b19e2907e51ab5bb131750e2c0257cc
|
| --- /dev/null
|
| +++ b/test/mjsunit/strong/object-freeze-property.js
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2015 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: --strong-mode --allow-natives-syntax
|
| +
|
| +// TODO(conradw): Track implementation of strong bit for other objects, add
|
| +// tests.
|
| +
|
| +function getSloppyObjects() {
|
| + return [(function(){}), ({})];
|
| +}
|
| +
|
| +function getStrictObjects() {
|
| + "use strict";
|
| + return [(function(){}), ({})];
|
| +}
|
| +
|
| +function getStrongObjects() {
|
| + "use strong";
|
| + // Strong functions can't have properties added to them.
|
| + return [({})];
|
| +}
|
| +
|
| +function testStrongObjectFreezeProp() {
|
| + "use strict";
|
| + let sloppyObjects = getSloppyObjects();
|
| + let strictObjects = getStrictObjects();
|
| + let strongObjects = getStrongObjects();
|
| + let weakObjects = sloppyObjects.concat(strictObjects);
|
| +
|
| + for (let o of nonStrongObjects) {
|
| + Object.defineProperty(o, "foo", { enumerable:true, writable:true });
|
| + assertDoesNotThrow(
|
| + function() {
|
| + "use strong";
|
| + Object.defineProperty(o, "foo", { enumerable:true, writable:false });
|
| + });
|
| + }
|
| + for (let o of strongObjects) {
|
| + function defProp(o) {
|
| + Object.defineProperty(o, "foo", { enumerable:true, writable:false });
|
| + }
|
| + function defProps(o) {
|
| + let props = {};
|
| + Object.defineProperty(props, "foo", { enumerable:true, writable:false });
|
| + Object.defineProperties(o, props);
|
| + }
|
| + function freezeProp(o) {
|
| + Object.freeze(o);
|
| + }
|
| + Object.defineProperty(o, "foo", { enumerable:true, writable:true });
|
| + for (let func of [defProp, defProps, freezeProp]) {
|
| + assertThrows(function(){func(o)}, TypeError);
|
| + assertThrows(function(){func(o)}, TypeError);
|
| + assertThrows(function(){func(o)}, TypeError);
|
| + %OptimizeFunctionOnNextCall(func);
|
| + assertThrows(function(){func(o)}, TypeError);
|
| + %DeoptimizeFunction(func);
|
| + assertThrows(function(){func(o)}, TypeError);
|
| + }
|
| + }
|
| +}
|
| +testStrongObjectFreezeProp();
|
|
|