Merge pull request #1937 from overleaf/spd-sandboxedmodule-global-console

Add 'console' to SandboxedModule globals

GitOrigin-RevId: fad442ca128561a4fa193b929f217cf31ad0f043
This commit is contained in:
Shane Kilkelly
2019-07-15 10:44:47 +00:00
committed by sharelatex
parent 9cc5dc968c
commit 238e2b2565
142 changed files with 453 additions and 0 deletions
@@ -20,6 +20,9 @@ const SandboxedModule = require('sandboxed-module')
describe('doc lines comparitor', function() {
beforeEach(function() {
return (this.comparitor = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'logger-sharelatex': { log() {} }
}
@@ -20,6 +20,9 @@ describe('Project api controller', function() {
beforeEach(function() {
this.ProjectDetailsHandler = { getDetails: sinon.stub() }
this.controller = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'./ProjectDetailsHandler': this.ProjectDetailsHandler,
'logger-sharelatex': {
@@ -34,6 +34,9 @@ describe('ProjectCollabratecDetailsHandler', function() {
this.ProjectCollabratecDetailsHandler = SandboxedModule.require(
modulePath,
{
globals: {
console: console
},
requires: {
'../../models/Project': { Project: this.ProjectModel }
}
@@ -116,6 +116,9 @@ describe('ProjectController', function() {
this.getUserAffiliations = sinon.stub().callsArgWith(1, null, [])
this.ProjectController = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'settings-sharelatex': this.settings,
'logger-sharelatex': {
@@ -89,6 +89,9 @@ describe('ProjectCreationHandler', function() {
this.AnalyticsManager = { recordEvent: sinon.stub() }
return (this.handler = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'../../models/User': {
User: this.User
@@ -72,6 +72,9 @@ describe('ProjectDeleter', function() {
.yields(null, ['member-id-1', 'member-id-2'])
}
return (this.deleter = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'../Editor/EditorController': this.editorController,
'../../models/Project': { Project: this.Project },
@@ -52,6 +52,9 @@ describe('ProjectDetailsHandler', function() {
removeUserFromProject: sinon.stub().callsArg(2)
}
return (this.handler = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'./ProjectGetter': this.ProjectGetter,
'../../models/Project': {
@@ -148,6 +148,9 @@ describe('ProjectDuplicator', function() {
this.ProjectDeleter = { deleteProject: sinon.stub().callsArgWith(1, null) }
return (this.duplicator = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'../../models/Project': { Project: this.Project },
'../DocumentUpdater/DocumentUpdaterHandler': this
@@ -61,6 +61,9 @@ describe('ProjectEntityHandler', function() {
this.callback = sinon.stub()
return (this.ProjectEntityHandler = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
@@ -48,6 +48,9 @@ describe('ProjectEntityMongoUpdateHandler', function() {
tk.freeze(Date.now())
return (this.subject = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
@@ -85,6 +85,9 @@ describe('ProjectEntityUpdateHandler', function() {
return (this.ProjectEntityUpdateHandler = SandboxedModule.require(
modulePath,
{
globals: {
console: console
},
requires: {
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
@@ -24,6 +24,9 @@ describe('ProjectGetter', function() {
beforeEach(function() {
this.callback = sinon.stub()
return (this.ProjectGetter = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'../../infrastructure/mongojs': {
db: (this.db = {
@@ -46,6 +46,9 @@ describe('ProjectHistoryHandler', function() {
this.callback = sinon.stub()
return (this.ProjectHistoryHandler = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
@@ -66,6 +66,9 @@ describe('ProjectLocator', function() {
getProject: sinon.stub().callsArgWith(2, null, project)
}
return (this.locator = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'../../models/Project': { Project },
'../../models/User': { User: this.User },
@@ -32,6 +32,9 @@ describe('ProjectOptionsHandler', function() {
this.projectModel.update = sinon.spy()
return (this.handler = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'../../models/Project': { Project: this.projectModel },
'settings-sharelatex': {
@@ -41,6 +41,9 @@ describe('ProjectRootDocManager', function() {
stat: sinon.stub().callsArgWith(1, null, { size: 100 })
}
return (this.ProjectRootDocManager = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'./ProjectEntityHandler': (this.ProjectEntityHandler = {}),
'./ProjectEntityUpdateHandler': (this.ProjectEntityUpdateHandler = {}),
@@ -29,6 +29,9 @@ describe('ProjectUpdateHandler', function() {
this.ProjectModel = Project = class Project {}
this.ProjectModel.update = sinon.stub().callsArg(3)
return (this.handler = SandboxedModule.require(modulePath, {
globals: {
console: console
},
requires: {
'../../models/Project': { Project: this.ProjectModel },
'logger-sharelatex': { log: sinon.stub() }