summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/test_isProxy.js
blob: 7cc5262269c38218c7392631401911bf76aa131a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
}