Index: test/mjsunit/es6/regress/regress-cr493566.js |
diff --git a/test/mjsunit/es6/regress/regress-cr493566.js b/test/mjsunit/es6/regress/regress-cr493566.js |
index 95a5a3edd09eb061bbfcfaabf648fc9adb6e73f8..2b0b7eace7b0353eb18b552a8310e4a7f9ac1568 100644 |
--- a/test/mjsunit/es6/regress/regress-cr493566.js |
+++ b/test/mjsunit/es6/regress/regress-cr493566.js |
@@ -2,34 +2,41 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// Flags: --harmony-proxies |
+// Flags: --harmony-proxies --harmony-reflect |
"use strict"; |
- |
- |
var global = this; |
- |
(function TestGlobalReceiver() { |
class A { |
- s() { |
- super.bla = 10; |
+ s(value) { |
+ super.bla = value; |
} |
} |
- new A().s.call(global); |
+ var a = new A(); |
+ a.s(9); |
+ assertEquals(undefined, global.bla); |
+ assertEquals(9, a.bla); |
+ |
+ a = new A(); |
+ a.s.call(global, 10); |
assertEquals(10, global.bla); |
+ assertEquals(undefined, a.bla); |
})(); |
(function TestProxyProto() { |
var calls = 0; |
var handler = { |
- getPropertyDescriptor: function(name) { |
+ set(t, p, v, r) { |
calls++; |
+ return Reflect.set(t, p, v, r); |
+ }, |
+ getPropertyDescriptor(target, name) { |
+ calls += 10; |
return undefined; |
} |
}; |
- |
var target = {}; |
var proxy = new Proxy(target, handler); |
var object = { |
@@ -43,15 +50,23 @@ var global = this; |
}; |
object.setX(1); |
+ assertEquals(1, object.x); |
+ assertEquals(1, Object.getOwnPropertyDescriptor(object, 'x').value); |
+ assertEquals(1, calls); |
+ |
+ calls = 0; |
+ object.setX.call(proxy, 2); |
+ assertEquals(2, target.x); |
assertEquals(1, Object.getOwnPropertyDescriptor(object, 'x').value); |
assertEquals(1, calls); |
var sym = Symbol(); |
+ calls = 0; |
object.setSymbol.call(global, sym, 2); |
assertEquals(2, Object.getOwnPropertyDescriptor(global, sym).value); |
// We currently do not invoke proxy traps for symbols |
assertEquals(1, calls); |
-})(); |
+}); |
(function TestProxyReceiver() { |
@@ -62,19 +77,28 @@ var global = this; |
}; |
var calls = 0; |
+ var target = {target:1}; |
var handler = { |
- getPropertyDescriptor(name) { |
- assertUnreachable(); |
- }, |
- set(receiver, name, value) { |
+ getOwnPropertyDescriptor(t, name) { |
calls++; |
- assertEquals(proxy, receiver); |
- assertEquals('y', name); |
- assertEquals(3, value); |
+ }, |
+ defineProperty(t, name, desc) { |
+ calls += 10; |
+ t[name] = desc.value; |
+ return true; |
+ }, |
+ set(target, name, value) { |
+ assertUnreachable(); |
} |
}; |
+ var proxy = new Proxy(target, handler); |
- var proxy = new Proxy({}, handler); |
+ assertEquals(undefined, object.y); |
+ object.setY(10); |
+ assertEquals(10, object.y); |
+ |
+ // Change the receiver to the proxy, but the set is called on the global. |
object.setY.call(proxy, 3); |
- assertEquals(1, calls); |
+ assertEquals(3, target.y); |
+ assertEquals(11, calls); |
})(); |