Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: test/mjsunit/strong/object-set-prototype.js

Issue 1143623002: [strong] Implement per-object restrictions behaviour for prototype setting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strong/object-set-prototype.js
diff --git a/test/mjsunit/strong/object-set-prototype.js b/test/mjsunit/strong/object-set-prototype.js
new file mode 100644
index 0000000000000000000000000000000000000000..53706df1eede758e954673b7b23288c1d022eea6
--- /dev/null
+++ b/test/mjsunit/strong/object-set-prototype.js
@@ -0,0 +1,83 @@
+// 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";
+ return [(function(){}), ({})];
+}
+
+function declareObjectLiteralWithProtoSloppy() {
+ return {__proto__: {}};
+}
+
+function declareObjectLiteralWithProtoStrong() {
+ "use strong";
+ return {__proto__: {}};
+}
+
+function testStrongObjectSetProto() {
+ "use strict";
+ let sloppyObjects = getSloppyObjects();
+ let strictObjects = getStrictObjects();
+ let strongObjects = getStrongObjects();
+ let weakObjects = sloppyObjects.concat(strictObjects);
+
+ for (let o of weakObjects) {
+ let setProtoBuiltin = function(o){Object.setPrototypeOf(o, {})};
+ let setProtoProperty = function(o){o.__proto__ = {}};
+ for (let setProtoFunc of [setProtoBuiltin, setProtoProperty]) {
+ assertDoesNotThrow(function(){setProtoFunc(o)});
+ assertDoesNotThrow(function(){setProtoFunc(o)});
+ assertDoesNotThrow(function(){setProtoFunc(o)});
+ %OptimizeFunctionOnNextCall(setProtoFunc);
+ assertDoesNotThrow(function(){setProtoFunc(o)});
+ %DeoptimizeFunction(setProtoFunc);
+ assertDoesNotThrow(function(){setProtoFunc(o)});
+ }
+ }
+ for (let o of strongObjects) {
+ let setProtoBuiltin = function(o){Object.setPrototypeOf(o, {})};
+ let setProtoProperty = function(o){o.__proto__ = {}};
+ for (let setProtoFunc of [setProtoBuiltin, setProtoProperty]) {
+ assertThrows(function(){setProtoFunc(o)}, TypeError);
+ assertThrows(function(){setProtoFunc(o)}, TypeError);
+ assertThrows(function(){setProtoFunc(o)}, TypeError);
+ %OptimizeFunctionOnNextCall(setProtoFunc);
+ assertThrows(function(){setProtoFunc(o)}, TypeError);
+ %DeoptimizeFunction(setProtoFunc);
+ assertThrows(function(){setProtoFunc(o)}, TypeError);
+ }
+ }
+
+ assertDoesNotThrow(declareObjectLiteralWithProtoSloppy);
+ assertDoesNotThrow(declareObjectLiteralWithProtoSloppy);
+ assertDoesNotThrow(declareObjectLiteralWithProtoSloppy);
+ %OptimizeFunctionOnNextCall(declareObjectLiteralWithProtoSloppy);
+ assertDoesNotThrow(declareObjectLiteralWithProtoSloppy);
+ %DeoptimizeFunction(declareObjectLiteralWithProtoSloppy);
+ assertDoesNotThrow(declareObjectLiteralWithProtoSloppy);
+
+ assertDoesNotThrow(declareObjectLiteralWithProtoStrong);
+ assertDoesNotThrow(declareObjectLiteralWithProtoStrong);
+ assertDoesNotThrow(declareObjectLiteralWithProtoStrong);
+ %OptimizeFunctionOnNextCall(declareObjectLiteralWithProtoStrong);
+ assertDoesNotThrow(declareObjectLiteralWithProtoStrong);
+ %DeoptimizeFunction(declareObjectLiteralWithProtoStrong);
+ assertDoesNotThrow(declareObjectLiteralWithProtoStrong);
+}
+testStrongObjectSetProto();
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698