Index: test/mjsunit/harmony/proxies.js |
diff --git a/test/mjsunit/harmony/proxies.js b/test/mjsunit/harmony/proxies.js |
index 7a8b194fabbede0fc4946d1e3eb1a474c5c48f0c..c681fee5377f749b45471d992646b59eb38bbe4b 100644 |
--- a/test/mjsunit/harmony/proxies.js |
+++ b/test/mjsunit/harmony/proxies.js |
@@ -35,8 +35,10 @@ |
// Helper. |
function TestWithProxies(test, x, y, z) { |
- test(Proxy.create, x, y, z) |
- test(function(h) {return Proxy.createFunction(h, function() {})}, x, y, z) |
+ test(function(handler) { return new Proxy({}, handler) }, x, y, z) |
+ test(function(handler) { |
+ return Proxy.createFunction(handler, function() {}) |
+ }, x, y, z) |
} |
@@ -81,7 +83,7 @@ TestGetOwnProperty({ |
} |
}) |
-TestGetOwnProperty(Proxy.create({ |
+TestGetOwnProperty(new Proxy({}, { |
get: function(pr, pk) { |
return function(k) { key = k; return {value: 42, configurable: true} } |
} |
@@ -1824,61 +1826,59 @@ TestKeysThrow({ |
// Object.isFrozen, Object.isSealed, Object.isExtensible) |
function TestFix(names, handler) { |
-// TODO(neis): Reenable/adapt once proxies properly support these operations. |
-// |
-// var proto = {p: 77} |
-// var assertFixing = function(o, s, f, e) { |
-// assertEquals(s, Object.isSealed(o)) |
-// assertEquals(f, Object.isFrozen(o)) |
-// assertEquals(e, Object.isExtensible(o)) |
-// } |
-// |
-// var p1 = Proxy.create(handler, proto) |
-// assertFixing(p1, false, false, true) |
-// Object.seal(p1) |
-// assertFixing(p1, true, names.length === 0, false) |
-// assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p1).sort()) |
-// assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), |
-// Object.keys(p1).sort()) |
-// assertEquals(proto, Object.getPrototypeOf(p1)) |
-// assertEquals(77, p1.p) |
-// for (var n in p1) { |
-// var desc = Object.getOwnPropertyDescriptor(p1, n) |
-// if (desc !== undefined) assertFalse(desc.configurable) |
-// } |
-// |
-// var p2 = Proxy.create(handler, proto) |
-// assertFixing(p2, false, false, true) |
-// Object.freeze(p2) |
-// assertFixing(p2, true, true, false) |
-// assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p2).sort()) |
-// assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), |
-// Object.keys(p2).sort()) |
-// assertEquals(proto, Object.getPrototypeOf(p2)) |
-// assertEquals(77, p2.p) |
-// for (var n in p2) { |
-// var desc = Object.getOwnPropertyDescriptor(p2, n) |
-// if (desc !== undefined) assertFalse(desc.writable) |
-// if (desc !== undefined) assertFalse(desc.configurable) |
-// } |
-// |
-// var p3 = Proxy.create(handler, proto) |
-// assertFixing(p3, false, false, true) |
-// Object.preventExtensions(p3) |
-// assertFixing(p3, names.length === 0, names.length === 0, false) |
-// assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p3).sort()) |
-// assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), |
-// Object.keys(p3).sort()) |
-// assertEquals(proto, Object.getPrototypeOf(p3)) |
-// assertEquals(77, p3.p) |
-// |
-// var p = Proxy.create(handler, proto) |
-// var o = Object.create(p) |
-// assertFixing(p, false, false, true) |
-// assertFixing(o, false, false, true) |
-// Object.freeze(o) |
-// assertFixing(p, false, false, true) |
-// assertFixing(o, true, true, false) |
+ var target = {p: 77} |
+ var assertFixing = function(o, s, f, e) { |
+ assertEquals(s, Object.isSealed(o)) |
+ assertEquals(f, Object.isFrozen(o)) |
+ assertEquals(e, Object.isExtensible(o)) |
+ } |
+ |
+ var p1 = new Proxy(target, handler) |
+ assertFixing(p1, false, false, true) |
+ Object.seal(p1) |
+ assertFixing(p1, true, names.length === 0, false) |
+ assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p1).sort()) |
+ assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), |
+ Object.keys(p1).sort()) |
+ assertEquals(target, Object.getPrototypeOf(p1)) |
+ assertEquals(77, p1.p) |
+ for (var n in p1) { |
+ var desc = Object.getOwnPropertyDescriptor(p1, n) |
+ if (desc !== undefined) assertFalse(desc.configurable) |
+ } |
+ |
+ var p2 = new Proxy(target, handler) |
+ assertFixing(p2, false, false, true) |
+ Object.freeze(p2) |
+ assertFixing(p2, true, true, false) |
+ assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p2).sort()) |
+ assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), |
+ Object.keys(p2).sort()) |
+ assertEquals(target, Object.getPrototypeOf(p2)) |
+ assertEquals(77, p2.p) |
+ for (var n in p2) { |
+ var desc = Object.getOwnPropertyDescriptor(p2, n) |
+ if (desc !== undefined) assertFalse(desc.writable) |
+ if (desc !== undefined) assertFalse(desc.configurable) |
+ } |
+ |
+ var p3 = new Proxy(target, handler) |
+ assertFixing(p3, false, false, true) |
+ Object.preventExtensions(p3) |
+ assertFixing(p3, names.length === 0, names.length === 0, false) |
+ assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p3).sort()) |
+ assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), |
+ Object.keys(p3).sort()) |
+ assertEquals(target, Object.getPrototypeOf(p3)) |
+ assertEquals(77, p3.p) |
+ |
+ var p = new Proxy(target, handler) |
+ var o = Object.create(p) |
+ assertFixing(p, false, false, true) |
+ assertFixing(o, false, false, true) |
+ Object.freeze(o) |
+ assertFixing(p, false, false, true) |
+ assertFixing(o, true, true, false) |
} |
TestFix([], { |
@@ -1914,25 +1914,23 @@ TestFix(["b"], { |
function TestFixFunction(fix) { |
-// TODO(neis): Reenable/adapt once proxies properly support these operations. |
-// |
-// var f1 = Proxy.createFunction({ |
-// fix: function() { return {} } |
-// }, function() {}) |
-// fix(f1) |
-// assertEquals(0, f1.length) |
-// |
-// var f2 = Proxy.createFunction({ |
-// fix: function() { return {length: {value: 3}} } |
-// }, function() {}) |
-// fix(f2) |
-// assertEquals(3, f2.length) |
-// |
-// var f3 = Proxy.createFunction({ |
-// fix: function() { return {length: {value: "huh"}} } |
-// }, function() {}) |
-// fix(f3) |
-// assertEquals(0, f1.length) |
+ var f1 = Proxy.createFunction({ |
+ fix: function() { return {} } |
+ }, function() {}) |
+ fix(f1) |
+ assertEquals(0, f1.length) |
+ |
+ var f2 = Proxy.createFunction({ |
+ fix: function() { return {length: {value: 3}} } |
+ }, function() {}) |
+ fix(f2) |
+ assertEquals(3, f2.length) |
+ |
+ var f3 = Proxy.createFunction({ |
+ fix: function() { return {length: {value: "huh"}} } |
+ }, function() {}) |
+ fix(f3) |
+ assertEquals(0, f1.length) |
} |
TestFixFunction(Object.seal) |
@@ -1945,12 +1943,10 @@ function TestFixThrow(handler) { |
} |
function TestFixThrow2(create, handler) { |
-// TODO(neis): Reenable/adapt once proxies properly support these operations. |
-// |
-// var p = create(handler, {}) |
-// assertThrows(function(){ Object.seal(p) }, "myexn") |
-// assertThrows(function(){ Object.freeze(p) }, "myexn") |
-// assertThrows(function(){ Object.preventExtensions(p) }, "myexn") |
+ var p = create(handler, {}) |
+ assertThrows(function(){ Object.seal(p) }, "myexn") |
+ assertThrows(function(){ Object.freeze(p) }, "myexn") |
+ assertThrows(function(){ Object.preventExtensions(p) }, "myexn") |
} |
TestFixThrow({ |
@@ -1977,11 +1973,9 @@ TestFixThrow({ |
// TODO(rossberg): actual behaviour not specified consistently at the moment, |
// just make sure that we do not crash. |
function TestReentrantFix(f) { |
-// TODO(neis): Reenable/adapt once proxies properly support these operations. |
-// |
-// TestWithProxies(f, Object.freeze) |
-// TestWithProxies(f, Object.seal) |
-// TestWithProxies(f, Object.preventExtensions) |
+ TestWithProxies(f, Object.freeze) |
+ TestWithProxies(f, Object.seal) |
+ TestWithProxies(f, Object.preventExtensions) |
} |
TestReentrantFix(function(create, freeze) { |