summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/test_bug1131707.js
blob: 57ade9f8c8f5b077bab3fb2efa87baff830920f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function testStrict(sb) {
  "use strict";
  Assert.equal(sb.eval("typeof wrappedCtor()"), "string");
  Assert.equal(sb.eval("typeof new wrappedCtor()"), "object");
}

function run_test() {
  var sb = new Cu.Sandbox(null);
  var dateCtor = sb.Date;
  sb.wrappedCtor = Cu.exportFunction(function wrapper(val) {
    "use strict";
    var constructing = this.constructor == wrapper;
    return constructing ? new dateCtor(val) : dateCtor(val);
  }, sb);
  Assert.equal(typeof Date(), "string");
  Assert.equal(typeof new Date(), "object");
  Assert.equal(sb.eval("typeof wrappedCtor()"), "string");
  Assert.equal(sb.eval("typeof new wrappedCtor()"), "object");
  testStrict(sb);
}