diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2019-01-29 23:16:33 +0000 |
---|---|---|
committer | Gabriel Russell <gabriel.russell@mongodb.com> | 2019-01-29 23:16:33 +0000 |
commit | 254fff93270089e8ac33be3f7e079aa8bfc3f7bc (patch) | |
tree | ef7f69b2cacc081a16b4da1b58c327f29ae0b8b4 /src/mongo/shell | |
parent | a3d232b697dfc7c8833fc1855abbc190fe0d5970 (diff) | |
download | mongo-254fff93270089e8ac33be3f7e079aa8bfc3f7bc.tar.gz |
Revert "SERVER-29286 import and use mozjs-60"
This reverts commit a3d232b697dfc7c8833fc1855abbc190fe0d5970.
Diffstat (limited to 'src/mongo/shell')
-rw-r--r-- | src/mongo/shell/error_codes.tpl.js | 2 | ||||
-rw-r--r-- | src/mongo/shell/mongo.js | 103 | ||||
-rw-r--r-- | src/mongo/shell/replsettest.js | 11 |
3 files changed, 52 insertions, 64 deletions
diff --git a/src/mongo/shell/error_codes.tpl.js b/src/mongo/shell/error_codes.tpl.js index f4299deae3f..767a48d1ae3 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 (typeof prop !== "symbol" && prop in obj === false && prop in Object === false) { + if (prop !== Symbol.toPrimitive && 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 2f25605536d..4b3f95db88d 100644 --- a/src/mongo/shell/mongo.js +++ b/src/mongo/shell/mongo.js @@ -89,66 +89,63 @@ Mongo.prototype.getDBs = function(driverSession = this._getDefaultSession(), filter = undefined, nameOnly = undefined, authorizedDatabases = undefined) { + 'use strict'; - return function(driverSession, filter, nameOnly, authorizedDatabases) { - 'use strict'; - - let cmdObj = {listDatabases: 1}; - if (filter !== undefined) { - cmdObj.filter = filter; - } - if (nameOnly !== undefined) { - cmdObj.nameOnly = nameOnly; - } - if (authorizedDatabases !== undefined) { - cmdObj.authorizedDatabases = authorizedDatabases; - } + let cmdObj = {listDatabases: 1}; + if (filter !== undefined) { + cmdObj.filter = filter; + } + if (nameOnly !== undefined) { + cmdObj.nameOnly = nameOnly; + } + if (authorizedDatabases !== undefined) { + cmdObj.authorizedDatabases = authorizedDatabases; + } - if (driverSession._isExplicit || !jsTest.options().disableImplicitSessions) { - cmdObj = driverSession._serverSession.injectSessionId(cmdObj); - } + 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}; - }), - }; - } + 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; - }.call(this, driverSession, filter, nameOnly, authorizedDatabases); + return res; }; Mongo.prototype.adminCommand = function(cmd) { diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index ea8766968e6..8f1522b7618 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.includes('/')) { + if (!member.host.contains('/')) { member.host += ":" + this.ports[i]; } @@ -2279,15 +2279,6 @@ 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. |