Move the scripted proxies test into js1_8_5/extensions (bug 546590).

This commit is contained in:
Andreas Gal 2010-05-19 02:08:53 -07:00
Родитель fd15cf0041
Коммит 7576f0f9a9
6 изменённых файлов: 83 добавлений и 79 удалений

Просмотреть файл

@ -7,3 +7,4 @@ skip-if(!xulRuntime.shell) script worker-init.js
skip-if(!xulRuntime.shell) script worker-simple.js
skip-if(!xulRuntime.shell) script worker-terminate.js
skip-if(!xulRuntime.shell) script worker-timeout.js
script scripted-proxies.js

Просмотреть файл

@ -4,8 +4,89 @@
* Contributor: Andreas Gal
*/
/* Test object proxies. */
var gTestfile = 'proxies.js';
//-----------------------------------------------------------------------------
var BUGNUMBER = 546590;
var summary = 'basic scripted proxies tests';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test() {
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus(summary);
testObj({ foo: 1, bar: 2 });
testObj({ 1: 2, 3: 4 });
testObj([ 1, 2, 3 ]);
testObj(new Date());
testObj(new Array());
testObj(new RegExp());
testObj(Date);
testObj(Array);
testObj(RegExp);
/* Test function proxies. */
var proxy = Proxy.createFunction({
get: function(obj,name) { return Function.prototype[name]; },
fix: function() {
return ({});
}
}, function() { return "call"; });
assertEq(proxy(), "call");
assertEq(typeof proxy, "function");
if ("isTrapping" in Proxy) {
assertEq(Proxy.isTrapping(proxy), true);
assertEq(Proxy.fix(proxy), true);
assertEq(Proxy.isTrapping(proxy), false);
assertEq(typeof proxy, "function");
assertEq(proxy(), "call");
}
/* Test function proxies as constructors. */
var proxy = Proxy.createFunction({
get: function(obj, name) { return Function.prototype[name]; },
fix: function() { return ({}); }
},
function() { var x = {}; x.origin = "call"; return x; },
function() { var x = {}; x.origin = "new"; return x; })
assertEq(proxy().origin, "call");
assertEq((new proxy()).origin, "new");
if ("fix" in Proxy) {
assertEq(Proxy.fix(proxy), true);
assertEq(proxy().origin, "call");
assertEq((new proxy()).origin, "new");
}
/* Test fallback on call if no construct trap was given. */
var proxy = Proxy.createFunction({
get: function(obj, name) { return Function.prototype[name]; },
fix: function() { return ({}); }
},
function() { this.origin = "new"; return "new-ret"; });
assertEq((new proxy()).origin, "new");
if ("fix" in Proxy) {
assertEq(Proxy.fix(proxy), true);
assertEq((new proxy()).origin, "new");
}
/* Test invoke. */
var proxy = Proxy.create({ get: function(obj,name) { return function(a,b,c) { return name + uneval([a,b,c]); } }});
assertEq(proxy.foo(1,2,3), "foo[1, 2, 3]");
reportCompare(0, 0, "done.");
exitFunc ('test');
}
/* Test object proxies. */
function noopHandlerMaker(obj) {
return {
getOwnPropertyDescriptor: function(name) {
@ -77,78 +158,3 @@ function testObj(obj) {
testNoopHandler(obj, proxy);
}
}
testObj({ foo: 1, bar: 2 });
testObj({ 1: 2, 3: 4 });
testObj([ 1, 2, 3 ]);
testObj(new Date());
testObj(new Array());
testObj(new RegExp());
testObj(Date);
testObj(Array);
testObj(RegExp);
reportCompare(0, 0, "Proxies: Object proxies.");
/* Test function proxies. */
var proxy = Proxy.createFunction({
get: function(obj,name) { return Function.prototype[name]; },
fix: function() {
return ({});
}
}, function() { return "call"; });
assertEq(proxy(), "call");
assertEq(typeof proxy, "function");
if ("isTrapping" in Proxy) {
assertEq(Proxy.isTrapping(proxy), true);
assertEq(Proxy.fix(proxy), true);
assertEq(Proxy.isTrapping(proxy), false);
assertEq(typeof proxy, "function");
assertEq(proxy(), "call");
}
reportCompare(0, 0, "Proxies: Function proxies.");
/* Test function proxies as constructors. */
var proxy = Proxy.createFunction({
get: function(obj, name) { return Function.prototype[name]; },
fix: function() { return ({}); }
},
function() { var x = {}; x.origin = "call"; return x; },
function() { var x = {}; x.origin = "new"; return x; })
assertEq(proxy().origin, "call");
assertEq((new proxy()).origin, "new");
if ("fix" in Proxy) {
assertEq(Proxy.fix(proxy), true);
assertEq(proxy().origin, "call");
assertEq((new proxy()).origin, "new");
}
reportCompare(0, 0, "Proxies: Function proxies as constructor.");
/* Test fallback on call if no construct trap was given. */
var proxy = Proxy.createFunction({
get: function(obj, name) { return Function.prototype[name]; },
fix: function() { return ({}); }
},
function() { this.origin = "new"; return "new-ret"; });
assertEq((new proxy()).origin, "new");
if ("fix" in Proxy) {
assertEq(Proxy.fix(proxy), true);
assertEq((new proxy()).origin, "new");
}
reportCompare(0, 0, "Proxies: No constructor trap supplied.");
/* Test invoke. */
var proxy = Proxy.create({ get: function(obj,name) { return function(a,b,c) { return name + uneval([a,b,c]); } }});
assertEq(proxy.foo(1,2,3), "foo[1, 2, 3]");
reportCompare(0, 0, "Proxies: Test invoke.");

Просмотреть файл

@ -14,4 +14,3 @@ include js1_7/jstests.list
include js1_8/jstests.list
include js1_8_1/jstests.list
include js1_8_5/jstests.list
include proxies/jstests.list

Просмотреть файл

Просмотреть файл

@ -1,2 +0,0 @@
url-prefix ../../jsreftest.html?test=proxies/
script scripted.js

Просмотреть файл