summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/test_isProxy.js
blob: 996aa320b94a38a418c74925c014358cb8d6d2b5 (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
function run_test() {
  var handler = {
      get: function(target, name){
          return name in target?
              target[name] :
              37;
      }
  };

  var p = new Proxy({}, handler);
  Assert.ok(Cu.isProxy(p));
  Assert.ok(!Cu.isProxy({}));
  Assert.ok(!Cu.isProxy(42));

  sb = new Cu.Sandbox(this,
                      { wantExportHelpers: true });

  Assert.ok(!Cu.isProxy(sb));

  sb.ok = ok;
  sb.p = p;
  Cu.evalInSandbox('ok(isProxy(p));' +
                   'ok(!isProxy({}));' +
                   'ok(!isProxy(42));',
                   sb);
}