summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/test_isProxy.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/xpconnect/tests/unit/test_isProxy.js')
-rw-r--r--js/xpconnect/tests/unit/test_isProxy.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/js/xpconnect/tests/unit/test_isProxy.js b/js/xpconnect/tests/unit/test_isProxy.js
new file mode 100644
index 000000000..7cc526226
--- /dev/null
+++ b/js/xpconnect/tests/unit/test_isProxy.js
@@ -0,0 +1,29 @@
+function run_test() {
+ var Cu = Components.utils;
+
+ var handler = {
+ get: function(target, name){
+ return name in target?
+ target[name] :
+ 37;
+ }
+ };
+
+ var p = new Proxy({}, handler);
+ do_check_true(Cu.isProxy(p));
+ do_check_false(Cu.isProxy({}));
+ do_check_false(Cu.isProxy(42));
+
+ sb = new Cu.Sandbox(this,
+ { wantExportHelpers: true });
+
+ do_check_false(Cu.isProxy(sb));
+
+ sb.do_check_true = do_check_true;
+ sb.do_check_false = do_check_false;
+ sb.p = p;
+ Cu.evalInSandbox('do_check_true(isProxy(p));' +
+ 'do_check_false(isProxy({}));' +
+ 'do_check_false(isProxy(42));',
+ sb);
+}