Index: test/mjsunit/strict-mode.js |
diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js |
index ab3e535ec33055a8245ff5280c8b196a74170d3c..0bc117e14771471cfa0441dbe1bfd2e805e84975 100644 |
--- a/test/mjsunit/strict-mode.js |
+++ b/test/mjsunit/strict-mode.js |
@@ -700,3 +700,118 @@ 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 TestAssignmentToReadOnlyProperty() { |
+ "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); |
+})(); |
+ |
+ |
+(function TestAssignmentToReadOnlyLoop() { |
+ var name = "prop" + "erty"; // to avoid symbol path. |
+ var o = {}; |
+ Object.defineProperty(o, "property", { value: 7 }); |
+ |
+ function strict(o, name) { |
+ "use strict"; |
+ o[name] = "new value"; |
+ } |
+ |
+ for (var i = 0; i < 10; i ++) { |
+ try { |
+ strict(o, name); |
+ assertUnreachable(); |
+ } catch(e) { |
+ assertInstanceof(e, TypeError); |
+ } |
+ } |
+})(); |
+ |
+ |
+// Specialized KeyedStoreIC experiencing miss. |
+(function testKeyedStoreICStrict() { |
+ var o = [9,8,7,6,5,4,3,2,1]; |
+ |
+ function test(o, i, v) { |
+ "use strict"; |
+ o[i] = v; |
+ } |
+ |
+ for (var i = 0; i < 10; i ++) { |
+ test(o, 5, 17); // start specialized for smi indices |
+ assertEquals(o[5], 17); |
+ test(o, "a", 19); |
+ assertEquals(o["a"], 19); |
+ test(o, "5", 29); |
+ assertEquals(o[5], 29); |
+ test(o, 100000, 31); |
+ assertEquals(o[100000], 31); |
+ } |
+})(); |