Files
mongo/jstests/core/where5.js
Jason Carey e749ffad9b SERVER-18531 Integrate SpiderMonkey
Provides SpiderMonkey 38.0.1esr as a JS engine for mongo and mongod.
2015-07-14 16:15:54 -04:00

31 lines
799 B
JavaScript

// Tests toString() in object constructor.
// Verifies that native functions do not expose the _native_function and _native_data properties.
var t = db.where5;
t.drop();
t.save({a: 1});
// Prints information on the document's _id field.
function printIdConstructor(doc) {
// If doc is undefined, this function is running inside server.
if (!doc) {
doc = this;
}
// Verify that function and data fields are hidden.
assert(!('_native_function' in sleep));
assert(!('_native_data' in sleep));
// Predicate for matching document in collection.
return true;
}
print('Running JS function in server...');
assert.eq(t.find({$where: printIdConstructor}).itcount(), 1);
print('Running JS function in client...');
var doc = t.findOne();
printIdConstructor(doc);