blob: 82197d4f1e2f82b8f5b72e8b64fbd81b7b81fa23 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
|
(function() {
"use strict";
// Tests for SERVER-20080
//
// Verify that various types cannot be invoked as constructors
var t = db.jstests_type4;
t.drop();
t.insert({});
t.insert({});
t.insert({});
var oldReadMode = db.getMongo().readMode();
assert.throws(function() {
(new _rand())();
}, [], "invoke constructor on natively injected function");
assert.throws(function() {
var doc = db.test.findOne();
new doc();
}, [], "invoke constructor on BSON");
assert.throws(function() {
db.getMongo().forceReadMode("commands");
var cursor = t.find();
cursor.next();
new cursor._cursor._cursorHandle();
}, [], "invoke constructor on CursorHandle");
assert.throws(function() {
db.getMongo().forceReadMode("legacy");
var cursor = t.find();
cursor.next();
new cursor._cursor();
}, [], "invoke constructor on Cursor");
db.getMongo().forceReadMode(oldReadMode);
})();
|