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

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

Issue 1489423002: [proxies] Make Object.{freeze,seal} behave correctly for proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add some tests. 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 | « test/mjsunit/harmony/proxies-hash.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-proxies --harmony-reflect
6
7
8
9 function toKey(x) {
10 if (typeof x === "symbol") return x;
11 return String(x);
12 }
13
14
15 const noconf = {configurable: false};
16 const noconf_nowrite = {configurable: false, writable: false};
17
18
19 var symbol = Symbol();
20
21
22 var log = [];
23 var logger = {};
24 var handler = new Proxy({}, logger);
25
26 logger.get = function(t, trap, r) {
27 return function() {
28 log.push([trap, ...arguments]);
29 return Reflect[trap](...arguments);
30 }
31 };
32
33
34 (function Seal() {
35 var target = [];
36 var proxy = new Proxy(target, handler);
37 log.length = 0;
38
39 target.wurst = 42;
40 target[0] = true;
41 Object.defineProperty(target, symbol, {get: undefined});
42
43 Object.seal(proxy);
44 assertEquals(6, log.length)
45 for (var i in log) assertSame(target, log[i][1]);
46
47 assertArrayEquals(
48 ["preventExtensions", target], log[0]);
49 assertArrayEquals(
50 ["ownKeys", target], log[1]);
51 assertArrayEquals(
52 ["defineProperty", target, toKey(0), noconf], log[2]);
53 assertArrayEquals(
54 ["defineProperty", target, toKey("length"), noconf], log[3]);
55 assertArrayEquals(
56 ["defineProperty", target, toKey("wurst"), noconf], log[4]);
57 assertArrayEquals(
58 ["defineProperty", target, toKey(symbol), noconf], log[5]);
59 })();
60
61
62 (function Freeze() {
63 var target = [];
64 var proxy = new Proxy(target, handler);
65 log.length = 0;
66
67 target.wurst = 42;
68 target[0] = true;
69 Object.defineProperty(target, symbol, {get: undefined});
70
71 Object.freeze(proxy);
72 assertEquals(10, log.length)
73 for (var i in log) assertSame(target, log[i][1]);
74
75 assertArrayEquals(
76 ["preventExtensions", target], log[0]);
77 assertArrayEquals(
78 ["ownKeys", target], log[1]);
79 assertArrayEquals(
80 ["getOwnPropertyDescriptor", target, toKey(0)], log[2]);
81 assertArrayEquals(
82 ["defineProperty", target, toKey(0), noconf_nowrite], log[3]);
83 assertArrayEquals(
84 ["getOwnPropertyDescriptor", target, toKey("length")], log[4]);
85 assertArrayEquals(
86 ["defineProperty", target, toKey("length"), noconf_nowrite], log[5]);
87 assertArrayEquals(
88 ["getOwnPropertyDescriptor", target, toKey("wurst")], log[6]);
89 assertArrayEquals(
90 ["defineProperty", target, toKey("wurst"), noconf_nowrite], log[7]);
91 assertArrayEquals(
92 ["getOwnPropertyDescriptor", target, toKey(symbol)], log[8]);
93 assertArrayEquals(
94 ["defineProperty", target, toKey(symbol), noconf], log[9]);
95 })();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/proxies-hash.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698