summaryrefslogtreecommitdiff
path: root/jstests/core/type5.js
blob: d4dfc42d9f66ee54ac6f520ae27b89382e26a272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function() {
    "use strict";

    // This checks SERVER-20375 - Constrain JS method thisv
    //
    // Check to make sure we can't invoke methods on incorrect types, or on
    // prototypes of objects that aren't intended to have methods invoked on
    // them.

    assert.throws(function() {
        HexData(0, "aaaa").hex.apply({});
    }, [], "invoke method on object of incorrect type");
    assert.throws(function() {
        var x = HexData(0, "aaaa");
        x.hex.apply(10);
    }, [], "invoke method on incorrect type");
    assert.throws(function() {
        var x = HexData(0, "aaaa");
        x.hex.apply(x.__proto__);
    }, [], "invoke method on prototype of correct type");

})();