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

Side by Side Diff: test/mjsunit/harmony/proxies-define-property.js

Issue 1492923002: [proxies] do not leak private symbols to proxy traps (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More tests + cleanup fix Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-proxies 5 // Flags: --harmony-proxies --harmony-reflect --allow-natives-syntax
6 6
7 // Check basic call to trap. 7 // Check basic call to trap.
8 8
9 var g_target, g_name, g_desc; 9 var g_target, g_name, g_desc;
10 var handler = { 10 var handler = {
11 defineProperty: function(target, name, desc) { 11 defineProperty: function(target, name, desc) {
12 g_target = target; 12 g_target = target;
13 g_name = name; 13 g_name = name;
14 g_desc = desc; 14 g_desc = desc;
15 return true; 15 return true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // Step 16a: Trap returns true for non-compatible property descriptor. 66 // Step 16a: Trap returns true for non-compatible property descriptor.
67 Object.defineProperty(target, "foo", 67 Object.defineProperty(target, "foo",
68 {value: 1, writable: false, configurable: false}); 68 {value: 1, writable: false, configurable: false});
69 assertThrows("Object.defineProperty(proxy, 'foo', {value: 2})", TypeError); 69 assertThrows("Object.defineProperty(proxy, 'foo', {value: 2})", TypeError);
70 70
71 // Step 16b: Trap returns true for overwriting a configurable property 71 // Step 16b: Trap returns true for overwriting a configurable property
72 // with a non-configurable descriptor. 72 // with a non-configurable descriptor.
73 target.bar = "baz"; 73 target.bar = "baz";
74 assertThrows("Object.defineProperty(proxy, 'bar', {configurable: false})", 74 assertThrows("Object.defineProperty(proxy, 'bar', {configurable: false})",
75 TypeError); 75 TypeError);
76
77 (function testDefinePrivateSymbol() {
78 var symbol = %CreatePrivateSymbol("secret");
79 var O = {};
80 Object.defineProperty(O, symbol, { value: "value", configurable: true });
81 assertEquals("value", O[symbol]);
82 var proxy = new Proxy(O, { defineProperty(t, n, d) { assertUnreachable(); }});
83 Object.defineProperty(O, symbol, { value: "value", configurable: true });
84 assertEquals(undefined, proxy[symbol]);
85 assertEquals(undefined, Reflect.get(proxy, symbol));
86
87 assertEquals(
88 true, Reflect.defineProperty(O, symbol,
89 { value: "value2", configurable: true }));
neis 2015/12/03 12:01:24 assertTrue
90
91 assertEquals(
92 false, Reflect.defineProperty(proxy, symbol,
93 { value: "value2", configurable: true }));
94 })();
neis 2015/12/03 12:01:24 assertFalse
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698