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

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

Issue 1502983002: [proxies] Make Object.{isFrozen,isSealed} behave correctly for proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 --harmony-reflect 5 // Flags: --harmony-proxies --harmony-reflect
6 6
7 7
8 8
9 function toKey(x) { 9 function toKey(x) {
10 if (typeof x === "symbol") return x; 10 if (typeof x === "symbol") return x;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 ["defineProperty", target, toKey("length"), noconf_nowrite], log[5]); 86 ["defineProperty", target, toKey("length"), noconf_nowrite], log[5]);
87 assertArrayEquals( 87 assertArrayEquals(
88 ["getOwnPropertyDescriptor", target, toKey("wurst")], log[6]); 88 ["getOwnPropertyDescriptor", target, toKey("wurst")], log[6]);
89 assertArrayEquals( 89 assertArrayEquals(
90 ["defineProperty", target, toKey("wurst"), noconf_nowrite], log[7]); 90 ["defineProperty", target, toKey("wurst"), noconf_nowrite], log[7]);
91 assertArrayEquals( 91 assertArrayEquals(
92 ["getOwnPropertyDescriptor", target, toKey(symbol)], log[8]); 92 ["getOwnPropertyDescriptor", target, toKey(symbol)], log[8]);
93 assertArrayEquals( 93 assertArrayEquals(
94 ["defineProperty", target, toKey(symbol), noconf], log[9]); 94 ["defineProperty", target, toKey(symbol), noconf], log[9]);
95 })(); 95 })();
96
97
98 (function IsSealed() {
99 var target = [];
100 var proxy = new Proxy(target, handler);
101
102 target.wurst = 42;
103 target[0] = true;
104 Object.defineProperty(target, symbol, {get: undefined});
105
106 // Extensible.
107
108 log.length = 0;
109
110 Object.isSealed(proxy);
111 assertEquals(1, log.length)
112 for (var i in log) assertSame(target, log[i][1]);
113
114 assertArrayEquals(
115 ["isExtensible", target], log[0]);
116
117 // Not extensible but not sealed.
118
119 log.length = 0;
120 Object.preventExtensions(target);
121
122 Object.isSealed(proxy);
123 assertEquals(3, log.length)
124 for (var i in log) assertSame(target, log[i][1]);
125
126 assertArrayEquals(
127 ["isExtensible", target], log[0]);
128 assertArrayEquals(
129 ["ownKeys", target], log[1]);
130 assertArrayEquals(
131 ["getOwnPropertyDescriptor", target, toKey(0)], log[2]);
132
133 // Sealed.
134
135 log.length = 0;
136 Object.seal(target);
137
138 Object.isSealed(proxy);
139 assertEquals(6, log.length)
140 for (var i in log) assertSame(target, log[i][1]);
141
142 assertArrayEquals(
143 ["isExtensible", target], log[0]);
144 assertArrayEquals(
145 ["ownKeys", target], log[1]);
146 assertArrayEquals(
147 ["getOwnPropertyDescriptor", target, toKey(0)], log[2]);
148 assertArrayEquals(
149 ["getOwnPropertyDescriptor", target, toKey("length")], log[3]);
150 assertArrayEquals(
151 ["getOwnPropertyDescriptor", target, toKey("wurst")], log[4]);
152 assertArrayEquals(
153 ["getOwnPropertyDescriptor", target, toKey(symbol)], log[5]);
154 })();
155
156
157 (function IsFrozen() {
158 var target = [];
159 var proxy = new Proxy(target, handler);
160
161 target.wurst = 42;
162 target[0] = true;
163 Object.defineProperty(target, symbol, {get: undefined});
164
165 // Extensible.
166
167 log.length = 0;
168
169 Object.isFrozen(proxy);
170 assertEquals(1, log.length)
171 for (var i in log) assertSame(target, log[i][1]);
172
173 assertArrayEquals(
174 ["isExtensible", target], log[0]);
175
176 // Not extensible but not frozen.
177
178 log.length = 0;
179 Object.preventExtensions(target);
180
181 Object.isFrozen(proxy);
182 assertEquals(3, log.length)
183 for (var i in log) assertSame(target, log[i][1]);
184
185 assertArrayEquals(
186 ["isExtensible", target], log[0]);
187 assertArrayEquals(
188 ["ownKeys", target], log[1]);
189 assertArrayEquals(
190 ["getOwnPropertyDescriptor", target, toKey(0)], log[2]);
191
192 // Frozen.
193
194 log.length = 0;
195 Object.freeze(target);
196
197 Object.isFrozen(proxy);
198 assertEquals(6, log.length)
199 for (var i in log) assertSame(target, log[i][1]);
200
201 assertArrayEquals(
202 ["isExtensible", target], log[0]);
203 assertArrayEquals(
204 ["ownKeys", target], log[1]);
205 assertArrayEquals(
206 ["getOwnPropertyDescriptor", target, toKey(0)], log[2]);
207 assertArrayEquals(
208 ["getOwnPropertyDescriptor", target, toKey("length")], log[3]);
209 assertArrayEquals(
210 ["getOwnPropertyDescriptor", target, toKey("wurst")], log[4]);
211 assertArrayEquals(
212 ["getOwnPropertyDescriptor", target, toKey(symbol)], log[5]);
213 })();
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698