| Index: test/mjsunit/strict-mode.js
|
| diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js
|
| index ab3e535ec33055a8245ff5280c8b196a74170d3c..60f31f844afcdcbd41ee7d6310910a9e6221ab64 100644
|
| --- a/test/mjsunit/strict-mode.js
|
| +++ b/test/mjsunit/strict-mode.js
|
| @@ -700,3 +700,91 @@ repeat(10, function() { testAssignToUndefined(false); });
|
| cleanup(Boolean);
|
| }
|
| })();
|
| +
|
| +
|
| +(function ObjectEnvironment() {
|
| + var o = {};
|
| + Object.defineProperty(o, "foo", { value: "FOO", writable: false });
|
| + assertThrows(
|
| + function () {
|
| + with (o) {
|
| + (function() {
|
| + "use strict";
|
| + foo = "Hello";
|
| + })();
|
| + }
|
| + },
|
| + TypeError);
|
| +})();
|
| +
|
| +
|
| +(function TestSetPropertyWithoutSetter() {
|
| + var o = { get foo() { return "Yey"; } };
|
| + assertThrows(
|
| + function broken() {
|
| + "use strict";
|
| + o.foo = (0xBADBAD00 >> 1);
|
| + },
|
| + TypeError);
|
| +})();
|
| +
|
| +(function TestSetPropertyNonConfigurable() {
|
| + var frozen = Object.freeze({});
|
| + var sealed = Object.seal({});
|
| +
|
| + function strict(o) {
|
| + "use strict";
|
| + o.property = "value";
|
| + }
|
| +
|
| + assertThrows(function() { strict(frozen); }, TypeError);
|
| + assertThrows(function() { strict(sealed); }, TypeError);
|
| +})();
|
| +
|
| +(function TestAssignmentToReadOnlyPropert() {
|
| + "use strict";
|
| +
|
| + var o = {};
|
| + Object.defineProperty(o, "property", { value: 7 });
|
| +
|
| + assertThrows(function() { o.property = "new value"; }, TypeError);
|
| + assertThrows(function() { o.property += 10; }, TypeError);
|
| + assertThrows(function() { o.property -= 10; }, TypeError);
|
| + assertThrows(function() { o.property *= 10; }, TypeError);
|
| + assertThrows(function() { o.property /= 10; }, TypeError);
|
| + assertThrows(function() { o.property++; }, TypeError);
|
| + assertThrows(function() { o.property--; }, TypeError);
|
| + assertThrows(function() { ++o.property; }, TypeError);
|
| + assertThrows(function() { --o.property; }, TypeError);
|
| +
|
| + var name = "prop" + "erty"; // to avoid symbol path.
|
| + assertThrows(function() { o[name] = "new value"; }, TypeError);
|
| + assertThrows(function() { o[name] += 10; }, TypeError);
|
| + assertThrows(function() { o[name] -= 10; }, TypeError);
|
| + assertThrows(function() { o[name] *= 10; }, TypeError);
|
| + assertThrows(function() { o[name] /= 10; }, TypeError);
|
| + assertThrows(function() { o[name]++; }, TypeError);
|
| + assertThrows(function() { o[name]--; }, TypeError);
|
| + assertThrows(function() { ++o[name]; }, TypeError);
|
| + assertThrows(function() { --o[name]; }, TypeError);
|
| +
|
| + assertEquals(o.property, 7);
|
| +})();
|
| +
|
| +// TODO(mmaly): Add loop test, something like:
|
| +/*
|
| +(function outer() {
|
| + "use strict";
|
| + var name = "prop" + "erty"; // to avoid symbol path.
|
| + var o = {};
|
| + Object.defineProperty(o, "property", { value: 7 });
|
| +
|
| + function broken(o, name) {
|
| + o[name] = "new value";
|
| + }
|
| + try { broken(o, name); } catch(e) { print(e); }
|
| + try { broken(o, name); } catch(e) { print(e); }
|
| + try { broken(o, name); } catch(e) { print(e); }
|
| + try { broken(o, name); } catch(e) { print(e); }
|
| +})();
|
| +*/
|
|
|