summaryrefslogtreecommitdiff
path: root/src/mongo/shell
diff options
context:
space:
mode:
authorGabriel Russell <gabriel.russell@mongodb.com>2019-01-11 19:27:20 +0000
committerGabriel Russell <gabriel.russell@mongodb.com>2019-01-29 23:06:10 +0000
commita3d232b697dfc7c8833fc1855abbc190fe0d5970 (patch)
treefb02e9d3383f6342944fc4f2cd494ea86d42a92a /src/mongo/shell
parent941c4fbab21029e3bbe577d953250116cd0e8533 (diff)
downloadmongo-a3d232b697dfc7c8833fc1855abbc190fe0d5970.tar.gz
SERVER-29286 import and use mozjs-60
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/error_codes.tpl.js2
-rw-r--r--src/mongo/shell/mongo.js103
-rw-r--r--src/mongo/shell/replsettest.js11
3 files changed, 64 insertions, 52 deletions
diff --git a/src/mongo/shell/error_codes.tpl.js b/src/mongo/shell/error_codes.tpl.js
index 767a48d1ae3..f4299deae3f 100644
--- a/src/mongo/shell/error_codes.tpl.js
+++ b/src/mongo/shell/error_codes.tpl.js
@@ -31,7 +31,7 @@
var {ErrorCodes, ErrorCodeStrings} = (function() {
const handler = {
get: function(obj, prop) {
- if (prop !== Symbol.toPrimitive && prop in obj === false && prop in Object === false) {
+ if (typeof prop !== "symbol" && prop in obj === false && prop in Object === false) {
throw new Error('Unknown Error Code: ' + prop.toString());
}
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js
index 4b3f95db88d..2f25605536d 100644
--- a/src/mongo/shell/mongo.js
+++ b/src/mongo/shell/mongo.js
@@ -89,63 +89,66 @@ Mongo.prototype.getDBs = function(driverSession = this._getDefaultSession(),
filter = undefined,
nameOnly = undefined,
authorizedDatabases = undefined) {
- 'use strict';
- let cmdObj = {listDatabases: 1};
- if (filter !== undefined) {
- cmdObj.filter = filter;
- }
- if (nameOnly !== undefined) {
- cmdObj.nameOnly = nameOnly;
- }
- if (authorizedDatabases !== undefined) {
- cmdObj.authorizedDatabases = authorizedDatabases;
- }
+ return function(driverSession, filter, nameOnly, authorizedDatabases) {
+ 'use strict';
- if (driverSession._isExplicit || !jsTest.options().disableImplicitSessions) {
- cmdObj = driverSession._serverSession.injectSessionId(cmdObj);
- }
+ let cmdObj = {listDatabases: 1};
+ if (filter !== undefined) {
+ cmdObj.filter = filter;
+ }
+ if (nameOnly !== undefined) {
+ cmdObj.nameOnly = nameOnly;
+ }
+ if (authorizedDatabases !== undefined) {
+ cmdObj.authorizedDatabases = authorizedDatabases;
+ }
- const res = this.adminCommand(cmdObj);
- if (!res.ok) {
- // If "Unauthorized" was returned by the back end and we haven't explicitly
- // asked for anything difficult to provide from userspace, then we can
- // fallback on inspecting the user's permissions.
- // This means that:
- // * filter must be undefined, as reimplementing that logic is out of scope.
- // * nameOnly must not be false as we can't infer size information.
- // * authorizedDatabases must not be false as those are the only DBs we can infer.
- // Note that if the above are valid and we get Unauthorized, that also means
- // that we MUST be talking to a pre-4.0 mongod.
- //
- // Like the server response mode, this path will return a simple list of
- // names if nameOnly is specified as true.
- // If nameOnly is undefined, we come as close as we can to what the
- // server would return by supplying the databases key of the returned
- // object. Other information is unavailable.
- if ((res.code === ErrorCodes.Unauthorized) && (filter === undefined) &&
- (nameOnly !== false) && (authorizedDatabases !== false)) {
- const names = this._getDatabaseNamesFromPrivileges();
- if (nameOnly === true) {
- return names;
- } else {
- return {
- databases: names.map(function(x) {
- return {name: x};
- }),
- };
+ if (driverSession._isExplicit || !jsTest.options().disableImplicitSessions) {
+ cmdObj = driverSession._serverSession.injectSessionId(cmdObj);
+ }
+
+ const res = this.adminCommand(cmdObj);
+ if (!res.ok) {
+ // If "Unauthorized" was returned by the back end and we haven't explicitly
+ // asked for anything difficult to provide from userspace, then we can
+ // fallback on inspecting the user's permissions.
+ // This means that:
+ // * filter must be undefined, as reimplementing that logic is out of scope.
+ // * nameOnly must not be false as we can't infer size information.
+ // * authorizedDatabases must not be false as those are the only DBs we can infer.
+ // Note that if the above are valid and we get Unauthorized, that also means
+ // that we MUST be talking to a pre-4.0 mongod.
+ //
+ // Like the server response mode, this path will return a simple list of
+ // names if nameOnly is specified as true.
+ // If nameOnly is undefined, we come as close as we can to what the
+ // server would return by supplying the databases key of the returned
+ // object. Other information is unavailable.
+ if ((res.code === ErrorCodes.Unauthorized) && (filter === undefined) &&
+ (nameOnly !== false) && (authorizedDatabases !== false)) {
+ const names = this._getDatabaseNamesFromPrivileges();
+ if (nameOnly === true) {
+ return names;
+ } else {
+ return {
+ databases: names.map(function(x) {
+ return {name: x};
+ }),
+ };
+ }
}
+ throw _getErrorWithCode(res, "listDatabases failed:" + tojson(res));
}
- throw _getErrorWithCode(res, "listDatabases failed:" + tojson(res));
- }
- if (nameOnly) {
- return res.databases.map(function(db) {
- return db.name;
- });
- }
+ if (nameOnly) {
+ return res.databases.map(function(db) {
+ return db.name;
+ });
+ }
- return res;
+ return res;
+ }.call(this, driverSession, filter, nameOnly, authorizedDatabases);
};
Mongo.prototype.adminCommand = function(cmd) {
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 8f1522b7618..ea8766968e6 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -484,7 +484,7 @@ var ReplSetTest = function(opts) {
member._id = i;
member.host = this.host;
- if (!member.host.contains('/')) {
+ if (!member.host.includes('/')) {
member.host += ":" + this.ports[i];
}
@@ -2279,6 +2279,15 @@ var ReplSetTest = function(opts) {
// Turn off periodic noop writes for replica sets by default.
options.setParameter = options.setParameter || {};
+ if (typeof(options.setParameter) === "string") {
+ var eqIdx = options.setParameter.indexOf("=");
+ if (eqIdx != -1) {
+ var param = options.setParameter.substring(0, eqIdx);
+ var value = options.setParameter.substring(eqIdx + 1);
+ options.setParameter = {};
+ options.setParameter[param] = value;
+ }
+ }
options.setParameter.writePeriodicNoops = options.setParameter.writePeriodicNoops || false;
// We raise the number of initial sync connect attempts for tests that disallow chaining.