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

Side by Side Diff: test/mjsunit/es6/regress/regress-cr493566.js

Issue 1516843002: [proxy] fixing harmony/proxy.js tests and improving error messages + some drive-by fixes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
6 6
7 "use strict"; 7 "use strict";
8 8
9 9
10 var global = this; 10 var global = this;
11 11
12
13 (function TestGlobalReceiver() {
14 class A {
15 s() {
16 super.bla = 10;
17 }
18 }
19 new A().s.call(global);
20 assertEquals(10, global.bla);
21 })();
22
23
24 (function TestProxyProto() {
25 var calls = 0;
26 var handler = {
27 getPropertyDescriptor: function(name) {
28 calls++;
29 return undefined;
30 }
31 };
32
33 var target = {};
34 var proxy = new Proxy(target, handler);
35 var object = {
36 __proto__: proxy,
37 setX(v) {
38 super.x = v;
39 },
40 setSymbol(sym, v) {
41 super[sym] = v;
42 }
43 };
44
45 object.setX(1);
46 assertEquals(1, Object.getOwnPropertyDescriptor(object, 'x').value);
47 assertEquals(1, calls);
48
49 var sym = Symbol();
50 object.setSymbol.call(global, sym, 2);
51 assertEquals(2, Object.getOwnPropertyDescriptor(global, sym).value);
52 // We currently do not invoke proxy traps for symbols
53 assertEquals(1, calls);
54 })();
55
neis 2015/12/10 15:13:49 Not sure why I just deleted this. Could you try t
56
57 (function TestProxyReceiver() { 12 (function TestProxyReceiver() {
58 var object = { 13 var object = {
59 setY(v) { 14 setY(v) {
60 super.y = v; 15 super.y = v;
61 } 16 }
62 }; 17 };
63 18
64 var calls = 0; 19 var calls = 0;
65 var handler = { 20 var handler = {
66 getPropertyDescriptor(name) { 21 getOwnPropertyDescriptor() {
67 assertUnreachable(); 22 assertUnreachable();
68 }, 23 },
69 set(receiver, name, value) { 24 set(receiver, name, value) {
70 calls++; 25 calls++;
71 assertEquals(proxy, receiver); 26 assertEquals(proxy, receiver);
72 assertEquals('y', name); 27 assertEquals('y', name);
73 assertEquals(3, value); 28 assertEquals(3, value);
74 } 29 }
75 }; 30 };
76 31
77 var proxy = new Proxy({}, handler); 32 var proxy = new Proxy({}, handler);
78 object.setY.call(proxy, 3); 33 object.setY.call(proxy, 3);
79 assertEquals(1, calls); 34 assertEquals(1, calls);
80 })(); 35 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698