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

Unified Diff: test/mjsunit/object-literal.js

Issue 2501553002: [test] Add tests for definitions in object literal. (Closed)
Patch Set: Do not intercept before Context::New() is done. Created 4 years, 1 month 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 | « test/cctest/test-api-interceptors.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/object-literal.js
diff --git a/test/mjsunit/object-literal.js b/test/mjsunit/object-literal.js
index b861d443c0cd0bc011bfcadc20e9a963f608fcd9..6aa64bcb74166a7e0d8c696815815fd36e0373d8 100644
--- a/test/mjsunit/object-literal.js
+++ b/test/mjsunit/object-literal.js
@@ -260,3 +260,45 @@ TestNumericNamesSetter(['1.2', '1.3'], {
set 1.2(_) {; },
set 1.30(_) {; }
});
+
+
+(function TestPrototypeInObjectLiteral() {
+ // The prototype chain should not be used if the definition
+ // happens in the object literal.
+
+ Object.defineProperty(Object.prototype, 'c', {
+ get: function () {
+ return 21;
+ },
+ set: function () {
+ }
+ });
+
+ var o = {};
+ o.c = 7;
+ assertEquals(21, o.c);
+
+ var l = {c: 7};
+ assertEquals(7, l.c);
+
+ delete Object.prototype.c;
+})();
+
+(function TestProxyWithDefinitionInObjectLiteral() {
+ // Trap for set should not be used if the definition
+ // happens in the object literal.
+ var handler = {
+ set: function(target, name, value) {
+ }
+ };
+
+ const prop = 'a';
+
+ var p = new Proxy({}, handler);
+ p[prop] = 'my value';
+ assertEquals(undefined, p[prop]);
+
+
+ var l = new Proxy({[prop]: 'my value'}, handler);
+ assertEquals('my value', l[prop]);
+})();
« no previous file with comments | « test/cctest/test-api-interceptors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698