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

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

Issue 1441043002: [proxies] Implement [[PreventExtensions]] and [[IsExtensible]]. (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
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 (function () {
9 // No trap.
10
11 var target = {};
12 var handler = {};
13 var proxy = new Proxy(target, handler);
14
15 assertTrue(Reflect.isExtensible(target));
16 assertTrue(Reflect.isExtensible(proxy));
17 assertTrue(Reflect.preventExtensions(proxy));
18 assertFalse(Reflect.isExtensible(target));
19 assertFalse(Reflect.isExtensible(proxy));
20 })();
21
22
23 (function () {
24 // "Undefined" trap.
25
26 var target = {};
27 var handler = { isExtensible: null };
28 var proxy = new Proxy(target, handler);
29
30 assertTrue(Reflect.isExtensible(target));
31 assertTrue(Reflect.isExtensible(proxy));
32 assertTrue(Reflect.preventExtensions(proxy));
33 assertFalse(Reflect.isExtensible(target));
34 assertFalse(Reflect.isExtensible(proxy));
35 })();
36
37
38 (function () {
39 // Invalid trap.
40
41 var target = {};
42 var handler = { isExtensible: true };
43 var proxy = new Proxy(target, handler);
44
45 assertThrows(() => {Reflect.isExtensible(proxy)}, TypeError);
46 })();
47
48
49 (function () {
50 var target = {};
51 var handler = { isExtensible() {return "bla"} };
52 var proxy = new Proxy(target, handler);
53
54 // Trap returns trueish and target is extensible.
55 assertTrue(Reflect.isExtensible(proxy));
56
57 // Trap returns trueish but target is not extensible.
58 Reflect.preventExtensions(target);
59 assertThrows(() => {Reflect.isExtensible(proxy)}, TypeError);
60 })();
61
62
63 (function () {
64 var target = {};
65 var handler = { isExtensible() {return 0} };
66 var proxy = new Proxy(target, handler);
67
68 // Trap returns falsish but target is extensible.
69 assertThrows(() => {Reflect.isExtensible(proxy)}, TypeError);
70
71 // Trap returns falsish and target is not extensible.
72 Reflect.preventExtensions(target);
73 assertFalse(Reflect.isExtensible(proxy));
74 })();
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/mjsunit/harmony/proxies-prevent-extensions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698